An Erlang lexer and syntax highlighter in Gleam

Add tests for complex tokens

+50
+50
test/pearl_test.gleam
··· 45 45 assert_roundtrip(tokens_file, False) 46 46 } 47 47 48 + pub fn numbers_test() { 49 + let src = 50 + "2.3E10 5.4e-3 16#ABCDEF 16#abcdef123 8#1234 2#101101 0123 0988 1_2_3_4_5 51 + 1_2.3_4e-5_6 14#123_456_aBC" 52 + assert_tokens(src, [ 53 + token.Float("2.3E10"), 54 + token.Float("5.4e-3"), 55 + token.Integer("16#ABCDEF"), 56 + token.Integer("16#abcdef123"), 57 + token.Integer("8#1234"), 58 + token.Integer("2#101101"), 59 + token.Integer("0123"), 60 + token.Integer("0988"), 61 + token.Integer("1_2_3_4_5"), 62 + token.Float("1_2.3_4e-5_6"), 63 + token.Integer("14#123_456_aBC"), 64 + ]) 65 + } 66 + 67 + pub fn atom_variable_test() { 68 + let src = "this_is_an_atom This_is_a_variable 'This is an atom'" 69 + assert_tokens(src, [ 70 + token.Atom("this_is_an_atom", False), 71 + token.Variable("This_is_a_variable"), 72 + token.Atom("This is an atom", True), 73 + ]) 74 + } 75 + 76 + pub fn sigil_test() { 77 + let src = 78 + "~B/This is a raw sigil\\/ ~<Bracketed, with escapes <\\>> 79 + ~s|Sigil which allows \"quotes\"|" 80 + assert_tokens(src, [ 81 + token.Sigil("B", token.SigilSlash, "This is a raw sigil\\"), 82 + token.Sigil("", token.SigilAngle, "Bracketed, with escapes <\\>"), 83 + token.Sigil("s", token.SigilPipe, "Sigil which allows \"quotes\""), 84 + ]) 85 + } 86 + 87 + pub fn character_literal_test() { 88 + let src = "$\" $\\^_ $\\xAb $\\x{abcDe1} $\\41" 89 + assert_tokens(src, [ 90 + token.Character("\""), 91 + token.Character("\\^_"), 92 + token.Character("\\xAb"), 93 + token.Character("\\x{abcDe1}"), 94 + token.Character("\\41"), 95 + ]) 96 + } 97 + 48 98 pub fn unknown_character_test() { 49 99 let src = "a&b" 50 100 assert_errors(src, [pearl.UnknownCharacter("&")])