fspl/eval/test/eval_test.go
2024-04-20 23:40:41 -04:00

65 lines
996 B
Go

package evaltest
import "testing"
func TestEvalLiteralInt (test *testing.T) {
testString(test,
`-234`,
`
[main]:Int = -234
`)}
func TestEvalLiteralFloat (test *testing.T) {
testString(test,
`854.32`,
`
[main]:F64 = 854.32
`)}
func TestEvalLiteralString (test *testing.T) {
testString(test,
`'hello'`,
`
[main]:String = 'hello'
`)}
func TestEvalArray (test *testing.T) {
testString(test,
`((2 3 1) (8 9 -23) (432 89 1))`,
`
[main]:3:3:Int = (
( 2 3 1)
( 8 9 -23)
(432 89 1))
`)}
func TestEvalStruct (test *testing.T) {
testString(test,
`(. a:489 b:5.283 c:'a string' d:(2 3 1 293) e:(. x:32 y:92) f:true g:nil)`,
`
T:(. a:Int b:F64 c:String d:*:Int e:(. x:Int y:Int) f:Bool g:*Int)
[main]:T = (.
a: 489
b: 5.283
c: 'a string'
d: (2 3 1 293)
e: (. x: 32 y: 92)
f: true
g: nil)
`)}
func TestEvalLiteralBoolean (test *testing.T) {
testString(test,
`true`,
`
[main]:Bool = true
`)}
func TestEvalLiteralNil (test *testing.T) {
testString(test,
`nil`,
`
[main]:*Int = nil
`)}