Skip to content

Commit

Permalink
test: Add tests validating errors by unicode in identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
xpyctumo committed Jan 16, 2025
1 parent 5aaa18d commit ad4cac4
Show file tree
Hide file tree
Showing 10 changed files with 131 additions and 0 deletions.
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@
"src/grammar/test/items-asm-funs.tact",
"src/grammar/test-asm/*.tact",
"src/grammar/test-failed/funcid-*.tact",
"src/grammar/test-failed/*unicode*.tact",
"src/grammar/next/grammar.gg",
"src/grammar/next/grammar.ts",
"src/imports/stdlib.ts",
Expand Down
57 changes: 57 additions & 0 deletions src/grammar/next/__snapshots__/grammar.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ Line 4, col 1:
"
`;

exports[`grammar should fail const-unicode 1`] = `
"<unknown>:1:7: Expected identifier
Line 1, col 7:
> 1 | const Константа: Int = 42;
^
"
`;

exports[`grammar should fail const-virtual 1`] = `
"<unknown>:4:1: Module-level constants do not support attributes
Line 4, col 1:
Expand Down Expand Up @@ -168,6 +176,14 @@ Line 1, col 19:
"
`;

exports[`grammar should fail contract-unicode 1`] = `
"<unknown>:1:10: Expected identifier
Line 1, col 10:
> 1 | contract Контракт {}
^
"
`;

exports[`grammar should fail contract-with-imports 1`] = `
"<unknown>:6:1: Expected "@interface", "@name", "abstract", "asm", "const", "contract", "extends", "fun", "get", "inline", "message", "mutates", "override", "primitive", "struct", "trait", or "virtual"
Line 6, col 1:
Expand Down Expand Up @@ -208,6 +224,15 @@ Line 2, col 24:
"
`;

exports[`grammar should fail fun-unicode 1`] = `
"<unknown>:1:5: Expected identifier
Line 1, col 5:
> 1 | fun ФункциЯ() {
^
2 | return "";
"
`;

exports[`grammar should fail funcid-native-fun-arith-operator 1`] = `
"<unknown>:1:7: Reserved FunC identifier
Line 1, col 7:
Expand Down Expand Up @@ -679,6 +704,22 @@ Line 2, col 12:
"
`;

exports[`grammar should fail message-unicode 1`] = `
"<unknown>:1:9: Expected "(" or capitalized identifier
Line 1, col 9:
> 1 | message Сообщение {}
^
"
`;

exports[`grammar should fail message-with-opcode-unicode 1`] = `
"<unknown>:1:21: Expected capitalized identifier
Line 1, col 21:
> 1 | message(0x7362d09c) Сообщение {}
^
"
`;

exports[`grammar should fail struct-double-semicolon 1`] = `
"<unknown>:2:19: Expected "}" or identifier
Line 2, col 19:
Expand Down Expand Up @@ -709,6 +750,14 @@ Line 2, col 24:
"
`;

exports[`grammar should fail struct-unicode 1`] = `
"<unknown>:1:8: Expected capitalized identifier
Line 1, col 8:
> 1 | struct Структура { }
^
"
`;

exports[`grammar should fail trait-const-abstract-with-initializer 1`] = `
"<unknown>:5:3: Non-abstract constant has abstract modifier
Line 5, col 3:
Expand Down Expand Up @@ -757,6 +806,14 @@ Line 1, col 16:
"
`;

exports[`grammar should fail trait-unicode 1`] = `
"<unknown>:1:7: Expected identifier
Line 1, col 7:
> 1 | trait ОперацияД { }
^
"
`;

exports[`grammar should fail type-ident-msg-should-be-capitalized 1`] = `
"<unknown>:1:14: Expected capitalized identifier
Line 1, col 14:
Expand Down
64 changes: 64 additions & 0 deletions src/grammar/prev/__snapshots__/grammar.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ Line 4, col 1:
"
`;

exports[`grammar should fail const-unicode 1`] = `
"<unknown>:1:7: Expected "_", "A".."Z", or "a".."z"

Line 1, col 7:
> 1 | const Константа: Int = 42;
^
"
`;

exports[`grammar should fail const-virtual 1`] = `
"<unknown>:4:1: Module-level constants do not support attributes
Line 4, col 1:
Expand Down Expand Up @@ -172,6 +181,15 @@ Line 1, col 19:
"
`;

exports[`grammar should fail contract-unicode 1`] = `
"<unknown>:1:10: Expected "_", "A".."Z", or "a".."z"

Line 1, col 10:
> 1 | contract Контракт {}
^
"
`;

exports[`grammar should fail contract-with-imports 1`] = `
"<unknown>:6:1: Expected end of input, "trait", "contract", "message", "struct", "const", "@name", "asm", "fun", or "primitive"

Expand Down Expand Up @@ -213,6 +231,16 @@ Line 2, col 24:
"
`;

exports[`grammar should fail fun-unicode 1`] = `
"<unknown>:1:5: Expected "_", "A".."Z", or "a".."z"

Line 1, col 5:
> 1 | fun ФункциЯ() {
^
2 | return "";
"
`;

exports[`grammar should fail funcid-native-fun-arith-operator 1`] = `
"<unknown>:1:7: Expected not a funcInvalidId or "\`"

Expand Down Expand Up @@ -724,6 +752,24 @@ Line 2, col 13:
"
`;

exports[`grammar should fail message-unicode 1`] = `
"<unknown>:1:9: Expected "A".."Z" or "("

Line 1, col 9:
> 1 | message Сообщение {}
^
"
`;

exports[`grammar should fail message-with-opcode-unicode 1`] = `
"<unknown>:1:21: Expected "A".."Z"

Line 1, col 21:
> 1 | message(0x7362d09c) Сообщение {}
^
"
`;

exports[`grammar should fail struct-double-semicolon 1`] = `
"<unknown>:2:19: Expected "}"

Expand Down Expand Up @@ -757,6 +803,15 @@ Line 2, col 24:
"
`;

exports[`grammar should fail struct-unicode 1`] = `
"<unknown>:1:8: Expected "A".."Z"

Line 1, col 8:
> 1 | struct Структура { }
^
"
`;

exports[`grammar should fail trait-const-abstract-with-initializer 1`] = `
"<unknown>:5:3: Non-abstract constant has abstract modifier
Line 5, col 3:
Expand Down Expand Up @@ -807,6 +862,15 @@ Line 1, col 16:
"
`;

exports[`grammar should fail trait-unicode 1`] = `
"<unknown>:1:7: Expected "_", "A".."Z", or "a".."z"

Line 1, col 7:
> 1 | trait ОперацияД { }
^
"
`;

exports[`grammar should fail type-ident-msg-should-be-capitalized 1`] = `
"<unknown>:1:14: Expected "A".."Z"

Expand Down
1 change: 1 addition & 0 deletions src/grammar/test-failed/const-unicode.tact
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
const Константа: Int = 42;
1 change: 1 addition & 0 deletions src/grammar/test-failed/contract-unicode.tact
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
contract Контракт {}
3 changes: 3 additions & 0 deletions src/grammar/test-failed/fun-unicode.tact
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fun ФункциЯ() {
return "";
}
1 change: 1 addition & 0 deletions src/grammar/test-failed/message-unicode.tact
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
message Сообщение {}
1 change: 1 addition & 0 deletions src/grammar/test-failed/message-with-opcode-unicode.tact
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
message(0x7362d09c) Сообщение {}
1 change: 1 addition & 0 deletions src/grammar/test-failed/struct-unicode.tact
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
struct Структура { }
1 change: 1 addition & 0 deletions src/grammar/test-failed/trait-unicode.tact
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
trait ОперацияД { }

0 comments on commit ad4cac4

Please sign in to comment.