fspl/analyzer/operation_test.go

82 lines
1.3 KiB
Go

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