xgo/runtime/vm_bitwise_test.go
Daniel 61890b15cb
module refactor (#148)
* 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
2019-03-18 08:15:26 -07:00

36 lines
1 KiB
Go

package runtime_test
import "testing"
func TestBitwise(t *testing.T) {
expect(t, `out = 1 & 1`, nil, 1)
expect(t, `out = 1 & 0`, nil, 0)
expect(t, `out = 0 & 1`, nil, 0)
expect(t, `out = 0 & 0`, nil, 0)
expect(t, `out = 1 | 1`, nil, 1)
expect(t, `out = 1 | 0`, nil, 1)
expect(t, `out = 0 | 1`, nil, 1)
expect(t, `out = 0 | 0`, nil, 0)
expect(t, `out = 1 ^ 1`, nil, 0)
expect(t, `out = 1 ^ 0`, nil, 1)
expect(t, `out = 0 ^ 1`, nil, 1)
expect(t, `out = 0 ^ 0`, nil, 0)
expect(t, `out = 1 &^ 1`, nil, 0)
expect(t, `out = 1 &^ 0`, nil, 1)
expect(t, `out = 0 &^ 1`, nil, 0)
expect(t, `out = 0 &^ 0`, nil, 0)
expect(t, `out = 1 << 2`, nil, 4)
expect(t, `out = 16 >> 2`, nil, 4)
expect(t, `out = 1; out &= 1`, nil, 1)
expect(t, `out = 1; out |= 0`, nil, 1)
expect(t, `out = 1; out ^= 0`, nil, 1)
expect(t, `out = 1; out &^= 0`, nil, 1)
expect(t, `out = 1; out <<= 2`, nil, 4)
expect(t, `out = 16; out >>= 2`, nil, 4)
expect(t, `out = ^0`, nil, ^0)
expect(t, `out = ^1`, nil, ^1)
expect(t, `out = ^55`, nil, ^55)
expect(t, `out = ^-55`, nil, ^-55)
}