61890b15cb
* wip * move print and JSON functions to modules * builtin functions are not replacable now * builtin functions are added for default nil symbol table * importables: builtin modules and source modules * refactoring runtime tests * fix tests * update documentation * cleanup * clean up cli * fix REPL prints
41 lines
1.9 KiB
Go
41 lines
1.9 KiB
Go
package runtime_test
|
|
|
|
import "testing"
|
|
|
|
func TestLogical(t *testing.T) {
|
|
expect(t, `out = true && true`, nil, true)
|
|
expect(t, `out = true && false`, nil, false)
|
|
expect(t, `out = false && true`, nil, false)
|
|
expect(t, `out = false && false`, nil, false)
|
|
expect(t, `out = !true && true`, nil, false)
|
|
expect(t, `out = !true && false`, nil, false)
|
|
expect(t, `out = !false && true`, nil, true)
|
|
expect(t, `out = !false && false`, nil, false)
|
|
|
|
expect(t, `out = true || true`, nil, true)
|
|
expect(t, `out = true || false`, nil, true)
|
|
expect(t, `out = false || true`, nil, true)
|
|
expect(t, `out = false || false`, nil, false)
|
|
expect(t, `out = !true || true`, nil, true)
|
|
expect(t, `out = !true || false`, nil, false)
|
|
expect(t, `out = !false || true`, nil, true)
|
|
expect(t, `out = !false || false`, nil, true)
|
|
|
|
expect(t, `out = 1 && 2`, nil, 2)
|
|
expect(t, `out = 1 || 2`, nil, 1)
|
|
expect(t, `out = 1 && 0`, nil, 0)
|
|
expect(t, `out = 1 || 0`, nil, 1)
|
|
expect(t, `out = 1 && (0 || 2)`, nil, 2)
|
|
expect(t, `out = 0 || (0 || 2)`, nil, 2)
|
|
expect(t, `out = 0 || (0 && 2)`, nil, 0)
|
|
expect(t, `out = 0 || (2 && 0)`, nil, 0)
|
|
|
|
expect(t, `t:=func() {out = 3; return true}; f:=func() {out = 7; return false}; t() && f()`, nil, 7)
|
|
expect(t, `t:=func() {out = 3; return true}; f:=func() {out = 7; return false}; f() && t()`, nil, 7)
|
|
expect(t, `t:=func() {out = 3; return true}; f:=func() {out = 7; return false}; f() || t()`, nil, 3)
|
|
expect(t, `t:=func() {out = 3; return true}; f:=func() {out = 7; return false}; t() || f()`, nil, 3)
|
|
expect(t, `t:=func() {out = 3; return true}; f:=func() {out = 7; return false}; !t() && f()`, nil, 3)
|
|
expect(t, `t:=func() {out = 3; return true}; f:=func() {out = 7; return false}; !f() && t()`, nil, 3)
|
|
expect(t, `t:=func() {out = 3; return true}; f:=func() {out = 7; return false}; !f() || t()`, nil, 7)
|
|
expect(t, `t:=func() {out = 3; return true}; f:=func() {out = 7; return false}; !t() || f()`, nil, 7)
|
|
}
|