-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #744 from candy-lang/add-tests
Add tests to Core package
- Loading branch information
Showing
20 changed files
with
556 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
bool = use "..bool" | ||
[if] = use "..controlFlow" | ||
[equals] = use "Builtins" | ||
|
||
check condition := | ||
# Panics if the `condition` is `False`. | ||
# | ||
# This function is useful for ensuring that your mental model of the state of | ||
# your program matches its actual state. | ||
needs (bool.is condition) | ||
needs condition "A check didn't succeed." | ||
isConditionBool = condition % | ||
True | False -> True | ||
_ -> False | ||
needs isConditionBool | ||
needs condition "A check failed." | ||
|
||
checkEquals actual expected := | ||
# Panics if `actual` and `expected` are different. | ||
needs (actual | equals expected) "A check failed: Expected {actual} to be {expected}." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,40 @@ | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
8de67ee
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compiler
Time: Compiler/hello_world
45674162
ns/iter (± 769465
)26462601
ns/iter (± 568109
)1.73
Time: Compiler/fibonacci
2952241170
ns/iter (± 2624802
)191761450
ns/iter (± 1627935
)15.40
Time: VM Runtime/hello_world
58151
ns/iter (± 11621
)67151
ns/iter (± 10242
)0.87
This comment was automatically generated by workflow using github-action-benchmark.
8de67ee
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible performance regression was detected for benchmark 'Compiler'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold
2
.Time: Compiler/fibonacci
2952241170
ns/iter (± 2624802
)191761450
ns/iter (± 1627935
)15.40
This comment was automatically generated by workflow using github-action-benchmark.