-
Notifications
You must be signed in to change notification settings - Fork 574
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
92c471f
commit bfecbbe
Showing
7 changed files
with
110 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Tests function calls. | ||
|
||
# Function names are case-insensitive. | ||
> sqrt(1) | ||
> SQRT(1) | ||
--- | ||
Float(1.0) | ||
Float(1.0) | ||
|
||
# A space is allowed around the arguments. | ||
> sqrt ( 1 ) | ||
--- | ||
Float(1.0) | ||
|
||
# Wrong number of arguments errors. | ||
!> sqrt() | ||
!> sqrt(1, 2) | ||
--- | ||
Error: invalid input: unknown function sqrt with 0 arguments | ||
Error: invalid input: unknown function sqrt with 2 arguments | ||
|
||
# Unknown functions error. | ||
!> unknown() | ||
!> unknown(1, 2, 3) | ||
--- | ||
Error: invalid input: unknown function unknown with 0 arguments | ||
Error: invalid input: unknown function unknown with 3 arguments | ||
|
||
# Parse errors. | ||
!> unknown(1, 2, 3 | ||
!> unknown(1, 2, 3,) | ||
!> unknown(1, 2 3) | ||
--- | ||
Error: invalid input: unexpected end of input | ||
Error: invalid input: expected expression atom, found ) | ||
Error: invalid input: expected token ,, found 3 |
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Tests sqrt(). | ||
|
||
# Integers work, and return floats. | ||
[expr]> sqrt(2) | ||
[expr]> sqrt(100) | ||
--- | ||
Float(1.4142135623730951) ← SquareRoot(Constant(Integer(2))) | ||
Float(10.0) ← SquareRoot(Constant(Integer(100))) | ||
|
||
# Negative integers error, but 0 is valid. | ||
!> sqrt(-1) | ||
> sqrt(0) | ||
--- | ||
Error: invalid input: can't take square root of -1 | ||
Float(0.0) | ||
|
||
# Floats work. | ||
> sqrt(3.14) | ||
> sqrt(100.0) | ||
--- | ||
Float(1.772004514666935) | ||
Float(10.0) | ||
|
||
# Negative floats work, but return NAN. | ||
> sqrt(-1.0) | ||
--- | ||
Float(NaN) | ||
|
||
# Test various special float values. | ||
> sqrt(-0.0) | ||
> sqrt(0.0) | ||
> sqrt(NAN) | ||
> sqrt(INFINITY) | ||
> sqrt(-INFINITY) | ||
--- | ||
Float(-0.0) | ||
Float(0.0) | ||
Float(NaN) | ||
Float(inf) | ||
Float(NaN) | ||
|
||
# NULL is passed through. | ||
> sqrt(NULL) | ||
--- | ||
Null | ||
|
||
# Strings and booleans error. | ||
!> sqrt(TRUE) | ||
!> sqrt('foo') | ||
--- | ||
Error: invalid input: can't take square root of TRUE | ||
Error: invalid input: can't take square root of foo |
This file was deleted.
Oops, something went wrong.
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