tests/global.min
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 |
'min-test require :test ;;; "global" test.describe (2 'a define (3 a + (5 'a define a) -> +) -> a + 12 ==) test.assert (symbols "a" in? false ==) test.assert ('abcdefg defined-symbol? false ==) test.assert 5 :five (symbols "five" in?) test.assert ( (1 2 3 4 5 6) :test-data ( :item "_$1" (item) => % :namesym item (stack.dup *) stack.cons namesym define namesym global publish ) :def test-data def foreach _2 -> _5 -> _1 -> + + 30 == ) test.assert ( (stack.dup *) ^square 3 square 9 == ) test.assert 'five delete-symbol (symbols "five" in? false ==) test.assert ("3 4 +" eval 7 ==) test.assert ("2 2 +" "tests/testload.min" fs.write 'testload load 4 ==) test.assert "tests/testload.min" rm ("2 :two 3 :three" "tests/testrequire.min" fs.write 'testrequire require :tm tm.two tm.three + 5 ==) test.assert "tests/testrequire.min" rm (2 quote (2) ==) test.assert ((2 3) dequote stack.get (2 3) ==) test.assert (3 (succ) 3 times 6 ==) test.assert ((2 3 >) ("YES") ("NO") if "NO" ==) test.assert ((2 3 <) ("YES") ("NO") if "YES" ==) test.assert ("NO" (2 3 >) ("YES") when "NO" ==) test.assert ((2 3 <) ("YES") when "YES" ==) test.assert ((2 3 >) ("YES") unless "YES" ==) test.assert (1 type "int" ==) test.assert ({} type "dict" ==) test.assert (global type "dict:module" ==) test.assert (5 (stack.dup 0 ==) (1 +) (stack.dup 1 -) ( * ) linrec 120 ==) test.assert ;;factorial of 5 ( ( (stack.pop) ('error dget) ("finally") ) try stack.get ("MinEmptyStackError" "finally") ==) test.assert ("aaaa" :cd cd "aaaa" ==) test.assert ;;It is possible to shadow sealed symbols in child scopes (((2 :a1 'a1 seal-symbol 3 :a1) ("failed")) try "failed" ==) test.assert ( 1 :a1 'a1 seal-symbol 'a1 unseal-symbol 2 :a1 2 a1 ==) test.assert ( ( ({"TestError" :error "Test Message" :message} raise) ("error" dget) ) try "TestError" ==) test.assert ( (("test" °test :)) try stack.get ("test") ==) test.assert ( ( (() 1 get) (1) ) try 1 ==) test.assert ((a b +) {4 :a 5 :b} with 9 ==) test.assert ("{\"a\": 1, \"b\": 2.3}" from-json {1 :a 2.3 :b} ==) test.assert ((1 2 3 "aaa" 'q q true) to-json "\r\n" "" replace "\n" "" replace " " "" replace "[1,2,3,\"aaa\",\";sym:'q\",\";sym:q\",true]" ==) test.assert ((1 2 3 "aaa" 'q q true) to-json from-json (1 2 3 "aaa" 'q q true) ==) test.assert (((1 2 3)) :sym1 "sym1" save-symbol saved-symbols "sym1" in?) test.assert ("sym1" load-symbol symbols "sym1" in?) test.assert ('sym1 remove-symbol saved-symbols "sym1" in? false ==) test.assert (0 :temp (1 2 3) (temp + @temp) foreach 6 temp ==) test.assert ( (1 +) ^mysucc 'mysucc source (1 +) ==) test.assert (6 ( ((3 ==) (false)) ((3 <) (false)) ((3 >) (true)) ) case ) test.assert (time scope-symbols ("datetime" "now" "tformat" "timeinfo" "timestamp" "to-timestamp") ==) test.assert (global scope-sigils "$" in?) test.assert ({3 :a 5 :b} scope-symbols ("a" "b") ==) test.assert (dev?) ((opts {true :d} ==) test.assert) ((opts {} ==) test.assert) if (args first "\\.min$" match?) test.assert (3 string "3" ==) test.assert ("false" boolean false ==) test.assert ("" boolean false ==) test.assert (0 boolean false ==) test.assert (false boolean false ==) test.assert (0.0 boolean false ==) test.assert ("something" boolean true ==) test.assert ("345" integer 345 ==) test.assert (true integer 1 ==) test.assert (3.5 integer 3 ==) test.assert (3.5 float 3.5 ==) test.assert (3 float 3.0 ==) test.assert (false float 0.0 ==) test.assert ("3.678" float 3.678 ==) test.assert ( {1 :a 2 :b 3 :c} ( (stack.dup "a" dget succ succ "a" dset) (stack.dup "b" dget succ "b" dset) ) tap {3 :a 3 :b 3 :c} == ) test.assert ( {} :data data ( 1 "a" dset 2 "b" dset ) tap {1 :a 2 :b} == ) test.assert ( "" :s1 "test" ( (' "1" stack.swap append "" join) (' "2" stack.swap append "" join) (' "3" stack.swap append "" join @s1 s1) ) tap! s1 "test123" == ) test.assert (3.4 "test" 1 (int str num) expect (3.4 "test" 1) ==) test.assert ("aaa bbb ccc 2 2 + (2 3 4)" parse (aaa bbb ccc 2 2 + (2 3 4)) ==) test.assert ({} :myscope (2 :two 3 :three scope @myscope) -> myscope scope-symbols ("three" "two") ==) test.assert ((2 < 3 and (4 > 2)) >< true) test.assert ((float 3) >> 3.0 ==) test.assert ( ( sigil del (str :in ==> str :out) (in "--" suffix "--" prefix @out) ) :: del"test" "--test--" == ) test.assert ( ( sigil x (str :in ==> str :out) (in "x" prefix @out) ) :: 'x unseal-sigil 'x delete-sigil 'x defined-sigil? false == ) test.assert ( {{100 :b} :a} :test test.a.b 100 == ) test.assert ( ( symbol pow-mul (num :base int :exp ==> num :pr num :mr) ( exp 1 - :n base exp * @mr base (stack.dup) n times (*) n times @pr ) ) operator 2 4 pow-mul - 8 == ) test.assert ( ( sigil nt (str :s ==> bool :result) ( ("int" s ==) (true @result return) when ("num" s ==) (true @result return) when ("flt" s ==) (true @result return) when "not gonna be printed if true!" puts false @result ) ) :: nt"flt" ) test.assert ;; (:n ((n integer?) (n 0 >)) &&) 'natural typeclass ( typeclass natural (int :n ==> bool :out) (((n integer?) (n 0 >)) "&" run @out) ) :: ("typeclass:natural" defined-symbol?) test.assert ( symbol natural-sum (natural :n natural :m ==> natural :result) (n m + @result) ) :: (dev?) ( null :err ( (3 -3 natural-sum) (@err) ) try stack.pop ;;Remove 3 that was left on the stack. (err format-error "expected: natural natural natural-sum" match?) test.assert (2 3 natural-sum 5 ==) test.assert ) when ( constructor test-c (str :in ==> dict :out) ( {} in "test" dset @out ) ) :: ("aaa" test-c 'dict:test-c type?) test.assert ( symbol add ((str|num|quot :t) :a t :b ==> t :result) ( (a type "str" ==) (a b suffix @result return) when (a type "num" ==) (a b + @result return) when (a type "quot" ==) (a b concat @result return) when ) ) :: ("a" "b" add "ab" ==) test.assert ((1 2 3) (4 5) add (1 2 3 4 5) ==) test.assert (typeclass fiveplus (int :n ==> bool :o) ( n 5 > @o ) ) :: (typeclass tenminus (int :n ==> bool :o) ( n 10 < @o ) ) :: (typeclass even (int :n ==> bool :o) ( n 2 mod 0 == @o ) ) :: ( 'tenminus&fiveplus 'five-to-ten typealias (symbol test (!even|five-to-ten :n ==> bool :o) ( true @o ) ) :: 6 test 11 test and ) test.assert ( {{1 :aa} :a 2 :b} :test1 test1.b test1.a.aa + 3 == ) test.assert ( {} :obj 3 :obj.three 2 :obj.two (obj.three 6 <) ( obj.three 1 + @obj.three ) while obj.three 6 == ) test.assert ( {} :obj (stack.dup *) ^square 3 obj.square 9 == ) test.assert ;; Numeric operations (2 2 + 4 ==) test.assert (1 3.0 + 4 ==) test.assert (3.1 3.9 + 7 ==) test.assert (3 -2.1 + 0.8999999999999999 ==) test.assert (3 3 - 0 ==) test.assert (-5 -4 - -1 ==) test.assert (-4 3.7 - -7.7 ==) test.assert (-2 4 * -8 ==) test.assert (-2.5 -2 * 5 ==) test.assert (3 3 * 9 ==) test.assert (5 2 / 2.5 ==) test.assert (1 3 / 0.3333333333333333 ==) test.assert (-3 2 / -1.5 ==) test.assert (5 2 div 2 ==) test.assert (1 3 div 0 ==) test.assert (-3 2 div -1 ==) test.assert (5 2 mod 1 ==) test.assert (4 2 mod 0 ==) test.assert (-3 2 mod -1 ==) test.assert (1000 random 1000 <) test.assert ((1 2 3 4 5) sum 15 ==) test.assert ((1 2 3 4 5) product 120 ==) test.assert ((1 2 3 4 5) avg 3.0 ==) test.assert ((1 2 3 4 5 6) avg 3.5 ==) test.assert ((1 3 5 7) med 4.0 ==) test.assert ((1 3 5 7 9) med 5 ==) test.assert ((1 5) range (1 2 3 4 5) ==) test.assert ((5 1) range (5 4 3 2 1) ==) test.assert ((4 7) range (4 5 6 7) ==) test.assert ((7 4) range (7 6 5 4) ==) test.assert ((1 6 2) range (1 3 5) ==) test.assert ((1 6 3) range (1 4) ==) test.assert ((0 6 2) range (0 2 4 6) ==) test.assert ((6 1 2) range (6 4 2) ==) test.assert ((6 1 3) range (6 3) ==) test.assert ((6 0 2) range (6 4 2 0) ==) test.assert (2 3 bitand 2 ==) test.assert (123 bitnot -124 ==) test.assert (2 3 bitor 3 ==) test.assert (2 3 bitxor 1 ==) test.assert (2 3 shl 16 ==) test.assert (16 3 shr 2 ==) test.assert (0 :c (c 10 <) (c succ @c) while c 10 ==) test.assert ((1 2 3 4 5) (even?) filter (2 4) ==) test.assert ((1 2 3 4 5) (even?) any?) test.assert ((2 4 6 8) (even?) all?) test.assert (base? "dec" ==) test.assert ('bin base "bin" base? == 'dec base) test.assert (0b10010 18 ==) test.assert (0b101010 0b010101 bitand 0b000000 ==) test.assert (0b101010 0b010101 bitor 0b111111 ==) test.assert (0b101010 0b010101 bitxor 0b111111 ==) test.assert (0b111000 (0 2) bitflip 0b111101 ==) test.assert (0b111001 (0) bitclear 0b111000 ==) test.assert (0b111000 (0 1) bitset 0b111011 ==) test.assert (0b111000 bitparity 1 ==) test.assert ;; Logic operations (2 3 <) test.assert (3 2 < false ==) test.assert (3 3 < false ==) test.assert (2.99 3 <) test.assert (2 1.99 < false ==) test.assert (1.99 1.991 <) test.assert (1.99 1.990 < false ==) test.assert ("test1" "test2" <) test.assert ("test3" "test2" < false ==) test.assert ("test2" "test2" < false ==) test.assert (2 3 <=) test.assert (3 2 <= false ==) test.assert (3 3 <=) test.assert (2.99 3 <=) test.assert (2 1.99 <= false ==) test.assert (1.99 1.991 <=) test.assert (1.99 1.990 <=) test.assert ("test1" "test2" <=) test.assert ("test3" "test2" <= false ==) test.assert ("test2" "test2" <=) test.assert (2 3 > false ==) test.assert (3 2 >) test.assert (3 3 > false ==) test.assert (2.99 3 > false ==) test.assert (2 1.99 >) test.assert (1.99 1.991 > false ==) test.assert (1.99 1.990 > false ==) test.assert ("test1" "test2" > false ==) test.assert ("test3" "test2" >) test.assert ("test2" "test2" > false ==) test.assert (2 3 >= false ==) test.assert (3 2 >=) test.assert (3 3 >=) test.assert (2.99 3 >= false ==) test.assert (2 1.99 >=) test.assert (1.99 1.991 >= false ==) test.assert (1.99 1.990 >=) test.assert ("test1" "test2" >= false ==) test.assert ("test3" "test2" >=) test.assert ("test2" "test2" >=) test.assert (true true ==) test.assert (false true == false ==) test.assert (true false == false ==) test.assert (false false ==) test.assert (1 1 ==) test.assert ("aaa" "aaa" ==) test.assert (1.0 1 ==) test.assert ((1 2 3.0) (1.0 2 3) ==) test.assert (("a" "b") ("a" "b") ==) test.assert (("a" "b" 3) ("a" "b" 4) == false ==) test.assert ((1 "b" 3 myrandomsymbol) (1 "b" 3.0 myrandomsymbol) ==) test.assert (true true != false ==) test.assert (false true !=) test.assert (true false !=) test.assert (false false != false ==) test.assert (1 1 != false ==) test.assert ("aaa" "aaa" != false ==) test.assert ;;(1.0 1 != false ==) *test/assert ;;((1 2 3.0) (1.0 2.0 3) != false ==) *test/assert ;;(("a" "b") ("a" "b") != false ==) *test/assert (("a" "b" 3) ("a" "b" 4) !=) test.assert ((1 "b" 3 myrandomsymbol) (1 "b" 3.0 myrandomsymbol) != false ==) test.assert (false not) test.assert (true not false ==) test.assert (true true and) test.assert (true false and false ==) test.assert (false true and false ==) test.assert (false false and false ==) test.assert (true true or) test.assert (true false or) test.assert (false true or) test.assert (false false or false ==) test.assert (true true xor false ==) test.assert (true false xor) test.assert (false true xor) test.assert (false false xor false ==) test.assert ("a" string?) test.assert (1 string? false ==) test.assert (1.0 string? false ==) test.assert (true string? false ==) test.assert (false string? false ==) test.assert (("a" 2 c) string? false ==) test.assert ("a" integer? false ==) test.assert (1 integer?) test.assert (1.0 integer? false ==) test.assert (true integer? false ==) test.assert (false integer? false ==) test.assert (("a" 2 c) integer? false ==) test.assert ("a" float? false ==) test.assert (1 float? false ==) test.assert (1.0 float?) test.assert (true float? false ==) test.assert (false float? false ==) test.assert (("a" 2 c) float? false ==) test.assert ("a" boolean? false ==) test.assert (1 boolean? false ==) test.assert (1.0 boolean? false ==) test.assert (true boolean?) test.assert (false boolean?) test.assert (("a" 2 c) boolean? false ==) test.assert ("a" number? false ==) test.assert (1 number?) test.assert (1.0 number?) test.assert (true number? false ==) test.assert (false number? false ==) test.assert (("a" 2 c) number? false ==) test.assert ("a" quotation? false ==) test.assert (1 quotation? false ==) test.assert (1.0 quotation? false ==) test.assert (true quotation? false ==) test.assert (false quotation? false ==) test.assert (("a" 2 c) quotation?) test.assert ("a" stringlike?) test.assert (1 stringlike? false ==) test.assert ('test stringlike?) test.assert (("a") quoted-symbol? not) test.assert ('test quoted-symbol?) test.assert ((aaa bbb) quoted-symbol? not) test.assert ({} 'dict:module type? false ==) test.assert ((1 2 3) 'dict:module type? false ==) test.assert (4 'dict:module type? false ==) test.assert (global 'dict:module type?) test.assert (1 "int" type?) test.assert ("test" "str" type?) test.assert (global "dict:module" type?) test.assert (7 0 / inf ==) test.assert (-7 0 / -inf ==) test.assert (0 0 / nan ==) test.assert (10 3 / 3.33333 ==) test.assert (3 "a" == not) test.assert (1 () != true) test.assert (3.3 'test == not) test.assert ( ( (true) (2 1 >) ("a" "b" ==) ("never printed" puts!) ) && false == ) test.assert ( ( (false) (2 1 <) ("a" "a" ==) ("never printed" puts!) ) || ) test.assert ;; String operations ("$1 - $2 - $3" (1 true "test") interpolate "1 - true - test" ==) test.assert ("$1 + $2 = $3" (2 2 (2 2 +)) apply interpolate "2 + 2 = 4" ==) test.assert (" test " strip "test" ==) test.assert ("test" length 4 ==) test.assert ("a,b,c" "," split ("a" "b" "c") ==) test.assert ("abc" "" split ("a" "b" "c") ==) test.assert ("This is a test" 5 2 substr "is" ==) test.assert ("this" 2 3 substr "is" ==) test.assert ("This is a test" "is" indexof 2 ==) test.assert ("test #1" "[0-9]" search ("1") ==) test.assert ("a" ord 97 ==) test.assert (97 chr "a" ==) test.assert ("This is test #1" "test #([0-9])" search ("test #1" "1") ==) test.assert ("This is a random string" "random" match?) test.assert ("something is not something else" "some" "any" replace "anything is not anything else" ==) test.assert ("MiN is a concatenative programming language" "(?i)^min" search ("MiN") ==) test.assert ("This is a difficult test" "difficult" "simple" replace "This is a simple test" ==) test.assert ("This is a DIFFICULT\n test" "(?mi)difficult" "simple" replace "This is a simple\n test" ==) test.assert ("This is again another test" "(again|still|yet)" (1 get :m "_$#_" (m) =%) replace-apply "This is _again_ another test" ==) test.assert ("/api/items/test-1" "\\/api\\/items\\/(.+)" search 1 get "test-1" ==) test.assert ("this is a test" uppercase "THIS IS A TEST" ==) test.assert ("THIS IS A TEST" lowercase "this is a test" ==) test.assert ("test" capitalize "Test" ==) test.assert ("this is a test" titleize "This Is A Test" ==) test.assert ("+" 3 repeat "+++" ==) test.assert ("test" 4 indent " test" ==) test.assert ((1 3 "test") ", " join "1, 3, test" ==) test.assert ("PWD: $pwd" ("pwd" pwd) =% ("PWD: " pwd) => "" join ==) test.assert ("1.2.3" from-semver {1 :major 2 :minor 3 :patch} ==) test.assert ({2 :major 25 :minor 300 :patch} to-semver "2.25.300" ==) test.assert ("2.3.6" semver-inc-major "3.0.0" ==) test.assert ("2.3.6" semver-inc-minor "2.4.0" ==) test.assert ("2.3.6" semver-inc-patch "2.3.7" ==) test.assert ("4.6.5" semver? true ==) test.assert ("4.6.5.3" semver? false ==) test.assert ("fix" "pre" prefix "prefix" ==) test.assert ("suf" "fix" suffix "suffix" ==) test.assert ("http://test.com?€%,,!{}" encode-url "http%3A%2F%2Ftest.com%3F%E2%82%AC%25%2C%2C%21%7B%7D" ==) test.assert ("http%3A%2F%2Ftest.com%3F%E2%82%AC%25%2C%2C%21%7B%7D" decode-url "http://test.com?€%,,!{}" ==) test.assert ("http://h3rald.com/a/b/c?test=1#123" parse-url {"123" :anchor "h3rald.com" :hostname "" :password "/a/b/c" :path "" :port "test=1" :query "http" :scheme "" :username} ==) test.assert ("0b00101101" stack.dup from-bin to-bin ==) test.assert ("0x00FF0000" stack.dup from-hex to-hex ==) test.assert ("0o00007473" stack.dup from-oct to-oct ==) test.assert ("123" stack.dup from-dec to-dec ==) test.assert ;; Sequence operations ((1 2) (3 4) concat (1 2 3 4) ==) test.assert ((1 2 3) first 1 ==) test.assert ((1 2 3) last 3 ==) test.assert ((1 2 3) rest (2 3) ==) test.assert (4 (1 2 3) append (1 2 3 4) ==) test.assert (0 (1 2 3) prepend (0 1 2 3) ==) test.assert ((1 2 3 4) 2 get 3 ==) test.assert ((a b c) 1 get-raw "type" dget "sym" ==) test.assert ((1 2 3 4) 222 2 set (1 2 222 4) ==) test.assert ((1 2 3) "test" 1 set-sym (1 test 3) ==) test.assert ((1 2 3 4) 2 remove (1 2 4) ==) test.assert ((1 2 3 4) 333 2 insert (1 2 333 3 4) ==) test.assert ((1 2 3) size 3 ==) test.assert ((1 2 3 4) 5 in? false ==) test.assert ((1 2 3 4) 2 in?) test.assert ((1 2 3 4) (2 +) map (3 4 5 6) ==) test.assert ((5 4 3 2 1) reverse (1 2 3 4 5) ==) test.assert ((3 4 7 2 4 6 5 6) '> sort (2 3 4 4 5 6 6 7) ==) test.assert ((3 4 7 2 4 6 5 6) '< sort (7 6 6 5 4 4 3 2) ==) test.assert ((1 2 3 4 5) 3 shorten (1 2 3) ==) test.assert ((1 2 3 4 5) 3 take (1 2 3) ==) test.assert ((1 2 3 4 5) 6 take (1 2 3 4 5) ==) test.assert ((1 2 3 4 5) 3 drop (4 5) ==) test.assert ((1 2 3 4 5) 6 drop () ==) test.assert ((1 2 3 4 5) (2 >) find 2 ==) test.assert ((1 2 3 4 5) 1 (*) reduce 120 ==) test.assert ((1 3 5) (stack.dup *) (+) map-reduce 35 ==) test.assert ((1 2 3 4 5 6) (odd?) partition stack.get ((1 3 5) (2 4 6)) ==) test.assert ((1 2 3 4 5 6) (odd?) reject (2 4 6) ==) test.assert ((1 2 3 4 5 6) 2 4 slice (3 4 5) ==) test.assert ((2 3 () 4 (3 4) () () "test") harvest (2 3 4 (3 4) "test") ==) test.assert ((1 2 3 (4 5 6) 7 (8 9)) flatten (1 2 3 4 5 6 7 8 9) ==) test.assert ((2 3 + 4 *) quote-map ('+ ==) find 2 ==) test.assert ((2 4 6 8) 'even? all?) test.assert ((2 4 3 6 8) 'even? all? not) test.assert ((1 2 3 4) 'odd? one? not) test.assert ((1 2 4) 'odd? one?) test.assert ((1 2 3 4) 'odd? any?) test.assert ((2 4 6 8) 'odd? any? not) test.assert ((1 2 "test") ("test" "a" true 1) intersection (1 "test") ==) test.assert ((1 2 "test") ("test" "a" true 1) union (true 1 "test" "a" 2) ==) test.assert ((1 2 "test") ("test" "a" true 1) difference (2) ==) test.assert ((1 2 "test") ("test" "a" true 1) symmetric-difference (true "a" 2) ==) test.assert test.report ;; Tidy up stack.clear |