diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/c/string_of_bits.expect | 6 | ||||
| -rw-r--r-- | test/c/string_of_bits.sail | 25 |
2 files changed, 31 insertions, 0 deletions
diff --git a/test/c/string_of_bits.expect b/test/c/string_of_bits.expect new file mode 100644 index 00000000..e373cf38 --- /dev/null +++ b/test/c/string_of_bits.expect @@ -0,0 +1,6 @@ +HelloWorld0b11110000111 0xFF +HelloWorld0b11110000111 0xFF +HelloWorld0b11110000111 0xFF +HelloWorld0b11110000111 0xFF +HelloWorld0b11110000111 0xFF +HelloWorld0b11110000111 0xFF diff --git a/test/c/string_of_bits.sail b/test/c/string_of_bits.sail new file mode 100644 index 00000000..fcaeb3e1 --- /dev/null +++ b/test/c/string_of_bits.sail @@ -0,0 +1,25 @@ +default Order dec + +$include <prelude.sail> + +val "concat_str" : (string, string) -> string + +infixl 1 ++ + +overload operator ++ = {concat_str} + +val "print_endline" : string -> unit + +val BitStr = "string_of_bits" : forall 'n. bits('n) -> string + +val DecStr = "decimal_string_of_bits" : forall 'n. bits('n) -> string + +function main(() : unit) -> unit = { + foreach (i from 0 to 5) { + let x = "Hello"; + let y = "World"; + let z = 0b1111_0000_111; + let w = 0xFF; + print_endline(x ++ y ++ BitStr(z) ++ " " ++ BitStr(w)) + } +}
\ No newline at end of file |
