2024-04-13 10:11:44 +02:00
|
|
|
// Copyright (c) 2024 Celestino Amoroso (celestino.amoroso@gmail.com).
|
|
|
|
// All rights reserved.
|
|
|
|
|
2024-05-28 07:26:05 +02:00
|
|
|
// t_expr_test.go
|
2024-04-13 10:11:44 +02:00
|
|
|
package expr
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestExpr(t *testing.T) {
|
2024-06-01 19:56:40 +02:00
|
|
|
section := "Expr"
|
2024-04-13 10:11:44 +02:00
|
|
|
|
|
|
|
inputs := []inputType{
|
2024-04-20 06:56:26 +02:00
|
|
|
/* 1 */ {`0?{}`, nil, nil},
|
|
|
|
/* 2 */ {`fact=func(n){(n)?{1}::{n*fact(n-1)}}; fact(5)`, int64(120), nil},
|
2024-06-17 09:53:21 +02:00
|
|
|
/* 3 */ {`builtin "os.file"; f=fileOpen("test-file.txt"); line=fileReadText(f); fileClose(f); line`, "uno", nil},
|
2024-04-20 08:50:05 +02:00
|
|
|
/* 4 */ {`mynot=func(v){int(v)?{true}::{false}}; mynot(0)`, true, nil},
|
2024-05-06 15:31:28 +02:00
|
|
|
/* 5 */ {`1 ? {1} : [1+0] {3*(1+1)}`, int64(6), nil},
|
2024-05-19 01:38:07 +02:00
|
|
|
/* 6 */ {`
|
2024-04-26 21:03:22 +02:00
|
|
|
ds={
|
2024-07-21 05:45:22 +02:00
|
|
|
"init":func(@end){@current=0 but true},
|
|
|
|
//"current":func(){current},
|
2024-04-26 21:03:22 +02:00
|
|
|
"next":func(){
|
|
|
|
((next=current+1) <= end) ? [true] {@current=next but current} :: {nil}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
it=$(ds,3);
|
|
|
|
it++;
|
|
|
|
it++
|
|
|
|
`, int64(1), nil},
|
|
|
|
}
|
2024-06-01 19:56:40 +02:00
|
|
|
// t.Setenv("EXPR_PATH", ".")
|
2024-04-13 10:11:44 +02:00
|
|
|
|
2024-07-21 05:45:22 +02:00
|
|
|
//runTestSuiteSpec(t, section, inputs, 6)
|
2024-06-25 10:59:03 +02:00
|
|
|
runTestSuite(t, section, inputs)
|
2024-04-13 10:11:44 +02:00
|
|
|
}
|