fspl/analyzer/operation_test.go

84 lines
1.4 KiB
Go

package analyzer
import "testing"
func TestOperationModUnderArgCountErr (test *testing.T) {
testStringErr (test,
"wrong argument count for %", 2, 10,
`
[main] = [% 2]
`)
}
func TestOperationModOverArgCountErr (test *testing.T) {
testStringErr (test,
"wrong argument count for %", 2, 10,
`
[main] = [% 2 3 1]
`)
}
func TestOperationLogicalNegationOverArgCountErr (test *testing.T) {
testStringErr (test,
"wrong argument count for !", 2, 10,
`
[main] = [! 348 92]
`)
}
func TestOperationBitwiseNegationOverArgCountErr (test *testing.T) {
testStringErr (test,
"wrong argument count for !!", 2, 10,
`
[main] = [!! 348 92]
`)
}
func TestOperationBitShiftLeftOverArgCountErr (test *testing.T) {
testStringErr (test,
"wrong argument count for <<", 2, 10,
`
[main] = [<< 348 92 324]
`)
}
func TestOperationBitShiftRightOverArgCountErr (test *testing.T) {
testStringErr (test,
"wrong argument count for >>", 2, 10,
`
[main] = [>> 348 92 324]
`)
}
func TestOperationArgCount (test *testing.T) {
testString (test,
`
[main] = {
x:Int
b:Bool
x = [+ 1 2 3 4]
x = [++ 1]
x = [- 1 2 3 4]
x = [-- 1]
x = [* 5 6]
x = [/ 32 16]
x = [% 5 6]
x = [!! 1]
x = [|| 1 2]
x = [&& 3 1 5]
x = [^^ 1 2 3 4]
b = [! true]
b = [| true false]
b = [& true true]
b = [^ true true false true]
x = [<< 1 8]
x = [>> 8 1]
b = [< x 2 3 4]
b = [> x 2 3 4]
b = [<= x 5 3]
b = [>= x 2 3 3 4]
b = [= x 2 2 3 9]
}
`)
}