| 14 | ) |
| 15 | |
| 16 | func TestParse(t *testing.T) { |
| 17 | tests := []struct { |
| 18 | input string |
| 19 | want Node |
| 20 | }{ |
| 21 | { |
| 22 | "a", |
| 23 | &IdentifierNode{Value: "a"}, |
| 24 | }, |
| 25 | { |
| 26 | `"str"`, |
| 27 | &StringNode{Value: "str"}, |
| 28 | }, |
| 29 | { |
| 30 | "`hello\nworld`", |
| 31 | &StringNode{Value: `hello |
| 32 | world`}, |
| 33 | }, |
| 34 | { |
| 35 | "3", |
| 36 | &IntegerNode{Value: 3}, |
| 37 | }, |
| 38 | { |
| 39 | "0xFF", |
| 40 | &IntegerNode{Value: 255}, |
| 41 | }, |
| 42 | { |
| 43 | "0x6E", |
| 44 | &IntegerNode{Value: 110}, |
| 45 | }, |
| 46 | { |
| 47 | "0X63", |
| 48 | &IntegerNode{Value: 99}, |
| 49 | }, |
| 50 | { |
| 51 | "0o600", |
| 52 | &IntegerNode{Value: 384}, |
| 53 | }, |
| 54 | { |
| 55 | "0O45", |
| 56 | &IntegerNode{Value: 37}, |
| 57 | }, |
| 58 | { |
| 59 | "0b10", |
| 60 | &IntegerNode{Value: 2}, |
| 61 | }, |
| 62 | { |
| 63 | "0B101011", |
| 64 | &IntegerNode{Value: 43}, |
| 65 | }, |
| 66 | { |
| 67 | "10_000_000", |
| 68 | &IntegerNode{Value: 10_000_000}, |
| 69 | }, |
| 70 | { |
| 71 | "2.5", |
| 72 | &FloatNode{Value: 2.5}, |
| 73 | }, |