MCPcopy
hub / github.com/expr-lang/expr / TestLex

Function TestLex

parser/lexer/lexer_test.go:14–362  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestLex(t *testing.T) {
15 tests := []struct {
16 input string
17 tokens []Token
18 }{
19 {
20 "1",
21 []Token{
22 {Kind: Number, Value: "1"},
23 {Kind: EOF},
24 },
25 },
26 {
27 ".5 0.025 1 02 1e3 0xFF 0b0101 0o600 1.2e-4 1_000_000 _42 -.5",
28 []Token{
29 {Kind: Number, Value: ".5"},
30 {Kind: Number, Value: "0.025"},
31 {Kind: Number, Value: "1"},
32 {Kind: Number, Value: "02"},
33 {Kind: Number, Value: "1e3"},
34 {Kind: Number, Value: "0xFF"},
35 {Kind: Number, Value: "0b0101"},
36 {Kind: Number, Value: "0o600"},
37 {Kind: Number, Value: "1.2e-4"},
38 {Kind: Number, Value: "1_000_000"},
39 {Kind: Identifier, Value: "_42"},
40 {Kind: Operator, Value: "-"},
41 {Kind: Number, Value: ".5"},
42 {Kind: EOF},
43 },
44 },
45 {
46 `"double" 'single' "abc \n\t\"\\" '"\'' "'\"" "\xC3\xBF\u263A\U000003A8" '❤️'`,
47 []Token{
48 {Kind: String, Value: "double"},
49 {Kind: String, Value: "single"},
50 {Kind: String, Value: "abc \n\t\"\\"},
51 {Kind: String, Value: "\"'"},
52 {Kind: String, Value: "'\""},
53 {Kind: String, Value: "ÿ☺Ψ"},
54 {Kind: String, Value: "❤️"},
55 {Kind: EOF},
56 },
57 },
58 {
59 "`backtick` `hello\u263Aworld` `hello\n\tworld` `hello\"world'` `\xC3\xBF\u263A\U000003A8` `❤️`",
60 []Token{
61 {Kind: String, Value: `backtick`},
62 {Kind: String, Value: `hello☺world`},
63 {Kind: String, Value: `hello
64 world`},
65 {Kind: String, Value: `hello"world'`},
66 {Kind: String, Value: `ÿ☺Ψ`},
67 {Kind: String, Value: "❤️"},
68 {Kind: EOF},
69 },
70 },
71 {

Callers

nothing calls this directly

Calls 5

NewSourceFunction · 0.92
LexFunction · 0.85
compareTokensFunction · 0.85
RunMethod · 0.80
ErrorfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…