diff --git a/lib/chibi/iset/constructors.scm b/lib/chibi/iset/constructors.scm index bdbc4e3b..ba43c58c 100644 --- a/lib/chibi/iset/constructors.scm +++ b/lib/chibi/iset/constructors.scm @@ -81,7 +81,7 @@ (if (let* ((left (iset-left iset)) (m-end (and left (iset-max-end left)))) (and m-end - (or (< n m-end) + (or (<= n m-end) (< (- n m-end) s-diff)))) (iset-adjoin1! (iset-left iset) n) (cond @@ -98,7 +98,7 @@ (if (let* ((right (iset-right iset)) (m-start (and right (iset-min-start right)))) (and m-start - (or (> n m-start) + (or (>= n m-start) (> (- n m-start) e-diff)))) (iset-adjoin1! (iset-right iset) n) (cond diff --git a/tests/iset-tests.scm b/tests/iset-tests.scm index 40fc076b..0c3c072c 100644 --- a/tests/iset-tests.scm +++ b/tests/iset-tests.scm @@ -1,6 +1,7 @@ (cond-expand - (modules (import (chibi iset) (chibi iset optimize) (srfi 1) (chibi test))) + (modules + (import (chibi) (chibi iset) (chibi iset optimize) (srfi 1) (chibi test))) (else #f)) (test-begin "iset") @@ -15,6 +16,7 @@ ((0 1 2) (- 1) (- 2) (? 0)) ((1 2 3 1000 2000) (u 1 4)) ((1 2 3 1000 1005)) + ((97308 97827 97845 97827)) ((1 128 127)) ((129 2 127)) ((1 -128 -126)) @@ -25,10 +27,11 @@ (for-each (lambda (tst) (let* ((ls (car tst)) - (is (list->iset ls))) + (is (list->iset ls)) + (ls2 (delete-duplicates ls =))) ;; initial creation and sanity checks - (test-assert (lset= equal? ls (iset->list is))) - (test (length ls) (iset-size is)) + (test-assert (lset= equal? ls2 (iset->list is))) + (test (length ls2) (iset-size is)) (for-each (lambda (x) (test-assert (iset-contains? is x))) ls)