about summary refs log tree commit diff
path: root/pkg
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2022-04-20 00:10:53 +0200
committerMel <einebeere@gmail.com>2022-04-20 00:10:53 +0200
commitdb3dd28cdf9009880c1ab5f12c47b673dd00bc43 (patch)
treecf18718c53143011443b1c8b690ee155c5c5d990 /pkg
parentd816a9eae2822c1db57efd5de80af926de474611 (diff)
downloadjinx-db3dd28cdf9009880c1ab5f12c47b673dd00bc43.tar.zst
jinx-db3dd28cdf9009880c1ab5f12c47b673dd00bc43.zip
Add scanner emoji in strings test
Diffstat (limited to 'pkg')
-rw-r--r--pkg/lang/scanner/scanner_test.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/pkg/lang/scanner/scanner_test.go b/pkg/lang/scanner/scanner_test.go
index 896cdfd..99e77fd 100644
--- a/pkg/lang/scanner/scanner_test.go
+++ b/pkg/lang/scanner/scanner_test.go
@@ -153,3 +153,28 @@ func TestNewlineStacking(t *testing.T) {
 
 	require.Equal(t, expected, tokens)
 }
+
+func TestEmojiInStrings(t *testing.T) {
+	source := `
+	say("🇺🇦" + "❤️!")
+	`
+
+	s := scanner.New(strings.NewReader(source))
+
+	tokens, err := s.Scan()
+	require.NoError(t, err)
+
+	expected := []token.Token{
+		token.Simple(token.EOL, token.NewLoc(0, 0)),
+		token.New(token.Ident, token.NewLoc(1, 1), "say"),
+		token.Simple(token.LParen, token.NewLoc(1, 4)),
+		token.New(token.String, token.NewLoc(1, 5), "🇺🇦"),
+		token.Simple(token.Plus, token.NewLoc(1, 10)),
+		token.New(token.String, token.NewLoc(1, 12), "❤️!"),
+		token.Simple(token.RParen, token.NewLoc(1, 17)),
+		token.Simple(token.EOL, token.NewLoc(1, 18)),
+		token.Simple(token.EOF, token.NewLoc(2, 1)),
+	}
+
+	require.Equal(t, expected, tokens)
+}