From 7eadad03ec5aee7efda69f5fa276a1f60d04f7d6 Mon Sep 17 00:00:00 2001 From: Marcel Garus Date: Fri, 27 Oct 2023 14:38:58 +0200 Subject: [PATCH] Comment out all the tests from Core --- packages/Core/bool.candy | 64 ++++----- packages/Core/controlFlow.candy | 16 +-- packages/Core/equality.candy | 72 +++++----- packages/Core/function.candy | 26 ++-- packages/Core/int.candy | 242 ++++++++++++++++---------------- packages/Core/iterable.candy | 62 ++++---- packages/Core/list.candy | 142 +++++++++---------- packages/Core/result.candy | 124 ++++++++-------- packages/Core/struct.candy | 28 ++-- packages/Core/tag.candy | 32 ++--- packages/Core/text.candy | 38 ++--- packages/Core/toDebugText.candy | 20 +-- packages/Core/type.candy | 18 +-- 13 files changed, 442 insertions(+), 442 deletions(-) diff --git a/packages/Core/bool.candy b/packages/Core/bool.candy index c603bdc1d..9cccdd25e 100644 --- a/packages/Core/bool.candy +++ b/packages/Core/bool.candy @@ -50,35 +50,35 @@ implies a b := needs (is b) a | not | or b -test = - [checkEquals] = use "..check" - - checkEquals (is True) True - checkEquals (is False) True - checkEquals (is 3) False - - checkEquals (not True) False - checkEquals (not False) True - - ## `lazyAnd` and `lazyOr` are automatically tested by the tests for the - ## non-lazy variants. - - checkEquals (True | and True) True - checkEquals (True | and False) False - checkEquals (False | and True) False - checkEquals (False | and False) False - - checkEquals (True | or True) True - checkEquals (True | or False) True - checkEquals (False | or True) True - checkEquals (False | or False) False - - checkEquals (True | xor True) False - checkEquals (True | xor False) True - checkEquals (False | xor True) True - checkEquals (False | xor False) False - - checkEquals (True | implies True) True - checkEquals (True | implies False) False - checkEquals (False | implies True) True - checkEquals (False | implies False) True +#test = +# [checkEquals] = use "..check" +# +# checkEquals (is True) True +# checkEquals (is False) True +# checkEquals (is 3) False +# +# checkEquals (not True) False +# checkEquals (not False) True +# +# ## `lazyAnd` and `lazyOr` are automatically tested by the tests for the +# ## non-lazy variants. +# +# checkEquals (True | and True) True +# checkEquals (True | and False) False +# checkEquals (False | and True) False +# checkEquals (False | and False) False +# +# checkEquals (True | or True) True +# checkEquals (True | or False) True +# checkEquals (False | or True) True +# checkEquals (False | or False) False +# +# checkEquals (True | xor True) False +# checkEquals (True | xor False) True +# checkEquals (False | xor True) True +# checkEquals (False | xor False) False +# +# checkEquals (True | implies True) True +# checkEquals (True | implies False) False +# checkEquals (False | implies True) True +# checkEquals (False | implies False) True diff --git a/packages/Core/controlFlow.candy b/packages/Core/controlFlow.candy index 0e66ddda3..ab506feb6 100644 --- a/packages/Core/controlFlow.candy +++ b/packages/Core/controlFlow.candy @@ -44,11 +44,11 @@ repeat times body := } } -test = - [checkEquals] = use "..check" - - checkEquals (ifElse True { Then } { Else }) Then - checkEquals (ifElse False { Then } { Else }) Else - - checkEquals (if True { Then }) Then - checkEquals (if False { Then }) Nothing +#test = +# [checkEquals] = use "..check" +# +# checkEquals (ifElse True { Then } { Else }) Then +# checkEquals (ifElse False { Then } { Else }) Else +# +# checkEquals (if True { Then }) Then +# checkEquals (if False { Then }) Nothing diff --git a/packages/Core/equality.candy b/packages/Core/equality.candy index 4254ad711..0cb148695 100644 --- a/packages/Core/equality.candy +++ b/packages/Core/equality.candy @@ -2,39 +2,39 @@ builtins = use "Builtins" equals := builtins.equals -test = - [checkEquals] = use "..check" - - checkEquals (equals 2 Foo) False - - ## numbers - checkEquals (equals 5 5) True - checkEquals (equals 3 5) False - - ## text - checkEquals (equals "Hey" "Hey") True - checkEquals (equals "A" "B") False - - ## tags - checkEquals (equals Kiwi Kiwi) True - checkEquals (equals Kiwi Banana) False - checkEquals (equals Kiwi (Kiwi 3)) False - checkEquals (equals (Kiwi 3) (Kiwi 3)) True - checkEquals (equals (Kiwi 5) (Kiwi 3)) False - - ## functions - foo = { a -> 4 } - checkEquals (equals foo foo) True - ## TODO: Currently, this is not implemented correctly in the VM. - # checkEquals (equals foo { a -> 4 }) False - - ## lists - checkEquals (equals (1, 2, 3) (1, 2, 3)) True - checkEquals (equals (1, 2, 3) (1, 2)) False - checkEquals (equals (1, 2, 3) (1, 2, 30)) False - - ## structs - checkEquals (equals [Foo: 2] [Foo: 2]) True - checkEquals (equals [Foo: 2] [Bar: 2]) False - checkEquals (equals [Foo: 2] []) False - checkEquals (equals [Foo: 2] [Foo: 3]) False +#test = +# [checkEquals] = use "..check" +# +# checkEquals (equals 2 Foo) False +# +# ## numbers +# checkEquals (equals 5 5) True +# checkEquals (equals 3 5) False +# +# ## text +# checkEquals (equals "Hey" "Hey") True +# checkEquals (equals "A" "B") False +# +# ## tags +# checkEquals (equals Kiwi Kiwi) True +# checkEquals (equals Kiwi Banana) False +# checkEquals (equals Kiwi (Kiwi 3)) False +# checkEquals (equals (Kiwi 3) (Kiwi 3)) True +# checkEquals (equals (Kiwi 5) (Kiwi 3)) False +# +# ## functions +# foo = { a -> 4 } +# checkEquals (equals foo foo) True +# ## TODO: Currently, this is not implemented correctly in the VM. +# # checkEquals (equals foo { a -> 4 }) False +# +# ## lists +# checkEquals (equals (1, 2, 3) (1, 2, 3)) True +# checkEquals (equals (1, 2, 3) (1, 2)) False +# checkEquals (equals (1, 2, 3) (1, 2, 30)) False +# +# ## structs +# checkEquals (equals [Foo: 2] [Foo: 2]) True +# checkEquals (equals [Foo: 2] [Bar: 2]) False +# checkEquals (equals [Foo: 2] []) False +# checkEquals (equals [Foo: 2] [Foo: 3]) False diff --git a/packages/Core/function.candy b/packages/Core/function.candy index 52294f071..1be630082 100644 --- a/packages/Core/function.candy +++ b/packages/Core/function.candy @@ -39,16 +39,16 @@ doNotRun body := # errors. needs (is0 body) -test = - [checkEquals] = use "..check" - - checkEquals (is {}) True - checkEquals (is 4) False - checkEquals (getArgumentCount {}) 0 - checkEquals (getArgumentCount { a -> }) 1 - - checkEquals (is0 {}) True - checkEquals (is0 { a -> }) False - - checkEquals (run { 4 }) 4 - checkEquals (doNotRun { 4 }) Nothing +#test = +# [checkEquals] = use "..check" +# +# checkEquals (is {}) True +# checkEquals (is 4) False +# checkEquals (getArgumentCount {}) 0 +# checkEquals (getArgumentCount { a -> }) 1 +# +# checkEquals (is0 {}) True +# checkEquals (is0 { a -> }) False +# +# checkEquals (run { 4 }) 4 +# checkEquals (doNotRun { 4 }) Nothing diff --git a/packages/Core/int.candy b/packages/Core/int.candy index edf0e9bbe..b97a85d47 100644 --- a/packages/Core/int.candy +++ b/packages/Core/int.candy @@ -139,124 +139,124 @@ pow base exponent := } } -test = - [checkEquals] = use "..check" - - checkEquals (is 2) True - checkEquals (is Foo) False - - checkEquals (2 | add 3) 5 - checkEquals (4 | subtract 1) 3 - checkEquals (2 | multiply 3) 6 - checkEquals (7 | divideTruncating 4) 1 - - checkEquals (6 | remainder 3) 0 - checkEquals (5 | remainder 3) 2 - checkEquals ((negate 5) | remainder 3) (negate 2) - checkEquals (5 | remainder (negate 3)) 2 - checkEquals ((negate 5) | remainder (negate 3)) (negate 2) - - checkEquals (6 | modulo 3) 0 - checkEquals (5 | modulo 3) 2 - checkEquals (5 | modulo (negate 3)) 2 - checkEquals ((negate 5) | modulo 3) 1 - checkEquals ((negate 5) | modulo (negate 3)) 1 - - checkEquals (6 | compareTo 3) Greater - checkEquals (6 | compareTo 6) Equal - checkEquals (6 | compareTo 9) Less - - checkEquals (1 | isLessThan 2) True - checkEquals (2 | isLessThan 2) False - checkEquals (2 | isLessThan 1) False - - checkEquals (1 | isGreaterThan 2) False - checkEquals (2 | isGreaterThan 2) False - checkEquals (2 | isGreaterThan 1) True - - checkEquals (1 | isLessThanOrEqualTo 2) True - checkEquals (2 | isLessThanOrEqualTo 2) True - checkEquals (2 | isLessThanOrEqualTo 1) False - - checkEquals (1 | isGreaterThanOrEqualTo 2) False - checkEquals (2 | isGreaterThanOrEqualTo 2) True - checkEquals (2 | isGreaterThanOrEqualTo 1) True - - checkEquals (isPositive 1) True - checkEquals (isPositive 0) False - checkEquals (isPositive (negate 1)) False - - checkEquals (isNonPositive 1) False - checkEquals (isNonPositive 0) True - checkEquals (isNonPositive (negate 1)) True - - checkEquals (isNegative 1) False - checkEquals (isNegative 0) False - checkEquals (isNegative (negate 1)) True - - checkEquals (isNonNegative 1) True - checkEquals (isNonNegative 0) True - checkEquals (isNonNegative (negate 1)) False - - checkEquals (absolute 3) 3 - checkEquals (absolute 0) 0 - checkEquals (absolute (negate 3)) 3 - - checkEquals (1 | shiftLeft 2) 4 - checkEquals (3 | shiftLeft 1) 6 - - checkEquals (5 | shiftRight 2) 1 - checkEquals (10 | shiftRight 1) 5 - - checkEquals (bitLength 0) 0 - checkEquals (bitLength 1) 1 - checkEquals (bitLength 3) 2 - checkEquals (bitLength 10) 4 - - checkEquals (0b10 | bitwiseAnd 0b10) 0b10 - checkEquals (0b10 | bitwiseAnd 0b1) 0 - checkEquals (0b11 | bitwiseAnd 0b110) 0b10 - - checkEquals (0b10 | bitwiseOr 0b10) 0b10 - checkEquals (0b10 | bitwiseOr 0b1) 0b11 - checkEquals (0b11 | bitwiseOr 0b110) 0b111 - - checkEquals (0b10 | bitwiseXor 0b10) 0 - checkEquals (0b10 | bitwiseXor 0b1) 0b11 - checkEquals (0b11 | bitwiseXor 0b110) 0b101 - - checkEquals (isEven 0) True - checkEquals (isEven 1) False - checkEquals (isEven 2) True - checkEquals (isEven 3) False - checkEquals (isEven (negate 3)) False - - checkEquals (isOdd 0) False - checkEquals (isOdd 1) True - checkEquals (isOdd 2) False - checkEquals (isOdd 3) True - checkEquals (isOdd (negate 3)) True - - checkEquals (min 3 1) 1 - checkEquals (min 1 2) 1 - - checkEquals (max 3 1) 3 - checkEquals (max 1 2) 2 - - checkEquals (2 | coerceAtLeast 1) 2 - checkEquals (2 | coerceAtLeast 3) 3 - - checkEquals (2 | coerceAtMost 1) 1 - checkEquals (2 | coerceAtMost 3) 2 - - checkEquals (1 | coerceIn 2 4) 2 - checkEquals (3 | coerceIn 2 4) 3 - checkEquals (5 | coerceIn 2 4) 4 - - checkEquals (parse "123") (Ok 123) - # TODO: Currently, `parse` returns a different error. - #checkEquals (parse "Hi") (Error NotAnInteger) - - checkEquals (3 | pow 2) 9 - checkEquals (2 | pow 3) 8 - checkEquals (9 | pow 1) 9 +#test = +# [checkEquals] = use "..check" +# +# checkEquals (is 2) True +# checkEquals (is Foo) False +# +# checkEquals (2 | add 3) 5 +# checkEquals (4 | subtract 1) 3 +# checkEquals (2 | multiply 3) 6 +# checkEquals (7 | divideTruncating 4) 1 +# +# checkEquals (6 | remainder 3) 0 +# checkEquals (5 | remainder 3) 2 +# checkEquals ((negate 5) | remainder 3) (negate 2) +# checkEquals (5 | remainder (negate 3)) 2 +# checkEquals ((negate 5) | remainder (negate 3)) (negate 2) +# +# checkEquals (6 | modulo 3) 0 +# checkEquals (5 | modulo 3) 2 +# checkEquals (5 | modulo (negate 3)) 2 +# checkEquals ((negate 5) | modulo 3) 1 +# checkEquals ((negate 5) | modulo (negate 3)) 1 +# +# checkEquals (6 | compareTo 3) Greater +# checkEquals (6 | compareTo 6) Equal +# checkEquals (6 | compareTo 9) Less +# +# checkEquals (1 | isLessThan 2) True +# checkEquals (2 | isLessThan 2) False +# checkEquals (2 | isLessThan 1) False +# +# checkEquals (1 | isGreaterThan 2) False +# checkEquals (2 | isGreaterThan 2) False +# checkEquals (2 | isGreaterThan 1) True +# +# checkEquals (1 | isLessThanOrEqualTo 2) True +# checkEquals (2 | isLessThanOrEqualTo 2) True +# checkEquals (2 | isLessThanOrEqualTo 1) False +# +# checkEquals (1 | isGreaterThanOrEqualTo 2) False +# checkEquals (2 | isGreaterThanOrEqualTo 2) True +# checkEquals (2 | isGreaterThanOrEqualTo 1) True +# +# checkEquals (isPositive 1) True +# checkEquals (isPositive 0) False +# checkEquals (isPositive (negate 1)) False +# +# checkEquals (isNonPositive 1) False +# checkEquals (isNonPositive 0) True +# checkEquals (isNonPositive (negate 1)) True +# +# checkEquals (isNegative 1) False +# checkEquals (isNegative 0) False +# checkEquals (isNegative (negate 1)) True +# +# checkEquals (isNonNegative 1) True +# checkEquals (isNonNegative 0) True +# checkEquals (isNonNegative (negate 1)) False +# +# checkEquals (absolute 3) 3 +# checkEquals (absolute 0) 0 +# checkEquals (absolute (negate 3)) 3 +# +# checkEquals (1 | shiftLeft 2) 4 +# checkEquals (3 | shiftLeft 1) 6 +# +# checkEquals (5 | shiftRight 2) 1 +# checkEquals (10 | shiftRight 1) 5 +# +# checkEquals (bitLength 0) 0 +# checkEquals (bitLength 1) 1 +# checkEquals (bitLength 3) 2 +# checkEquals (bitLength 10) 4 +# +# checkEquals (0b10 | bitwiseAnd 0b10) 0b10 +# checkEquals (0b10 | bitwiseAnd 0b1) 0 +# checkEquals (0b11 | bitwiseAnd 0b110) 0b10 +# +# checkEquals (0b10 | bitwiseOr 0b10) 0b10 +# checkEquals (0b10 | bitwiseOr 0b1) 0b11 +# checkEquals (0b11 | bitwiseOr 0b110) 0b111 +# +# checkEquals (0b10 | bitwiseXor 0b10) 0 +# checkEquals (0b10 | bitwiseXor 0b1) 0b11 +# checkEquals (0b11 | bitwiseXor 0b110) 0b101 +# +# checkEquals (isEven 0) True +# checkEquals (isEven 1) False +# checkEquals (isEven 2) True +# checkEquals (isEven 3) False +# checkEquals (isEven (negate 3)) False +# +# checkEquals (isOdd 0) False +# checkEquals (isOdd 1) True +# checkEquals (isOdd 2) False +# checkEquals (isOdd 3) True +# checkEquals (isOdd (negate 3)) True +# +# checkEquals (min 3 1) 1 +# checkEquals (min 1 2) 1 +# +# checkEquals (max 3 1) 3 +# checkEquals (max 1 2) 2 +# +# checkEquals (2 | coerceAtLeast 1) 2 +# checkEquals (2 | coerceAtLeast 3) 3 +# +# checkEquals (2 | coerceAtMost 1) 1 +# checkEquals (2 | coerceAtMost 3) 2 +# +# checkEquals (1 | coerceIn 2 4) 2 +# checkEquals (3 | coerceIn 2 4) 3 +# checkEquals (5 | coerceIn 2 4) 4 +# +# checkEquals (parse "123") (Ok 123) +# # TODO: Currently, `parse` returns a different error. +# #checkEquals (parse "Hi") (Error NotAnInteger) +# +# checkEquals (3 | pow 2) 9 +# checkEquals (2 | pow 3) 8 +# checkEquals (9 | pow 1) 9 diff --git a/packages/Core/iterable.candy b/packages/Core/iterable.candy index ea76eeaee..63bca3d01 100644 --- a/packages/Core/iterable.candy +++ b/packages/Core/iterable.candy @@ -236,34 +236,34 @@ chunked iterable size := iterable | windowed size size True -test = - [checkEquals] = use "..check" - [toDebugText] = use "..toDebugText" - - oneToThree = (1, 2, 3) | fromList - oneToTen = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) | fromList - - checkEquals (is oneToThree) True - checkEquals (is 3) False - - testNext = - Ok [item, rest] = oneToThree | next - checkEquals item 1 - Ok [item, rest] = rest | next - checkEquals item 2 - - checkEquals (isEmpty oneToThree) False - checkEquals (isEmpty (fromList (,))) True - - checkEquals (oneToThree | map { a -> int.multiply a 2 } | toList) (2, 4, 6) - checkEquals (oneToThree | sum) 6 - checkEquals (oneToThree | length) 3 - checkEquals (oneToThree | all { a -> int.isPositive a }) True - checkEquals (oneToThree | any { a -> equals a 2 }) True - checkEquals (oneToThree | map { a -> a | toDebugText } | joinToText) "123" - checkEquals (oneToTen | where { a -> a | int.isOdd } | toList) (1, 3, 5, 7, 9) - checkEquals (oneToTen | takeWhile { a -> a | int.isLessThan 4 } | toList) (1, 2, 3) - checkEquals (oneToTen | take 4 | toList) (1, 2, 3, 4) - checkEquals (oneToTen | skip 4 | toList) (5, 6, 7, 8, 9, 10) - checkEquals (oneToTen | windowed 4 3 False | toList) ((1, 2, 3, 4), (4, 5, 6, 7), (7, 8, 9, 10)) - checkEquals (oneToTen | chunked 3 | toList) ((1, 2, 3), (4, 5, 6), (7, 8, 9), (10,)) +#test = +# [checkEquals] = use "..check" +# [toDebugText] = use "..toDebugText" +# +# oneToThree = (1, 2, 3) | fromList +# oneToTen = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) | fromList +# +# checkEquals (is oneToThree) True +# checkEquals (is 3) False +# +# testNext = +# Ok [item, rest] = oneToThree | next +# checkEquals item 1 +# Ok [item, rest] = rest | next +# checkEquals item 2 +# +# checkEquals (isEmpty oneToThree) False +# checkEquals (isEmpty (fromList (,))) True +# +# checkEquals (oneToThree | map { a -> int.multiply a 2 } | toList) (2, 4, 6) +# checkEquals (oneToThree | sum) 6 +# checkEquals (oneToThree | length) 3 +# checkEquals (oneToThree | all { a -> int.isPositive a }) True +# checkEquals (oneToThree | any { a -> equals a 2 }) True +# checkEquals (oneToThree | map { a -> a | toDebugText } | joinToText) "123" +# checkEquals (oneToTen | where { a -> a | int.isOdd } | toList) (1, 3, 5, 7, 9) +# checkEquals (oneToTen | takeWhile { a -> a | int.isLessThan 4 } | toList) (1, 2, 3) +# checkEquals (oneToTen | take 4 | toList) (1, 2, 3, 4) +# checkEquals (oneToTen | skip 4 | toList) (5, 6, 7, 8, 9, 10) +# checkEquals (oneToTen | windowed 4 3 False | toList) ((1, 2, 3, 4), (4, 5, 6, 7), (7, 8, 9, 10)) +# checkEquals (oneToTen | chunked 3 | toList) ((1, 2, 3), (4, 5, 6), (7, 8, 9), (10,)) diff --git a/packages/Core/list.candy b/packages/Core/list.candy index 70efb17e9..929e6d9da 100644 --- a/packages/Core/list.candy +++ b/packages/Core/list.candy @@ -109,74 +109,74 @@ concatenate listA listB := } } -test = - [checkEquals] = use "..check" - - checkEquals (is (1, 2, 3)) True - checkEquals (is Hello) False - - checkEquals (length (1, 2, 3)) 3 - checkEquals (length (3, 3)) 2 - - checkEquals (isEmpty (,)) True - - checkEquals (lastIndex (1, 2, 3)) (Ok 2) - checkEquals (lastIndex (3, 3)) (Ok 1) - checkEquals (lastIndex (,)) (Error Empty) - - checkEquals ((1, 2, 3) | isValidIndex (int.negate 1)) False - checkEquals ((1, 2, 3) | isValidIndex 0) True - checkEquals ((1, 2, 3) | isValidIndex 1) True - checkEquals ((1, 2, 3) | isValidIndex 2) True - checkEquals ((1, 2, 3) | isValidIndex 3) False - checkEquals ((1, 2, 3) | isValidIndex 4) False - checkEquals ((1, 2, 3) | isValidIndex 100) False - - checkEquals ((1, 2, 3) | isValidInsertIndex (int.negate 1)) False - checkEquals ((1, 2, 3) | isValidInsertIndex 0) True - checkEquals ((1, 2, 3) | isValidInsertIndex 1) True - checkEquals ((1, 2, 3) | isValidInsertIndex 2) True - checkEquals ((1, 2, 3) | isValidInsertIndex 3) True - checkEquals ((1, 2, 3) | isValidInsertIndex 4) False - checkEquals ((1, 2, 3) | isValidInsertIndex 100) False - - checkEquals ((Foo, Bar, Baz) | get 0) Foo - checkEquals ((Foo, Bar, Baz) | get 1) Bar - checkEquals ((Foo, Bar, Baz) | get 2) Baz - - checkEquals (single (,)) (Error Empty) - checkEquals (single (Foo,)) (Ok Foo) - checkEquals (single (Foo, Bar)) (Error MoreThanOneItem) - - checkEquals (first (,)) (Error Empty) - checkEquals (first (Foo,)) (Ok Foo) - checkEquals (first (Foo, Bar)) (Ok Foo) - - checkEquals (last (,)) (Error Empty) - checkEquals (last (Foo,)) (Ok Foo) - checkEquals (last (Foo, Bar)) (Ok Bar) - - checkEquals ((Foo, Bar) | insert 0 Baz) (Baz, Foo, Bar) - checkEquals ((Foo, Bar) | insert 1 Baz) (Foo, Baz, Bar) - checkEquals ((Foo, Bar) | insert 2 Baz) (Foo, Bar, Baz) - - checkEquals ((Foo, Bar) | prepend Baz) (Baz, Foo, Bar) - - checkEquals ((Foo, Bar) | append Baz) (Foo, Bar, Baz) - - checkEquals ((Foo, Bar) | replace 0 Baz) (Baz, Bar) - checkEquals ((Foo, Bar) | replace 1 Baz) (Foo, Baz) - - checkEquals ((1, 2) | update 0 { a -> int.add a 1 }) (2, 2) - - checkEquals ((Foo, Bar) | removeAt 0) (Bar,) - checkEquals ((Foo, Bar) | removeAt 1) (Foo,) - - checkEquals (filled 2 Foo) (Foo, Foo) - checkEquals (filled 10 1) (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) - - checkEquals (generate 5 { a -> a }) (0, 1, 2, 3, 4) - - checkEquals ((1, 2, 3, 4, 5) | getRange 1 4) (2, 3, 4) - - checkEquals (concatenate (1, 2, 3) (4, 5)) (1, 2, 3, 4, 5) +#test = +# [checkEquals] = use "..check" +# +# checkEquals (is (1, 2, 3)) True +# checkEquals (is Hello) False +# +# checkEquals (length (1, 2, 3)) 3 +# checkEquals (length (3, 3)) 2 +# +# checkEquals (isEmpty (,)) True +# +# checkEquals (lastIndex (1, 2, 3)) (Ok 2) +# checkEquals (lastIndex (3, 3)) (Ok 1) +# checkEquals (lastIndex (,)) (Error Empty) +# +# checkEquals ((1, 2, 3) | isValidIndex (int.negate 1)) False +# checkEquals ((1, 2, 3) | isValidIndex 0) True +# checkEquals ((1, 2, 3) | isValidIndex 1) True +# checkEquals ((1, 2, 3) | isValidIndex 2) True +# checkEquals ((1, 2, 3) | isValidIndex 3) False +# checkEquals ((1, 2, 3) | isValidIndex 4) False +# checkEquals ((1, 2, 3) | isValidIndex 100) False +# +# checkEquals ((1, 2, 3) | isValidInsertIndex (int.negate 1)) False +# checkEquals ((1, 2, 3) | isValidInsertIndex 0) True +# checkEquals ((1, 2, 3) | isValidInsertIndex 1) True +# checkEquals ((1, 2, 3) | isValidInsertIndex 2) True +# checkEquals ((1, 2, 3) | isValidInsertIndex 3) True +# checkEquals ((1, 2, 3) | isValidInsertIndex 4) False +# checkEquals ((1, 2, 3) | isValidInsertIndex 100) False +# +# checkEquals ((Foo, Bar, Baz) | get 0) Foo +# checkEquals ((Foo, Bar, Baz) | get 1) Bar +# checkEquals ((Foo, Bar, Baz) | get 2) Baz +# +# checkEquals (single (,)) (Error Empty) +# checkEquals (single (Foo,)) (Ok Foo) +# checkEquals (single (Foo, Bar)) (Error MoreThanOneItem) +# +# checkEquals (first (,)) (Error Empty) +# checkEquals (first (Foo,)) (Ok Foo) +# checkEquals (first (Foo, Bar)) (Ok Foo) +# +# checkEquals (last (,)) (Error Empty) +# checkEquals (last (Foo,)) (Ok Foo) +# checkEquals (last (Foo, Bar)) (Ok Bar) +# +# checkEquals ((Foo, Bar) | insert 0 Baz) (Baz, Foo, Bar) +# checkEquals ((Foo, Bar) | insert 1 Baz) (Foo, Baz, Bar) +# checkEquals ((Foo, Bar) | insert 2 Baz) (Foo, Bar, Baz) +# +# checkEquals ((Foo, Bar) | prepend Baz) (Baz, Foo, Bar) +# +# checkEquals ((Foo, Bar) | append Baz) (Foo, Bar, Baz) +# +# checkEquals ((Foo, Bar) | replace 0 Baz) (Baz, Bar) +# checkEquals ((Foo, Bar) | replace 1 Baz) (Foo, Baz) +# +# checkEquals ((1, 2) | update 0 { a -> int.add a 1 }) (2, 2) +# +# checkEquals ((Foo, Bar) | removeAt 0) (Bar,) +# checkEquals ((Foo, Bar) | removeAt 1) (Foo,) +# +# checkEquals (filled 2 Foo) (Foo, Foo) +# checkEquals (filled 10 1) (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) +# +# checkEquals (generate 5 { a -> a }) (0, 1, 2, 3, 4) +# +# checkEquals ((1, 2, 3, 4, 5) | getRange 1 4) (2, 3, 4) +# +# checkEquals (concatenate (1, 2, 3) (4, 5)) (1, 2, 3, 4, 5) diff --git a/packages/Core/result.candy b/packages/Core/result.candy index fe1e6ae0d..1183cc49b 100644 --- a/packages/Core/result.candy +++ b/packages/Core/result.candy @@ -112,65 +112,65 @@ flatten resultOfResult := innerResult } -test = - [checkEquals] = use "..check" - int = use "..int" - - checkEquals (is (Ok 4)) True - checkEquals (is (Error 4)) True - checkEquals (is 4) False - - checkEquals (getValue (Ok 4)) 4 - checkEquals (getValue (Error 4)) 4 - - checkEquals (isOk (Error 4)) False - checkEquals (isOk (Ok 4)) True - - checkEquals (unwrap (Ok 4)) 4 - checkEquals (expect (Ok 4) "blub") 4 - - checkEquals (isError (Error 4)) True - checkEquals (isError (Ok 4)) False - - checkEquals (unwrapError (Error 4)) 4 - checkEquals (expectError (Error 4) "blub") 4 - - checkEquals ((Ok 4) | mapOrElse { a -> int.add a 1 } { a -> int.add a 2 }) 5 - checkEquals ((Error 4) | mapOrElse { a -> int.add a 1 } { a -> int.add a 2 }) 6 - - checkEquals ((Ok 4) | mapOr { a -> int.add a 1 } 2) 5 - checkEquals ((Error 4) | mapOr { a -> int.add a 1 } 2) 2 - - checkEquals ((Ok 1) | flatMap { a -> Ok (int.add a 1) }) (Ok 2) - checkEquals ((Error 1) | flatMap { a -> Ok (int.add a 1) }) (Error 1) - checkEquals ((Ok 1) | flatMap { a -> Error 3 }) (Error 3) - - checkEquals ((Ok 1) | map { a -> int.add a 1 }) (Ok 2) - checkEquals ((Error 1) | map { a -> int.add a 1 }) (Error 1) - - checkEquals ((Ok 1) | and (Ok 2)) (Ok 2) - checkEquals ((Ok 1) | and (Error 2)) (Error 2) - checkEquals ((Error 1) | and (Ok 2)) (Error 1) - checkEquals ((Error 1) | and (Error 2)) (Error 1) - - checkEquals ((Ok 1) | flatMapError { a -> Ok (int.add a 1) }) (Ok 1) - checkEquals ((Error 1) | flatMapError { a -> Ok (int.add a 1) }) (Ok 2) - checkEquals ((Error 1) | flatMapError { a -> Error (int.add a 1) }) (Error 2) - - checkEquals ((Ok 1) | mapError { a -> int.add a 1 }) (Ok 1) - checkEquals ((Error 1) | mapError { a -> int.add a 1 }) (Error 2) - - checkEquals ((Ok 1) | or (Ok 2)) (Ok 1) - checkEquals ((Ok 1) | or (Error 2)) (Ok 1) - checkEquals ((Error 1) | or (Ok 2)) (Ok 2) - checkEquals ((Error 1) | or (Error 2)) (Error 2) - - checkEquals (unwrapOrElse (Ok 1) { 2 }) 1 - checkEquals (unwrapOrElse (Error 1) { 2 }) 2 - - checkEquals (unwrapOr (Ok 1) 2) 1 - checkEquals (unwrapOr (Error 1) 2) 2 - - checkEquals (flatten (Error 1)) (Error 1) - checkEquals (flatten (Ok (Error 1))) (Error 1) - checkEquals (flatten (Ok (Ok 1))) (Ok 1) +#test = +# [checkEquals] = use "..check" +# int = use "..int" +# +# checkEquals (is (Ok 4)) True +# checkEquals (is (Error 4)) True +# checkEquals (is 4) False +# +# checkEquals (getValue (Ok 4)) 4 +# checkEquals (getValue (Error 4)) 4 +# +# checkEquals (isOk (Error 4)) False +# checkEquals (isOk (Ok 4)) True +# +# checkEquals (unwrap (Ok 4)) 4 +# checkEquals (expect (Ok 4) "blub") 4 +# +# checkEquals (isError (Error 4)) True +# checkEquals (isError (Ok 4)) False +# +# checkEquals (unwrapError (Error 4)) 4 +# checkEquals (expectError (Error 4) "blub") 4 +# +# checkEquals ((Ok 4) | mapOrElse { a -> int.add a 1 } { a -> int.add a 2 }) 5 +# checkEquals ((Error 4) | mapOrElse { a -> int.add a 1 } { a -> int.add a 2 }) 6 +# +# checkEquals ((Ok 4) | mapOr { a -> int.add a 1 } 2) 5 +# checkEquals ((Error 4) | mapOr { a -> int.add a 1 } 2) 2 +# +# checkEquals ((Ok 1) | flatMap { a -> Ok (int.add a 1) }) (Ok 2) +# checkEquals ((Error 1) | flatMap { a -> Ok (int.add a 1) }) (Error 1) +# checkEquals ((Ok 1) | flatMap { a -> Error 3 }) (Error 3) +# +# checkEquals ((Ok 1) | map { a -> int.add a 1 }) (Ok 2) +# checkEquals ((Error 1) | map { a -> int.add a 1 }) (Error 1) +# +# checkEquals ((Ok 1) | and (Ok 2)) (Ok 2) +# checkEquals ((Ok 1) | and (Error 2)) (Error 2) +# checkEquals ((Error 1) | and (Ok 2)) (Error 1) +# checkEquals ((Error 1) | and (Error 2)) (Error 1) +# +# checkEquals ((Ok 1) | flatMapError { a -> Ok (int.add a 1) }) (Ok 1) +# checkEquals ((Error 1) | flatMapError { a -> Ok (int.add a 1) }) (Ok 2) +# checkEquals ((Error 1) | flatMapError { a -> Error (int.add a 1) }) (Error 2) +# +# checkEquals ((Ok 1) | mapError { a -> int.add a 1 }) (Ok 1) +# checkEquals ((Error 1) | mapError { a -> int.add a 1 }) (Error 2) +# +# checkEquals ((Ok 1) | or (Ok 2)) (Ok 1) +# checkEquals ((Ok 1) | or (Error 2)) (Ok 1) +# checkEquals ((Error 1) | or (Ok 2)) (Ok 2) +# checkEquals ((Error 1) | or (Error 2)) (Error 2) +# +# checkEquals (unwrapOrElse (Ok 1) { 2 }) 1 +# checkEquals (unwrapOrElse (Error 1) { 2 }) 2 +# +# checkEquals (unwrapOr (Ok 1) 2) 1 +# checkEquals (unwrapOr (Error 1) 2) 2 +# +# checkEquals (flatten (Error 1)) (Error 1) +# checkEquals (flatten (Ok (Error 1))) (Error 1) +# checkEquals (flatten (Ok (Ok 1))) (Ok 1) diff --git a/packages/Core/struct.candy b/packages/Core/struct.candy index 724ba7f76..ae93b1f17 100644 --- a/packages/Core/struct.candy +++ b/packages/Core/struct.candy @@ -16,17 +16,17 @@ getKeys struct := needs (is struct) struct | builtins.structGetKeys -test = - [checkEquals] = use "..check" - - checkEquals (is 3) False - checkEquals (is []) True - - checkEquals (hasKey [Foo: 2] Foo) True - checkEquals (hasKey [Foo: 2] Bar) False - - checkEquals (get [Foo: 2] Foo) (Ok 2) - checkEquals (get [Foo: 2] Bar) (Error KeyNotInStruct) - - checkEquals (getKeys [Foo: 2]) (Foo,) - ## For bigger structs, the order of keys is not guaranteed. +#test = +# [checkEquals] = use "..check" +# +# checkEquals (is 3) False +# checkEquals (is []) True +# +# checkEquals (hasKey [Foo: 2] Foo) True +# checkEquals (hasKey [Foo: 2] Bar) False +# +# checkEquals (get [Foo: 2] Foo) (Ok 2) +# checkEquals (get [Foo: 2] Bar) (Error KeyNotInStruct) +# +# checkEquals (getKeys [Foo: 2]) (Foo,) +# ## For bigger structs, the order of keys is not guaranteed. diff --git a/packages/Core/tag.candy b/packages/Core/tag.candy index b9027bc10..b19bad0e1 100644 --- a/packages/Core/tag.candy +++ b/packages/Core/tag.candy @@ -21,19 +21,19 @@ withValue tag value := needs (is tag) (tag | withoutValue) value -test = - [checkEquals] = use "..check" - - checkEquals (is 3) False - checkEquals (is Foo) True - checkEquals (is (Foo 2)) True - - checkEquals (hasValue Foo) False - checkEquals (hasValue (Foo 2)) True - - checkEquals (withoutValue Foo) Foo - checkEquals (withoutValue (Foo 2)) Foo - - checkEquals (getValue (Foo 2)) 2 - - checkEquals (withSymbol (Foo 2) Bar) (Bar 2) +#test = +# [checkEquals] = use "..check" +# +# checkEquals (is 3) False +# checkEquals (is Foo) True +# checkEquals (is (Foo 2)) True +# +# checkEquals (hasValue Foo) False +# checkEquals (hasValue (Foo 2)) True +# +# checkEquals (withoutValue Foo) Foo +# checkEquals (withoutValue (Foo 2)) Foo +# +# checkEquals (getValue (Foo 2)) 2 +# +# checkEquals (withSymbol (Foo 2) Bar) (Bar 2) diff --git a/packages/Core/text.candy b/packages/Core/text.candy index f98fda034..2689ddb0e 100644 --- a/packages/Core/text.candy +++ b/packages/Core/text.candy @@ -121,22 +121,22 @@ trim text := needs (is text) text | trimStart | trimEnd -test = - [checkEquals] = use "..check" - - checkEquals (is "Hi") True - checkEquals (is 2) False - - checkEquals (isEmpty "") True - checkEquals (isEmpty "Hi") False - - checkEquals (length "") 0 - checkEquals (length "Hi") 2 - checkEquals (length "🍔") 1 - - checkEquals (characters "Hello") ("H", "e", "l", "l", "o") - - checkEquals (getRange "Hello" 1 4) "ell" - - checkEquals (concatenate "jelly" "fish") "jellyfish" - checkEquals (concatenate "tea" "sing") "teasing" +#test = +# [checkEquals] = use "..check" +# +# checkEquals (is "Hi") True +# checkEquals (is 2) False +# +# checkEquals (isEmpty "") True +# checkEquals (isEmpty "Hi") False +# +# checkEquals (length "") 0 +# checkEquals (length "Hi") 2 +# checkEquals (length "🍔") 1 +# +# checkEquals (characters "Hello") ("H", "e", "l", "l", "o") +# +# checkEquals (getRange "Hello" 1 4) "ell" +# +# checkEquals (concatenate "jelly" "fish") "jellyfish" +# checkEquals (concatenate "tea" "sing") "teasing" diff --git a/packages/Core/toDebugText.candy b/packages/Core/toDebugText.candy index 6c2dad20d..699d237d5 100644 --- a/packages/Core/toDebugText.candy +++ b/packages/Core/toDebugText.candy @@ -2,13 +2,13 @@ builtins = use "Builtins" toDebugText value := builtins.toDebugText value -test = - [checkEquals] = use "..check" - - checkEquals (3 | toDebugText) "3" - checkEquals ("Hi" | toDebugText) '""Hi""' - checkEquals (Foo | toDebugText) "Foo" - checkEquals (Foo 3 | toDebugText) "Foo 3" - checkEquals (Foo (Bar 3) | toDebugText) "Foo (Bar 3)" - checkEquals ((1, 2, 3) | toDebugText) "(1, 2, 3)" - checkEquals ({} | toDebugText) '"{ … }"' +#test = +# [checkEquals] = use "..check" +# +# checkEquals (3 | toDebugText) "3" +# checkEquals ("Hi" | toDebugText) '""Hi""' +# checkEquals (Foo | toDebugText) "Foo" +# checkEquals (Foo 3 | toDebugText) "Foo 3" +# checkEquals (Foo (Bar 3) | toDebugText) "Foo (Bar 3)" +# checkEquals ((1, 2, 3) | toDebugText) "(1, 2, 3)" +# checkEquals ({} | toDebugText) '"{ … }"' diff --git a/packages/Core/type.candy b/packages/Core/type.candy index 8b697694f..47d5cf55a 100644 --- a/packages/Core/type.candy +++ b/packages/Core/type.candy @@ -7,12 +7,12 @@ is value type := needs (typeOf type | equals Tag) equals (typeOf value) type -test = - [checkEquals] = use "..check" - - checkEquals (typeOf 3) Int - checkEquals (typeOf "Text") Text - checkEquals (typeOf Foo) Tag - checkEquals (typeOf (1, 2, 3)) List - checkEquals (typeOf []) Struct - checkEquals (typeOf {}) Function +#test = +# [checkEquals] = use "..check" +# +# checkEquals (typeOf 3) Int +# checkEquals (typeOf "Text") Text +# checkEquals (typeOf Foo) Tag +# checkEquals (typeOf (1, 2, 3)) List +# checkEquals (typeOf []) Struct +# checkEquals (typeOf {}) Function