Raymond Toy pushed to branch issue-240-add-hashtable-set-exclusive-or at cmucl / cmucl

Commits:

1 changed file:

Changes:

  • tests/sets.lisp
    ... ... @@ -230,238 +230,6 @@
    230 230
         (test 1)))
    
    231 231
     
    
    232 232
     
    
    233
    -(define-test subsetp.hash-eq
    
    234
    -    (:tag :issues)
    
    235
    -  (let ((lisp::*min-list-length-for-hashtable* 2))
    
    236
    -    (assert-true
    
    237
    -     (subsetp '(a b c a) '(a a d d c b) :test 'eq))
    
    238
    -    (assert-true
    
    239
    -     (subsetp '(a b c a b c a b c) '(a a d d c b) :test 'eq))
    
    240
    -    (assert-false
    
    241
    -     (subsetp '(a b c a z) '(a a d d c b) :test 'eq))
    
    242
    -    (assert-false
    
    243
    -     (subsetp '(a b c a b cz) '(a a d d c b) :test 'eq))))
    
    244
    -
    
    245
    -(define-test subsetp.hash-eql
    
    246
    -    (:tag :issues)
    
    247
    -  (let ((lisp::*min-list-length-for-hashtable* 2))
    
    248
    -    (assert-true
    
    249
    -     (subsetp '(a b c a) '(a a d d c b) :test 'eql))
    
    250
    -    (assert-false
    
    251
    -     (subsetp '(a b c a z) '(a a d d c b) :test 'eql))))
    
    252
    -
    
    253
    -(define-test subsetp.hash-equal
    
    254
    -    (:tag :issues)
    
    255
    -  (let ((lisp::*min-list-length-for-hashtable* 2))
    
    256
    -    (assert-true
    
    257
    -     (subsetp '("a" "b" "c" "a") '("a" "a" "d" "d" "c" "b") :test 'equal))
    
    258
    -    (assert-false
    
    259
    -     (subsetp '("a" "b" "c" "a" "z") '("a" "a" "d" "d" "c" "b") :test 'equal))))
    
    260
    -
    
    261
    -(define-test subsetp.hash-equalp
    
    262
    -    (:tag :issues)
    
    263
    -  (let ((lisp::*min-list-length-for-hashtable* 2))
    
    264
    -    (assert-true
    
    265
    -     (subsetp '("a" "b" "C" "A") '("a" "a" "d" "d" "c" "b") :test 'equalp))
    
    266
    -    (assert-false
    
    267
    -     (subsetp '("a" "b" "C" "A" "z") '("a" "a" "d" "d" "c" "b") :test 'equalp))))
    
    268
    -
    
    269
    -(define-test subsetp.hash-eql-with-key
    
    270
    -    (:tag :issues)
    
    271
    -  (assert-true (subsetp '((1 "a") (2 "b") (3 "c"))
    
    272
    -                        '((3 "c") (3 "c") (2 "b") (1 "a"))
    
    273
    -                        :test 'eql
    
    274
    -                        :key #'first)))
    
    275
    -
    
    276
    -(define-test subsetp.test-and-test-not
    
    277
    -  (assert-error 'simple-error
    
    278
    -                (subsetp '(1 2)
    
    279
    -                         '(3 4)
    
    280
    -                         :test 'eql
    
    281
    -                         :test-not 'equal)))
    
    282
    -
    
    283
    -(define-test set-exclusive-or.1
    
    284
    -  (:tag :issues)
    
    285
    -  ;; From CLHS
    
    286
    -  (assert-equal '("b" "A" "b" "a")
    
    287
    -                (set-exclusive-or '(1 "a" "b")
    
    288
    -                                  '(1 "A" "b")))
    
    289
    -  ;; Tests for sets
    
    290
    -
    
    291
    -(defpackage :sets-tests
    
    292
    -  (:use :cl :lisp-unit))
    
    293
    -
    
    294
    -(in-package "SETS-TESTS")
    
    295
    -
    
    296
    -(define-test set-diff.hash-eql
    
    297
    -    (:tag :issues)
    
    298
    -  ;; For set-difference to use hashtables by making the threshold
    
    299
    -  ;; small.
    
    300
    -  (let ((lisp::*min-list-length-for-hashtable* 2))
    
    301
    -    (assert-equal '(2 2 1)
    
    302
    -		  (set-difference '(1 2 2 3) '(3 4)))
    
    303
    -    (assert-equal '(2 2 1)
    
    304
    -		  (set-difference '(1 2 2 3) '(3 4 5 6 7 8)))
    
    305
    -    (assert-equal '(2 2 1)
    
    306
    -		  (set-difference '(1 2 2 3) '(3 4)
    
    307
    -				  :test #'eql))
    
    308
    -    (assert-equal '(2 2 1)
    
    309
    -		  (set-difference '(1 2 2 3) '(3 4 5 6 7 8)
    
    310
    -				  :test #'eql))))
    
    311
    -
    
    312
    -(define-test set-diff.hash-eq
    
    313
    -    (:tag :issues)
    
    314
    -  (let ((lisp::*min-list-length-for-hashtable* 2))
    
    315
    -    (assert-equal '(b b a)
    
    316
    -		  (set-difference '(a b b c) '(c d e) :test 'eq))
    
    317
    -    (assert-equal '(b b a)
    
    318
    -		  (set-difference '(a b b c) '(c d e f g h) :test 'eq))
    
    319
    -    (assert-equal '(b b a)
    
    320
    -		  (set-difference '(a b b c) '(c d e) :test #'eq))
    
    321
    -    (assert-equal '(b b a)
    
    322
    -		  (set-difference '(a b b c) '(c d e f g h) :test #'eq))))
    
    323
    -
    
    324
    -(define-test set-diff.hash-equal
    
    325
    -    (:tag :issues)
    
    326
    -  (let ((lisp::*min-list-length-for-hashtable* 2))
    
    327
    -    (assert-equal '("b" "b" "a")
    
    328
    -		  (set-difference '("a" "b" "b" "c")
    
    329
    -				  '("c" "d" "e")
    
    330
    -				  :test 'equal))
    
    331
    -    (assert-equal '("b" "b" "a")
    
    332
    -		  (set-difference '("a" "b" "b" "c")
    
    333
    -				  '("c" "d" "e" "f" "g" "h")
    
    334
    -				  :test 'equal))
    
    335
    -    (assert-equal '("b" "b" "a")
    
    336
    -		  (set-difference '("a" "b" "b" "c")
    
    337
    -				  '("c" "d" "e")
    
    338
    -				  :test #'equal))
    
    339
    -    (assert-equal '("b" "b" "a")
    
    340
    -		  (set-difference '("a" "b" "b" "c")
    
    341
    -				  '("c" "d" "e" "f" "g" "h")
    
    342
    -				  :test #'equal))))
    
    343
    -
    
    344
    -(define-test set-diff.hash-equalp
    
    345
    -    (:tag :issues)
    
    346
    -  (let ((lisp::*min-list-length-for-hashtable* 2))
    
    347
    -    (assert-equal '("b" "b" "a")
    
    348
    -		  (set-difference '("a" "b" "b" "c")
    
    349
    -				  '("C" "d" "e")
    
    350
    -				  :test 'equalp))
    
    351
    -    (assert-equal '("b" "b" "a")
    
    352
    -		  (set-difference '("a" "b" "b" "C")
    
    353
    -				  '("c" "D" "e" "f" "g" "h")
    
    354
    -				  :test 'equalp))
    
    355
    -    (assert-equal '("b" "b" "a")
    
    356
    -		  (set-difference '("a" "b" "b" "c")
    
    357
    -				  '("C" "d" "e")
    
    358
    -				  :test #'equalp))
    
    359
    -    (assert-equal '("b" "b" "a")
    
    360
    -		  (set-difference '("a" "b" "b" "C")
    
    361
    -				  '("c" "D" "e" "f" "g" "h")
    
    362
    -				  :test #'equalp))))
    
    363
    -
    
    364
    -;; Simple test that we handle a key correctly
    
    365
    -(define-test set-diff.hash-eql-with-key
    
    366
    -  (let ((lisp::*min-list-length-for-hashtable* 2))
    
    367
    -    (assert-equal '((3 "b") (2 "b"))
    
    368
    -		  (set-difference '((1 "a") (2 "b") (3 "b"))
    
    369
    -				  '((1 "a") (4 "c") (5 "d"))
    
    370
    -				  :key #'first))))
    
    371
    -
    
    372
    -(define-test set-diff.test-and-test-not
    
    373
    -  (assert-error 'simple-error
    
    374
    -		(set-difference '(1 2)
    
    375
    -				'(3 4)
    
    376
    -				:test 'eql
    
    377
    -				:test-not 'eql)))
    
    378
    -
    
    379
    -   
    
    380
    -
    
    381
    -(define-test union.hash-eql
    
    382
    -    (:tag :issues)
    
    383
    -  ;; For union to use hashtables by making the threshold
    
    384
    -  ;; small.
    
    385
    -  (let ((lisp::*min-list-length-for-hashtable* 2))
    
    386
    -    (assert-equal '(2 2 1 3 4)
    
    387
    -		  (union '(1 2 2 3) '(3 4)))
    
    388
    -    (assert-equal '(2 2 1 3 4 5 6 7 8)
    
    389
    -		  (union '(1 2 2 3) '(3 4 5 6 7 8)))
    
    390
    -    (assert-equal '(2 2 1 3 4)
    
    391
    -		  (union '(1 2 2 3) '(3 4)
    
    392
    -			 :test #'eql))
    
    393
    -    (assert-equal '(2 2 1 3 4 5 6 7 8)
    
    394
    -		  (union '(1 2 2 3) '(3 4 5 6 7 8)
    
    395
    -			 :test #'eql))))
    
    396
    -
    
    397
    -(define-test union.hash-eq
    
    398
    -    (:tag :issues)
    
    399
    -  (let ((lisp::*min-list-length-for-hashtable* 2))
    
    400
    -    (assert-equal '(b b a c d e)
    
    401
    -		  (union '(a b b c) '(c d e) :test 'eq))
    
    402
    -    (assert-equal '(b b a c d e f g h)
    
    403
    -		  (union '(a b b c) '(c d e f g h) :test 'eq))
    
    404
    -    (assert-equal '(b b a c d e)
    
    405
    -		  (union '(a b b c) '(c d e) :test #'eq))
    
    406
    -    (assert-equal '(b b a c d e f g h)
    
    407
    -		  (union '(a b b c) '(c d e f g h) :test #'eq))))
    
    408
    -
    
    409
    -(define-test union.hash-equal
    
    410
    -    (:tag :issues)
    
    411
    -  (let ((lisp::*min-list-length-for-hashtable* 2))
    
    412
    -    (assert-equal '("b" "b" "a" "c" "d" "e")
    
    413
    -		  (union '("a" "b" "b" "c")
    
    414
    -			 '("c" "d" "e")
    
    415
    -			 :test 'equal))
    
    416
    -    (assert-equal '("b" "b" "a" "c" "d" "e" "f" "g" "h")
    
    417
    -		  (union '("a" "b" "b" "c")
    
    418
    -			 '("c" "d" "e" "f" "g" "h")
    
    419
    -			 :test 'equal))
    
    420
    -    (assert-equal '("b" "b" "a" "c" "d" "e")
    
    421
    -		  (union '("a" "b" "b" "c")
    
    422
    -			 '("c" "d" "e")
    
    423
    -			 :test #'equal))
    
    424
    -    (assert-equal '("b" "b" "a" "c" "d" "e" "f" "g" "h")
    
    425
    -		  (union '("a" "b" "b" "c")
    
    426
    -			 '("c" "d" "e" "f" "g" "h")
    
    427
    -			 :test #'equal))))
    
    428
    -
    
    429
    -(define-test union.hash-equalp
    
    430
    -    (:tag :issues)
    
    431
    -  (let ((lisp::*min-list-length-for-hashtable* 2))
    
    432
    -    (assert-equal '("b" "b" "a" "C" "d" "e")
    
    433
    -		  (union '("a" "b" "b" "c")
    
    434
    -			 '("C" "d" "e")
    
    435
    -			 :test 'equalp))
    
    436
    -    (assert-equal '("b" "b" "a" "c" "D" "e" "f" "g" "h")
    
    437
    -		  (union '("a" "b" "b" "C")
    
    438
    -			 '("c" "D" "e" "f" "g" "h")
    
    439
    -			 :test 'equalp))
    
    440
    -    (assert-equal '("b" "b" "a" "C" "d" "e")
    
    441
    -		  (union '("a" "b" "b" "c")
    
    442
    -			 '("C" "d" "e")
    
    443
    -			 :test #'equalp))
    
    444
    -    (assert-equal '("b" "b" "a" "c" "D" "e" "f" "g" "h")
    
    445
    -		  (union '("a" "b" "b" "C")
    
    446
    -			 '("c" "D" "e" "f" "g" "h")
    
    447
    -			 :test #'equalp))))
    
    448
    -
    
    449
    -;; Simple test that we handle a key correctly
    
    450
    -(define-test union.hash-eql-with-key
    
    451
    -  (let ((lisp::*min-list-length-for-hashtable* 2))
    
    452
    -    (assert-equal '((3 "b") (2 "b") (1 "a") (4 "c") (5 "d"))
    
    453
    -		  (union '((1 "a") (2 "b") (3 "b"))
    
    454
    -			 '((1 "a") (4 "c") (5 "d"))
    
    455
    -			 :key #'first))))
    
    456
    -
    
    457
    -(define-test union.test-and-test-not
    
    458
    -  (assert-error 'simple-error
    
    459
    -		(union '(1 2)
    
    460
    -		       '(3 4)
    
    461
    -		       :test 'eql
    
    462
    -		       :test-not 'eql)))
    
    463
    -
    
    464
    -
    
    465 233
     (define-test subsetp.hash-eq
    
    466 234
         (:tag :issues)
    
    467 235
       (let ((lisp::*min-list-length-for-hashtable* 2))