github.com/neugram/ng@v0.0.0-20180309130942-d472ff93d872/eval/testdata/binop2.ng (about) 1 a := 0x0101 2 b := 0x1001 3 4 if a|b != 0x1101 { 5 panic("ERROR 1") 6 } 7 8 if a&b != 0x0001 { 9 panic("ERROR 2") 10 } 11 12 if a^b != 0x1100 { 13 panic("ERROR 3") 14 } 15 16 if a%b != 0x0101 { 17 panic("ERROR 4") 18 } 19 20 if a&^b != 0x0100 { 21 panic("ERROR 5") 22 } 23 24 import "fmt" 25 26 var x int8 = 3 27 if s := fmt.Sprintf("%08b", x << 0); s != "00000011" { 28 panic(errorf("ERROR 5.1: %q", s)) 29 } 30 31 if s := fmt.Sprintf("%08b", x << 1); s != "00000110" { 32 panic(errorf("ERROR 5.2: %q", s)) 33 } 34 35 if s := fmt.Sprintf("%08b", x << 2); s != "00001100" { 36 panic(errorf("ERROR 5.3: %q", s)) 37 } 38 39 if s := fmt.Sprintf("%08b", x << 3); s != "00011000" { 40 panic(errorf("ERROR 5.4: %q", s)) 41 } 42 43 var y uint8 = 120 44 45 if s := fmt.Sprintf("%08b", y >> 0); s != "01111000" { 46 panic(errorf("ERROR 6.1: %q", s)) 47 } 48 49 if s := fmt.Sprintf("%08b", y >> 1); s != "00111100" { 50 panic(errorf("ERROR 6.2: %q", s)) 51 } 52 53 if s := fmt.Sprintf("%08b", y >> 2); s != "00011110" { 54 panic(errorf("ERROR 6.3: %q", s)) 55 } 56 57 print("OK")