(t *testing.T)
| 11 | } |
| 12 | |
| 13 | func TestScanner(t *testing.T) { |
| 14 | cases := []struct { |
| 15 | input string |
| 16 | want []scannedToken |
| 17 | }{ |
| 18 | { |
| 19 | input: `x"deadbeef"`, |
| 20 | want: []scannedToken{{tokHex, `x"deadbeef"`}}, |
| 21 | }, |
| 22 | { |
| 23 | input: `hello`, |
| 24 | want: []scannedToken{{tokIdent, `hello`}}, |
| 25 | }, |
| 26 | { |
| 27 | input: `-42`, |
| 28 | want: []scannedToken{{tokNumber, `-42`}}, |
| 29 | }, |
| 30 | { |
| 31 | input: ` "hello"`, |
| 32 | want: []scannedToken{{tokString, `"hello"`}}, |
| 33 | }, |
| 34 | { |
| 35 | input: ` 'hello' `, |
| 36 | want: []scannedToken{{tokString, `'hello'`}}, |
| 37 | }, |
| 38 | { |
| 39 | input: ` " 'hello world' " `, |
| 40 | want: []scannedToken{{tokString, `" 'hello world' "`}}, |
| 41 | }, |
| 42 | { |
| 43 | input: `hello world`, |
| 44 | want: []scannedToken{ |
| 45 | {tokIdent, `hello`}, |
| 46 | {tokIdent, `world`}, |
| 47 | }, |
| 48 | }, |
| 49 | { |
| 50 | input: `hello 42 "worlds" x'ffff'`, |
| 51 | want: []scannedToken{ |
| 52 | {tokIdent, `hello`}, |
| 53 | {tokNumber, `42`}, |
| 54 | {tokString, `"worlds"`}, |
| 55 | {tokHex, `x'ffff'`}, |
| 56 | }, |
| 57 | }, |
| 58 | { |
| 59 | input: `$label: jump:$label`, |
| 60 | want: []scannedToken{ |
| 61 | {tokLabel, `$label`}, |
| 62 | {tokColon, `:`}, |
| 63 | {tokJump, `jump:`}, |
| 64 | {tokLabel, `$label`}, |
| 65 | }, |
| 66 | }, |
| 67 | } |
| 68 | |
| 69 | for _, tc := range cases { |
| 70 | var s scanner |
nothing calls this directly
no test coverage detected