/* Every legal shape of '|', and the bitwise OR it still is for numbers. The mixed text/other case is rejected (reject_concat_non_text); this fixture pins the other side of the same rule, because a check that rejects too much is as wrong as one that rejects too little: text is BOTH spellings (string and []byte are one type), a named string type is text through its underlying type, and two non-text operands are a bitwise OR and must keep working. */ package main type label string func main() { // Termination: a batch program must still be stoppable, so the entry // handles the channel the runtime closes on SIGINT/SIGTERM. select { case <-shutdown: return default: } var n int64 = 5 var raw []byte = "y" var l label = "L" s := "x=" | "a" | raw | l if s != "x=ayL" { panic("string|[]byte|named-string = " | s) } // '+' and '+=' are the TEXT rules' other half: they are refused for text in // user code (reject_plus_text, reject_plusassign_text) and must stay legal // for numbers here. The first attempt at that rule used a predicate that // said yes to every Basic type and rejected `n += 3`, so the numeric forms // are part of this fixture. acc := n acc += 3 sum := acc + 4 if sum != 12 { panic("numeric += / + is wrong") } or := (n | 2) | 8 if or != 15 { // No .String() here on purpose: the builtin Stringer bodies are native // only (moxie.stringer is off for wasm), so a fixture that prints a // number cannot compile for the wasm target - and this one should. panic("bitwise OR is wrong") } println("concat text forms ok") }