summaryrefslogtreecommitdiffstats
path: root/tests/snippets/java
diff options
context:
space:
mode:
Diffstat (limited to 'tests/snippets/java')
-rw-r--r--tests/snippets/java/test_default.txt36
-rw-r--r--tests/snippets/java/test_enhanced_for.txt22
-rw-r--r--tests/snippets/java/test_multiline_string.txt185
-rw-r--r--tests/snippets/java/test_multiline_string_only.txt46
-rw-r--r--tests/snippets/java/test_numeric_literals.txt34
-rw-r--r--tests/snippets/java/test_record.txt67
6 files changed, 390 insertions, 0 deletions
diff --git a/tests/snippets/java/test_default.txt b/tests/snippets/java/test_default.txt
new file mode 100644
index 0000000..f24fa42
--- /dev/null
+++ b/tests/snippets/java/test_default.txt
@@ -0,0 +1,36 @@
+---input---
+switch (x) {
+ case 1: break;
+ default: break;
+}
+
+---tokens---
+'switch' Keyword
+' ' Text.Whitespace
+'(' Punctuation
+'x' Name
+')' Punctuation
+' ' Text.Whitespace
+'{' Punctuation
+'\n' Text.Whitespace
+
+' ' Text.Whitespace
+'case' Keyword
+' ' Text.Whitespace
+'1' Literal.Number.Integer
+':' Punctuation
+' ' Text.Whitespace
+'break' Keyword
+';' Punctuation
+'\n' Text.Whitespace
+
+' ' Text.Whitespace
+'default' Keyword
+':' Punctuation
+' ' Text.Whitespace
+'break' Keyword
+';' Punctuation
+'\n' Text.Whitespace
+
+'}' Punctuation
+'\n' Text.Whitespace
diff --git a/tests/snippets/java/test_enhanced_for.txt b/tests/snippets/java/test_enhanced_for.txt
new file mode 100644
index 0000000..d2a8091
--- /dev/null
+++ b/tests/snippets/java/test_enhanced_for.txt
@@ -0,0 +1,22 @@
+---input---
+label:
+for(String var2: var1) {}
+
+---tokens---
+'label' Name.Label
+':' Punctuation
+'\n' Text.Whitespace
+
+'for' Keyword
+'(' Punctuation
+'String' Name
+' ' Text.Whitespace
+'var2' Name
+':' Punctuation
+' ' Text.Whitespace
+'var1' Name
+')' Punctuation
+' ' Text.Whitespace
+'{' Punctuation
+'}' Punctuation
+'\n' Text.Whitespace
diff --git a/tests/snippets/java/test_multiline_string.txt b/tests/snippets/java/test_multiline_string.txt
new file mode 100644
index 0000000..c7325b5
--- /dev/null
+++ b/tests/snippets/java/test_multiline_string.txt
@@ -0,0 +1,185 @@
+---input---
+public class Quine {
+ public static void main(String[] args) {
+ String textBlockQuotes = new String(new char[]{'"', '"', '"'});
+ char newLine = 10;
+ String teststring = "test123\n";
+ String source = """
+public class Quine {
+ public static void main(String[] args) {
+ String textBlockQuotes = new String(new char[]{'"', '"', '"'});
+ char newLine = 10;
+ String teststringinside = "hello my name is...\n\r";
+ String source = %s;
+ System.out.println(source.formatted(textBlockQuotes + newLine + source + textBlockQuotes));
+ }
+}
+""";
+ System.out.println(source.formatted(textBlockQuotes + newLine + source + textBlockQuotes));
+ String teststring2 = "Hello\n";
+ }
+}
+
+---tokens---
+'public' Keyword.Declaration
+' ' Text.Whitespace
+'class' Keyword.Declaration
+' ' Text
+'Quine' Name.Class
+' ' Text.Whitespace
+'{' Punctuation
+'\n' Text.Whitespace
+
+'\t' Text.Whitespace
+'public' Keyword.Declaration
+' ' Text.Whitespace
+'static' Keyword.Declaration
+' ' Text.Whitespace
+'void' Keyword.Type
+' ' Text.Whitespace
+'main' Name.Function
+'(' Punctuation
+'String' Name
+'[' Operator
+']' Operator
+' ' Text.Whitespace
+'args' Name
+')' Punctuation
+' ' Text.Whitespace
+'{' Punctuation
+'\n' Text.Whitespace
+
+'\t\t' Text.Whitespace
+'String' Name
+' ' Text.Whitespace
+'textBlockQuotes' Name
+' ' Text.Whitespace
+'=' Operator
+' ' Text.Whitespace
+'new' Keyword
+' ' Text.Whitespace
+'String' Name
+'(' Punctuation
+'new' Keyword
+' ' Text.Whitespace
+'char' Keyword.Type
+'[' Operator
+']' Operator
+'{' Punctuation
+'\'"\'' Literal.String.Char
+',' Punctuation
+' ' Text.Whitespace
+'\'"\'' Literal.String.Char
+',' Punctuation
+' ' Text.Whitespace
+'\'"\'' Literal.String.Char
+'}' Punctuation
+')' Punctuation
+';' Punctuation
+'\n' Text.Whitespace
+
+'\t\t' Text.Whitespace
+'char' Keyword.Type
+' ' Text.Whitespace
+'newLine' Name
+' ' Text.Whitespace
+'=' Operator
+' ' Text.Whitespace
+'10' Literal.Number.Integer
+';' Punctuation
+'\n' Text.Whitespace
+
+'\t\t' Text.Whitespace
+'String' Name
+' ' Text.Whitespace
+'teststring' Name
+' ' Text.Whitespace
+'=' Operator
+' ' Text.Whitespace
+'"' Literal.String
+'test123' Literal.String
+'\\' Literal.String
+'n' Literal.String
+'"' Literal.String
+';' Punctuation
+'\n' Text.Whitespace
+
+'\t ' Text.Whitespace
+'String' Name
+' ' Text.Whitespace
+'source' Name
+' ' Text.Whitespace
+'=' Operator
+' ' Text.Whitespace
+'"""\n' Literal.String
+
+"public class Quine {\n\tpublic static void main(String[] args) {\n\t\tString textBlockQuotes = new String(new char[]{'" Literal.String
+'"' Literal.String
+"', '" Literal.String
+'"' Literal.String
+"', '" Literal.String
+'"' Literal.String
+"'});\n\t\tchar newLine = 10;\n\t\tString teststringinside = " Literal.String
+'"' Literal.String
+'hello my name is...' Literal.String
+'\\' Literal.String
+'n' Literal.String
+'\\' Literal.String
+'r' Literal.String
+'"' Literal.String
+';\n\t\tString source = %s;\n\t\tSystem.out.println(source.formatted(textBlockQuotes + newLine + source + textBlockQuotes));\n\t}\n}\n' Literal.String
+
+'"""' Literal.String
+';' Punctuation
+'\n' Text.Whitespace
+
+' ' Text.Whitespace
+'System' Name
+'.' Punctuation
+'out' Name.Attribute
+'.' Punctuation
+'println' Name.Attribute
+'(' Punctuation
+'source' Name
+'.' Punctuation
+'formatted' Name.Attribute
+'(' Punctuation
+'textBlockQuotes' Name
+' ' Text.Whitespace
+'+' Operator
+' ' Text.Whitespace
+'newLine' Name
+' ' Text.Whitespace
+'+' Operator
+' ' Text.Whitespace
+'source' Name
+' ' Text.Whitespace
+'+' Operator
+' ' Text.Whitespace
+'textBlockQuotes' Name
+')' Punctuation
+')' Punctuation
+';' Punctuation
+'\n' Text.Whitespace
+
+'\t' Text.Whitespace
+'String' Name
+' ' Text.Whitespace
+'teststring2' Name
+' ' Text.Whitespace
+'=' Operator
+' ' Text.Whitespace
+'"' Literal.String
+'Hello' Literal.String
+'\\' Literal.String
+'n' Literal.String
+'"' Literal.String
+';' Punctuation
+'\n' Text.Whitespace
+
+'\t' Text.Whitespace
+'}' Punctuation
+'\n' Text.Whitespace
+
+'}' Punctuation
+'\n' Text.Whitespace
diff --git a/tests/snippets/java/test_multiline_string_only.txt b/tests/snippets/java/test_multiline_string_only.txt
new file mode 100644
index 0000000..09d54ad
--- /dev/null
+++ b/tests/snippets/java/test_multiline_string_only.txt
@@ -0,0 +1,46 @@
+---input---
+ String source = """
+public class Quine {
+ public static void main(String[] args) {
+ String textBlockQuotes = new String(new char[]{'"', '"', '"'});
+ char newLine = 10;
+ String teststringinside = "hello my name is...\n\r";
+ String source = %s;
+ System.out.println(source.formatted(textBlockQuotes + newLine + source + textBlockQuotes));
+ }
+}
+""";
+
+
+---tokens---
+'\t ' Text.Whitespace
+'String' Name
+' ' Text.Whitespace
+'source' Name
+' ' Text.Whitespace
+'=' Operator
+' ' Text.Whitespace
+'"""\n' Literal.String
+
+"public class Quine {\n\tpublic static void main(String[] args) {\n\t\tString textBlockQuotes = new String(new char[]{'" Literal.String
+'"' Literal.String
+"', '" Literal.String
+'"' Literal.String
+"', '" Literal.String
+'"' Literal.String
+"'});\n\t\tchar newLine = 10;\n\t\tString teststringinside = " Literal.String
+'"' Literal.String
+'hello my name is...' Literal.String
+'\\' Literal.String
+'n' Literal.String
+'\\' Literal.String
+'r' Literal.String
+'"' Literal.String
+';\n\t\tString source = %s;\n\t\tSystem.out.println(source.formatted(textBlockQuotes + newLine + source + textBlockQuotes));\n\t}\n}\n' Literal.String
+
+'"""' Literal.String
+';' Punctuation
+'\n' Text.Whitespace
+
+' ' Text.Whitespace
+'\n' Text.Whitespace
diff --git a/tests/snippets/java/test_numeric_literals.txt b/tests/snippets/java/test_numeric_literals.txt
new file mode 100644
index 0000000..1dc933d
--- /dev/null
+++ b/tests/snippets/java/test_numeric_literals.txt
@@ -0,0 +1,34 @@
+---input---
+0 5L 9__542_72l 0xbEEf 0X9_A 0_35 01 0b0___101_0 0. .7_17F 3e-1_3d 1f 6_01.9e+3 0x.1Fp3 0XEP8D
+
+---tokens---
+'0' Literal.Number.Integer
+' ' Text.Whitespace
+'5L' Literal.Number.Integer
+' ' Text.Whitespace
+'9__542_72l' Literal.Number.Integer
+' ' Text.Whitespace
+'0xbEEf' Literal.Number.Hex
+' ' Text.Whitespace
+'0X9_A' Literal.Number.Hex
+' ' Text.Whitespace
+'0_35' Literal.Number.Oct
+' ' Text.Whitespace
+'01' Literal.Number.Oct
+' ' Text.Whitespace
+'0b0___101_0' Literal.Number.Bin
+' ' Text.Whitespace
+'0.' Literal.Number.Float
+' ' Text.Whitespace
+'.7_17F' Literal.Number.Float
+' ' Text.Whitespace
+'3e-1_3d' Literal.Number.Float
+' ' Text.Whitespace
+'1f' Literal.Number.Float
+' ' Text.Whitespace
+'6_01.9e+3' Literal.Number.Float
+' ' Text.Whitespace
+'0x.1Fp3' Literal.Number.Float
+' ' Text.Whitespace
+'0XEP8D' Literal.Number.Float
+'\n' Text.Whitespace
diff --git a/tests/snippets/java/test_record.txt b/tests/snippets/java/test_record.txt
new file mode 100644
index 0000000..f4ca08b
--- /dev/null
+++ b/tests/snippets/java/test_record.txt
@@ -0,0 +1,67 @@
+---input---
+public record RecordTest() {}
+public static record RecordTest() {}
+record Person(String firstName, String lastName) {}
+String[] record = csvReader.getValues();
+
+
+---tokens---
+'public' Keyword.Declaration
+' ' Text.Whitespace
+'record' Keyword.Declaration
+' ' Text
+'RecordTest' Name.Class
+'(' Punctuation
+')' Punctuation
+' ' Text.Whitespace
+'{' Punctuation
+'}' Punctuation
+'\n' Text.Whitespace
+
+'public' Keyword.Declaration
+' ' Text.Whitespace
+'static' Keyword.Declaration
+' ' Text.Whitespace
+'record' Keyword.Declaration
+' ' Text
+'RecordTest' Name.Class
+'(' Punctuation
+')' Punctuation
+' ' Text.Whitespace
+'{' Punctuation
+'}' Punctuation
+'\n' Text.Whitespace
+
+'record' Keyword.Declaration
+' ' Text
+'Person' Name.Class
+'(' Punctuation
+'String' Name
+' ' Text.Whitespace
+'firstName' Name
+',' Punctuation
+' ' Text.Whitespace
+'String' Name
+' ' Text.Whitespace
+'lastName' Name
+')' Punctuation
+' ' Text.Whitespace
+'{' Punctuation
+'}' Punctuation
+'\n' Text.Whitespace
+
+'String' Name
+'[' Operator
+']' Operator
+' ' Text.Whitespace
+'record' Name
+' ' Text.Whitespace
+'=' Operator
+' ' Text.Whitespace
+'csvReader' Name
+'.' Punctuation
+'getValues' Name.Attribute
+'(' Punctuation
+')' Punctuation
+';' Punctuation
+'\n' Text.Whitespace