diff --git a/migrator/src/com/ohos/migrator/staticTS/parser/StaticTSLexer.g4 b/migrator/src/com/ohos/migrator/staticTS/parser/StaticTSLexer.g4 index b0ba23ccce21fcc1f05f183e268848d70dc29ae6..f5ada6b17abc4c692f0a8055dae5e2963cbb3359 100644 --- a/migrator/src/com/ohos/migrator/staticTS/parser/StaticTSLexer.g4 +++ b/migrator/src/com/ohos/migrator/staticTS/parser/StaticTSLexer.g4 @@ -265,6 +265,7 @@ fragment ExponentPart fragment IdentifierPart : [\p{ID_Continue}] | '$' + | [\u200C\u200D] | '\\' UnicodeEscapeSequence ; diff --git a/migrator/test/staticTS/CTS/01.introduction/.gitkeep b/migrator/test/staticTS/CTS/01.introduction/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/migrator/test/staticTS/CTS/02.lexical_elements/01.comments/multi_line_comment.sts b/migrator/test/staticTS/CTS/02.lexical_elements/01.comments/multi_line_comment.sts new file mode 100644 index 0000000000000000000000000000000000000000..b8179d84fd0f29f468ec777660bf8d4cae117d2c --- /dev/null +++ b/migrator/test/staticTS/CTS/02.lexical_elements/01.comments/multi_line_comment.sts @@ -0,0 +1,24 @@ +/*--- +desc: Multi-line comments +---*/ + +/**/ + +/* + block +*/ + +/* + /* + nested block + */ +*/ + +/* + // nested one-liner +*/ + +// /* + +// */ +function main(): void {} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/02.lexical_elements/01.comments/one_line_comment.sts b/migrator/test/staticTS/CTS/02.lexical_elements/01.comments/one_line_comment.sts new file mode 100644 index 0000000000000000000000000000000000000000..979c26029ff4330fe3040d4b2876b6d28b9cffd1 --- /dev/null +++ b/migrator/test/staticTS/CTS/02.lexical_elements/01.comments/one_line_comment.sts @@ -0,0 +1,6 @@ +/*--- +desc: Line comment +---*/ + +// one-liner +function main(): void {} diff --git a/migrator/test/staticTS/CTS/02.lexical_elements/02.tokens/01.whitespaces/.gitattributes b/migrator/test/staticTS/CTS/02.lexical_elements/02.tokens/01.whitespaces/.gitattributes new file mode 100644 index 0000000000000000000000000000000000000000..460fe17b80cc29a4dd811842c7f7e7441b50b505 --- /dev/null +++ b/migrator/test/staticTS/CTS/02.lexical_elements/02.tokens/01.whitespaces/.gitattributes @@ -0,0 +1 @@ +whitespaces.sts binary diff --git a/migrator/test/staticTS/CTS/02.lexical_elements/02.tokens/01.whitespaces/whitespaces.sts b/migrator/test/staticTS/CTS/02.lexical_elements/02.tokens/01.whitespaces/whitespaces.sts new file mode 100644 index 0000000000000000000000000000000000000000..ee8b905a5d3f52864861a906e56c1fcc736ca58a --- /dev/null +++ b/migrator/test/staticTS/CTS/02.lexical_elements/02.tokens/01.whitespaces/whitespaces.sts @@ -0,0 +1,9 @@ +/*--- +desc: Whitespaces +---*/ +// PLEASE DO NOT EDIT! +// THIS FILE CONSTRUCTED WITH WHITESPACES FROM 2.2.1 +// \U+0020 function \U+0009 main ( \U+000B ) : \U+000C void \U+00A0 { \U+FEFF } + + function main( ): void +{} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/02.lexical_elements/02.tokens/02.line_separators/.gitattributes b/migrator/test/staticTS/CTS/02.lexical_elements/02.tokens/02.line_separators/.gitattributes new file mode 100644 index 0000000000000000000000000000000000000000..c8e18f51d374084eb57db16e382017a72491c306 --- /dev/null +++ b/migrator/test/staticTS/CTS/02.lexical_elements/02.tokens/02.line_separators/.gitattributes @@ -0,0 +1 @@ +line_separators.sts binary diff --git a/migrator/test/staticTS/CTS/02.lexical_elements/02.tokens/02.line_separators/line_separators.sts b/migrator/test/staticTS/CTS/02.lexical_elements/02.tokens/02.line_separators/line_separators.sts new file mode 100644 index 0000000000000000000000000000000000000000..4ad07c8069b9275f7223548611f11cfe55496d58 --- /dev/null +++ b/migrator/test/staticTS/CTS/02.lexical_elements/02.tokens/02.line_separators/line_separators.sts @@ -0,0 +1,17 @@ +/*--- +desc: Line separators +---*/ + +// PLEASE DO NOT EDIT! +// THIS FILE IS CONSTRUCTED WITH LINE SEPARATORS FROM 2.2.2 +// function main(): void { +// \U+000A +// \U+000D +// \U+000D \U+000A +// \U+2028 +// \U+2029 +//} + +function main(): void { + +

} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/02.lexical_elements/03.identifiers/identifiers.sts b/migrator/test/staticTS/CTS/02.lexical_elements/03.identifiers/identifiers.sts new file mode 100644 index 0000000000000000000000000000000000000000..b385e2e2c9fb707de903dda4a3bc05c736c89042 --- /dev/null +++ b/migrator/test/staticTS/CTS/02.lexical_elements/03.identifiers/identifiers.sts @@ -0,0 +1,7 @@ +/*--- +desc: Identifiers +---*/ + +let simple_ident: int = 1; +let _underscore_ident: int = 2; +let $dollar_ident: int = 3; diff --git a/migrator/test/staticTS/CTS/02.lexical_elements/03.identifiers/identifiers_continue.sts b/migrator/test/staticTS/CTS/02.lexical_elements/03.identifiers/identifiers_continue.sts new file mode 100644 index 0000000000000000000000000000000000000000..03df7e76d9d1a36e928a904b64e9734cc7ce8ffa --- /dev/null +++ b/migrator/test/staticTS/CTS/02.lexical_elements/03.identifiers/identifiers_continue.sts @@ -0,0 +1,9 @@ +{% for ident in continue %} +/*--- +desc: Other character {{.ident}} should be Unicode code point with the Unicode property "ID_Continue" +---*/ + +let X{{.ident}} = 0; +function main(): void {} + +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/02.lexical_elements/03.identifiers/identifiers_dollar.sts b/migrator/test/staticTS/CTS/02.lexical_elements/03.identifiers/identifiers_dollar.sts new file mode 100644 index 0000000000000000000000000000000000000000..57027d41292170d61f872a6623e866fa83cb8610 --- /dev/null +++ b/migrator/test/staticTS/CTS/02.lexical_elements/03.identifiers/identifiers_dollar.sts @@ -0,0 +1,14 @@ +{% for word1 in words %} + {% for word2 in words %} + +/*--- +desc: Identifiers with '$' in the middle +params: {{.word1}}${{.word2}} +---*/ + +let {{.word1}}${{.word2}} = 1; + +function {{.word2}}${{.word1}}(): void {} + + {% endfor %} +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/02.lexical_elements/03.identifiers/identifiers_start.sts b/migrator/test/staticTS/CTS/02.lexical_elements/03.identifiers/identifiers_start.sts new file mode 100644 index 0000000000000000000000000000000000000000..806e31a4bece20ecad6f254464c10aa8a12f204a --- /dev/null +++ b/migrator/test/staticTS/CTS/02.lexical_elements/03.identifiers/identifiers_start.sts @@ -0,0 +1,9 @@ +{% for ident in start %} +/*--- +desc: First character {{.ident}} should be Unicode code point with the Unicode property "ID_Start" +---*/ + +let {{.ident}} = 0; +function main(): void {} + +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/02.lexical_elements/03.identifiers/list.continue.yaml b/migrator/test/staticTS/CTS/02.lexical_elements/03.identifiers/list.continue.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d65bb1f92b0447b3089fe24506fe3a1948c5a742 --- /dev/null +++ b/migrator/test/staticTS/CTS/02.lexical_elements/03.identifiers/list.continue.yaml @@ -0,0 +1,4 @@ +--- +- a\u0024 +- a‌\u0024 # Zero Width Non-Joiner (U+200C) between a and \u0024 +- a‍\u0024 # Zero Width Joiner (U+200D) between a and \u0024 \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/02.lexical_elements/03.identifiers/list.start.yaml b/migrator/test/staticTS/CTS/02.lexical_elements/03.identifiers/list.start.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2e39d0bc29acb6aceb7c8ca491da10db9c112bd1 --- /dev/null +++ b/migrator/test/staticTS/CTS/02.lexical_elements/03.identifiers/list.start.yaml @@ -0,0 +1,14 @@ +--- # List of possible ident start symbols +- $ +- _ +- \\u0024 +- q +- Q +- я +- Я +- Î +- î +- ʻ # Modifier Letter Turned Comma +- ⅲ # Small Roman Numeral Three +- ℘ # Script Capital P +- ǂ # Latin Letter Alveolar Click diff --git a/migrator/test/staticTS/CTS/02.lexical_elements/03.identifiers/list.words.yaml b/migrator/test/staticTS/CTS/02.lexical_elements/03.identifiers/list.words.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2a6474bacde741359bcf603797d3dd948db61242 --- /dev/null +++ b/migrator/test/staticTS/CTS/02.lexical_elements/03.identifiers/list.words.yaml @@ -0,0 +1,7 @@ +--- # List of simple words that can be used as identifiers +- "yes" +- "no" +- x +- xx +- y +- identifier diff --git a/migrator/test/staticTS/CTS/02.lexical_elements/04.keywords/list.keywords.yaml b/migrator/test/staticTS/CTS/02.lexical_elements/04.keywords/list.keywords.yaml new file mode 100644 index 0000000000000000000000000000000000000000..478aea8a4d30c97c83f0aee4250db98159d9ca58 --- /dev/null +++ b/migrator/test/staticTS/CTS/02.lexical_elements/04.keywords/list.keywords.yaml @@ -0,0 +1,40 @@ +--- # List of keywords +- abstract +- as +- assert +- break +- case +- class +- const +- constructor +- continue +- default +- do +- else +- enum +- export +- extends +- "false" +- for +- function +- if +- implements +- import +- interface +- let +- new +- "null" +- of +- open +- override +- package +- private +- protected +- public +- return +- static +- super +- switch +- this +- "true" +- while diff --git a/migrator/test/staticTS/CTS/02.lexical_elements/04.keywords/list.types.yaml b/migrator/test/staticTS/CTS/02.lexical_elements/04.keywords/list.types.yaml new file mode 100644 index 0000000000000000000000000000000000000000..740870dcc236ad94bd336a1238a4a9445393a70b --- /dev/null +++ b/migrator/test/staticTS/CTS/02.lexical_elements/04.keywords/list.types.yaml @@ -0,0 +1,11 @@ +--- # List of keywords denoting predefined data types +- boolean +- byte +- char +- double +- float +- int +- long +- short +- string +- void diff --git a/migrator/test/staticTS/CTS/02.lexical_elements/04.keywords/n.keywords.sts b/migrator/test/staticTS/CTS/02.lexical_elements/04.keywords/n.keywords.sts new file mode 100644 index 0000000000000000000000000000000000000000..ccff91630794fb9c6d5748424d74d5724e530577 --- /dev/null +++ b/migrator/test/staticTS/CTS/02.lexical_elements/04.keywords/n.keywords.sts @@ -0,0 +1,11 @@ +{% for kwd in keywords %} + +/*--- +desc: The {{.kwd}} is reserved and may not be used as identifiers +params: {{.kwd}} +---*/ + +let {{.kwd}} = 0; +function main(): void {} + +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/02.lexical_elements/04.keywords/n.types.sts b/migrator/test/staticTS/CTS/02.lexical_elements/04.keywords/n.types.sts new file mode 100644 index 0000000000000000000000000000000000000000..729d4d8b07aa54f437243b8da2269876dd587df4 --- /dev/null +++ b/migrator/test/staticTS/CTS/02.lexical_elements/04.keywords/n.types.sts @@ -0,0 +1,11 @@ +{% for type in types %} + +/*--- +desc: The keyword {{.type}} denotes predefined type name and may not be used as identifier +params: {{.type}} +---*/ + +let {{.type}} = 0; +function main(): void {} + +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/02.lexical_elements/05.operators_and_punctuation/tbd.sts b/migrator/test/staticTS/CTS/02.lexical_elements/05.operators_and_punctuation/tbd.sts new file mode 100644 index 0000000000000000000000000000000000000000..c0a645b3704f24b1a1a0f58ea7e19a82fcef3438 --- /dev/null +++ b/migrator/test/staticTS/CTS/02.lexical_elements/05.operators_and_punctuation/tbd.sts @@ -0,0 +1,3 @@ +/*--- +desc: Operators and punctuation +---*/ \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/01.integer_literals/int_literals.sts b/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/01.integer_literals/int_literals.sts new file mode 100644 index 0000000000000000000000000000000000000000..a9feb52b57e1390b63fafa6d1d1015c822740d13 --- /dev/null +++ b/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/01.integer_literals/int_literals.sts @@ -0,0 +1,11 @@ +{% for lit in int_literals %} + +/*--- +desc: Correct integer literals with bases 16, 10, 8 and 2 +params: {{.lit}} +---*/ + +let x = {{.lit}}; +function main(): void {} + +{% endfor %} diff --git a/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/01.integer_literals/list.bad_int_literals.yaml b/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/01.integer_literals/list.bad_int_literals.yaml new file mode 100644 index 0000000000000000000000000000000000000000..32b9018776411e5fc22c2a12bf998a67e23d4e97 --- /dev/null +++ b/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/01.integer_literals/list.bad_int_literals.yaml @@ -0,0 +1,4 @@ +--- # List of invalid integer literals +- 0x +- 0o +- 0b diff --git a/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/01.integer_literals/list.int_literals.yaml b/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/01.integer_literals/list.int_literals.yaml new file mode 100644 index 0000000000000000000000000000000000000000..fc70bb74e0ae484dae55603624a1e2ed4bbf7b03 --- /dev/null +++ b/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/01.integer_literals/list.int_literals.yaml @@ -0,0 +1,5 @@ +--- # List of valid integer literals +- 153 # Decimal literal +- 0xDAD # Hex literal +- 0o777 # Octal literal +- 0b101 # Binary literal diff --git a/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/01.integer_literals/n.bad_int_literals.sts b/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/01.integer_literals/n.bad_int_literals.sts new file mode 100644 index 0000000000000000000000000000000000000000..54bc2584f5fc21db90b6f1999f8ceae71c8f8112 --- /dev/null +++ b/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/01.integer_literals/n.bad_int_literals.sts @@ -0,0 +1,11 @@ +{% for lit in bad_int_literals %} + +/*--- +desc: Incorrect integer literals +params: {{.lit}} +---*/ + +let x = {{.lit}}; +function main(): void {} + +{% endfor %} diff --git a/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/02.floating_point_literals/float_literals.sts b/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/02.floating_point_literals/float_literals.sts new file mode 100644 index 0000000000000000000000000000000000000000..99e1f69fd8f45f5c75a2da017f97e27fa87aabc6 --- /dev/null +++ b/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/02.floating_point_literals/float_literals.sts @@ -0,0 +1,12 @@ +{% for f in float_literals %} + +/*--- +desc: Floating-point literals +params: {{.f}} +---*/ + +let x = {{.f}}; + +function main(): void {} + +{% endfor %} diff --git a/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/02.floating_point_literals/list.float_literals.yaml b/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/02.floating_point_literals/list.float_literals.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9a54008a8f4d6ef2f6fc765d8cdced915af6b8ff --- /dev/null +++ b/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/02.floating_point_literals/list.float_literals.yaml @@ -0,0 +1,36 @@ +--- # List of valid float literals + +- 0.0 +- 0. + +- 0.e1 +- 0.0e1 +- 0.0e+1 +- 0.0e-1 +- 0.0e-11 + +- 0.E1 +- 0.0E1 +- 0.0E+1 +- 0.0E-1 +- 0.0E-11 + +- .0 +- .0e0 +- .0e+1 +- .0e-1 +- .0e11 + +- .0 +- .0E0 +- .0E+1 +- .0E-1 +- .0E11 + +- 1e0 +- 1e-1 +- 1e+1 + +- 1E0 +- 1E-1 +- 1E+1 diff --git a/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/03.boolean_literals/boolean_literals.sts b/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/03.boolean_literals/boolean_literals.sts new file mode 100644 index 0000000000000000000000000000000000000000..1cf65a0219687d4182efbe6029a585f1d4a0f5f4 --- /dev/null +++ b/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/03.boolean_literals/boolean_literals.sts @@ -0,0 +1,7 @@ +/*--- +desc: Boolean literals +---*/ + +let t = true; +let f = false; +function main(): void {} diff --git a/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/04.string_literals/string_literals.sts b/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/04.string_literals/string_literals.sts new file mode 100644 index 0000000000000000000000000000000000000000..f5adb0bcb40192055393666300ddca8761e05819 --- /dev/null +++ b/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/04.string_literals/string_literals.sts @@ -0,0 +1,6 @@ +/*--- +desc: String literals +---*/ + +let x = "hello"; +function main(): void {} diff --git a/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/04.string_literals/tbd.multiline_string_literals.sts b/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/04.string_literals/tbd.multiline_string_literals.sts new file mode 100644 index 0000000000000000000000000000000000000000..f2299c8987b27fa6ec6bf6838005cde68a235ad4 --- /dev/null +++ b/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/04.string_literals/tbd.multiline_string_literals.sts @@ -0,0 +1,3 @@ +/*--- +desc: Multiline string literals +---*/ \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/04.string_literals/tbd.string_literals_escapes_n_continuation.sts b/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/04.string_literals/tbd.string_literals_escapes_n_continuation.sts new file mode 100644 index 0000000000000000000000000000000000000000..a9d35f7267dfaa9add3267979c490f1072e3433a --- /dev/null +++ b/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/04.string_literals/tbd.string_literals_escapes_n_continuation.sts @@ -0,0 +1,3 @@ +/*--- +desc: String with line continuation and escape sequences +---*/ \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/05.char_literals/char_literals.sts b/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/05.char_literals/char_literals.sts new file mode 100644 index 0000000000000000000000000000000000000000..2f05f8f282d409e6fad5b3028d51d58f300524b9 --- /dev/null +++ b/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/05.char_literals/char_literals.sts @@ -0,0 +1,12 @@ +{% for ch in char_literals %} + +/*--- +desc: Correct char literals +params: {{.ch}} +---*/ + +let x = {{.ch}}; + +function main(): void {} + +{% endfor %} diff --git a/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/05.char_literals/list.char_literals.yaml b/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/05.char_literals/list.char_literals.yaml new file mode 100644 index 0000000000000000000000000000000000000000..850690d2ce955365fd0558c5a7b7a4c20b0d9627 --- /dev/null +++ b/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/05.char_literals/list.char_literals.yaml @@ -0,0 +1,4 @@ +--- # List of correct char literals +- 'ʻ' +- 'a' +- '\u0000' diff --git a/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/06.null_literals/null_literal.sts b/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/06.null_literals/null_literal.sts new file mode 100644 index 0000000000000000000000000000000000000000..e5eaf53162ed32f8b964bcf8e5558d62d0fcdf90 --- /dev/null +++ b/migrator/test/staticTS/CTS/02.lexical_elements/06.literals/06.null_literals/null_literal.sts @@ -0,0 +1,6 @@ +/*--- +desc: Null literal +---*/ + +let x= null; +function main(): void {} diff --git a/migrator/test/staticTS/CTS/02.lexical_elements/07.automatic_semicolon_insertion/tbd.automatic_semicolon_insertion.sts b/migrator/test/staticTS/CTS/02.lexical_elements/07.automatic_semicolon_insertion/tbd.automatic_semicolon_insertion.sts new file mode 100644 index 0000000000000000000000000000000000000000..4785dddf1eb3228b58550b435efa67025e3d6998 --- /dev/null +++ b/migrator/test/staticTS/CTS/02.lexical_elements/07.automatic_semicolon_insertion/tbd.automatic_semicolon_insertion.sts @@ -0,0 +1,3 @@ +/*--- +desc: Automatic Semicolon Insertion +---*/ \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/03.types/01.predefined_primitive_types/01.integer_type/integer_types.sts b/migrator/test/staticTS/CTS/03.types/01.predefined_primitive_types/01.integer_type/integer_types.sts new file mode 100644 index 0000000000000000000000000000000000000000..593a2e422802a66f770085308653f47d383b091a --- /dev/null +++ b/migrator/test/staticTS/CTS/03.types/01.predefined_primitive_types/01.integer_type/integer_types.sts @@ -0,0 +1,11 @@ +{% for item in integer_types %} + +/*--- +desc: Integer type {{.item.type}} +params: {{.item.type}}, {{.item.value}} +---*/ + +let x: {{.item.type}} = {{.item.value}}; +function main(): void {} + +{% endfor %} diff --git a/migrator/test/staticTS/CTS/03.types/01.predefined_primitive_types/01.integer_type/list.integer_types.yaml b/migrator/test/staticTS/CTS/03.types/01.predefined_primitive_types/01.integer_type/list.integer_types.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9a16681f9b8301351ef847a30ab6ac0a3933c298 --- /dev/null +++ b/migrator/test/staticTS/CTS/03.types/01.predefined_primitive_types/01.integer_type/list.integer_types.yaml @@ -0,0 +1,15 @@ +--- # List of valid values for specific integer types + +- {type: byte, value: 127} +- {type: byte, value: -128} + +- {type: short, value: 32767} +- {type: short, value: -32768} + +- {type: int, value: 2147483647} +- {type: int, value: -2147483648} + +- {type: long, value: 9223372036854775807} +- {type: long, value: -9223372036854775808} + + diff --git a/migrator/test/staticTS/CTS/03.types/01.predefined_primitive_types/02.float_type/float_types.sts b/migrator/test/staticTS/CTS/03.types/01.predefined_primitive_types/02.float_type/float_types.sts new file mode 100644 index 0000000000000000000000000000000000000000..99d689774b45a93abad2647602fcb4f53ce702eb --- /dev/null +++ b/migrator/test/staticTS/CTS/03.types/01.predefined_primitive_types/02.float_type/float_types.sts @@ -0,0 +1,11 @@ + +/*--- +desc: Floating-point type NaN values +corner-case: true +---*/ + +let f: float = NaN; +let d: double = NaN; + +function main(): void {} + diff --git a/migrator/test/staticTS/CTS/03.types/01.predefined_primitive_types/02.float_type/float_types_nan.sts b/migrator/test/staticTS/CTS/03.types/01.predefined_primitive_types/02.float_type/float_types_nan.sts new file mode 100644 index 0000000000000000000000000000000000000000..a2355f9d0f0841a45382058ad7ee1f81b19cc81d --- /dev/null +++ b/migrator/test/staticTS/CTS/03.types/01.predefined_primitive_types/02.float_type/float_types_nan.sts @@ -0,0 +1,11 @@ +{% for item in float_types %} + +/*--- +desc: Floating-point type {{.item.type}} +params: {{.item.type}}, {{.item.value}} +---*/ + +let x: {{.item.type}} = {{.item.value}}; +function main(): void {} + +{% endfor %} diff --git a/migrator/test/staticTS/CTS/03.types/01.predefined_primitive_types/02.float_type/list.float_types.yaml b/migrator/test/staticTS/CTS/03.types/01.predefined_primitive_types/02.float_type/list.float_types.yaml new file mode 100644 index 0000000000000000000000000000000000000000..cb577565d014f5586026656f6533edbd8206e8ef --- /dev/null +++ b/migrator/test/staticTS/CTS/03.types/01.predefined_primitive_types/02.float_type/list.float_types.yaml @@ -0,0 +1,7 @@ +--- # List of valid values for specific float types + +- {type: float, value: "3.4028235e38"} +- {type: float, value: "1.40e-45"} + +- {type: double, value: "1.7976931348623157e308"} +- {type: double, value: "4.9e-324"} diff --git a/migrator/test/staticTS/CTS/03.types/01.predefined_primitive_types/03.boolean_type/boolean_type.sts b/migrator/test/staticTS/CTS/03.types/01.predefined_primitive_types/03.boolean_type/boolean_type.sts new file mode 100644 index 0000000000000000000000000000000000000000..e4cb2660dc13c4302e14343b365917bdd106bbca --- /dev/null +++ b/migrator/test/staticTS/CTS/03.types/01.predefined_primitive_types/03.boolean_type/boolean_type.sts @@ -0,0 +1,7 @@ +/*--- +desc: Boolean type +---*/ + +let t: boolean = true; +let f: boolean = false; +function main(): void {} diff --git a/migrator/test/staticTS/CTS/03.types/01.predefined_primitive_types/04.char_type/char_type.sts b/migrator/test/staticTS/CTS/03.types/01.predefined_primitive_types/04.char_type/char_type.sts new file mode 100644 index 0000000000000000000000000000000000000000..298b74dae5fa5ea17833dd0233073010cb593177 --- /dev/null +++ b/migrator/test/staticTS/CTS/03.types/01.predefined_primitive_types/04.char_type/char_type.sts @@ -0,0 +1,7 @@ +/*--- +desc: Char type +---*/ + +let charMin: char = '\u0000'; +let charMax: char = '\uffff'; +function main(): void {} diff --git a/migrator/test/staticTS/CTS/03.types/01.predefined_primitive_types/05.void_type/void_type.sts b/migrator/test/staticTS/CTS/03.types/01.predefined_primitive_types/05.void_type/void_type.sts new file mode 100644 index 0000000000000000000000000000000000000000..0e0719b063afcc2b2c1ebea6d6c3617fc233b80d --- /dev/null +++ b/migrator/test/staticTS/CTS/03.types/01.predefined_primitive_types/05.void_type/void_type.sts @@ -0,0 +1,5 @@ +/*--- +desc: void type +---*/ + +function main(): void {} diff --git a/migrator/test/staticTS/CTS/03.types/01.predefined_primitive_types/06.default_values_for_primitive_types/default_value.sts b/migrator/test/staticTS/CTS/03.types/01.predefined_primitive_types/06.default_values_for_primitive_types/default_value.sts new file mode 100644 index 0000000000000000000000000000000000000000..475f8bdd79ac4783e3b686a09a24d4df2a479ae7 --- /dev/null +++ b/migrator/test/staticTS/CTS/03.types/01.predefined_primitive_types/06.default_values_for_primitive_types/default_value.sts @@ -0,0 +1,13 @@ +{% for i in default_value %} + +/*--- +desc: Default value for primitive type {{.i.type}} +params: {{.i.type}}, {{.i.value}} +---*/ + +let x: {{.i.type}}; +function main(): void { + assert x == {{.i.value}}; +} + +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/03.types/01.predefined_primitive_types/06.default_values_for_primitive_types/list.default_value.yaml b/migrator/test/staticTS/CTS/03.types/01.predefined_primitive_types/06.default_values_for_primitive_types/list.default_value.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9ffc292f9149ff299af735ba7f392e8bbb9bbce6 --- /dev/null +++ b/migrator/test/staticTS/CTS/03.types/01.predefined_primitive_types/06.default_values_for_primitive_types/list.default_value.yaml @@ -0,0 +1,10 @@ +--- # List of default values for primitive types + +- {type: byte, value: 0} +- {type: short, value: 0} +- {type: int, value: 0} +- {type: long, value: 0} +- {type: float, value: 0.0} +- {type: double, value: 0.0} +- {type: char, value: '\u0000'} +- {type: boolean, value: false} diff --git a/migrator/test/staticTS/CTS/03.types/01.predefined_primitive_types/07.implicit_conversion_for_numeric_types/tbd.implicit_numeric_conversion.sts b/migrator/test/staticTS/CTS/03.types/01.predefined_primitive_types/07.implicit_conversion_for_numeric_types/tbd.implicit_numeric_conversion.sts new file mode 100644 index 0000000000000000000000000000000000000000..d620c7ed2ab5d07c8de66ddd8440b09d0e42042d --- /dev/null +++ b/migrator/test/staticTS/CTS/03.types/01.predefined_primitive_types/07.implicit_conversion_for_numeric_types/tbd.implicit_numeric_conversion.sts @@ -0,0 +1,3 @@ +/*--- +desc: Implicit numeric conversion for primitive type +---*/ \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/03.types/02.array_type/array_type.sts b/migrator/test/staticTS/CTS/03.types/02.array_type/array_type.sts new file mode 100644 index 0000000000000000000000000000000000000000..ec6bbe9cc98ce407864296d585abf51111608caf --- /dev/null +++ b/migrator/test/staticTS/CTS/03.types/02.array_type/array_type.sts @@ -0,0 +1,7 @@ +/*--- +desc: Array type +---*/ + +let a: int[]; +function main(): void {} + diff --git a/migrator/test/staticTS/CTS/03.types/03.named_types/list.named_types.yaml b/migrator/test/staticTS/CTS/03.types/03.named_types/list.named_types.yaml new file mode 100644 index 0000000000000000000000000000000000000000..5c271ede9c4150bd8e117e9167611b8953047366 --- /dev/null +++ b/migrator/test/staticTS/CTS/03.types/03.named_types/list.named_types.yaml @@ -0,0 +1,5 @@ +--- # List of named type declarations + +- class a {} +- interface b {} +- enum c {v1, v2} diff --git a/migrator/test/staticTS/CTS/03.types/03.named_types/list.named_types_generics.yaml b/migrator/test/staticTS/CTS/03.types/03.named_types/list.named_types_generics.yaml new file mode 100644 index 0000000000000000000000000000000000000000..28de02d9fbcf95a17ac4aa24230c21e65e4bd23c --- /dev/null +++ b/migrator/test/staticTS/CTS/03.types/03.named_types/list.named_types_generics.yaml @@ -0,0 +1,5 @@ +--- # List of named type declarations (with generics) + +- class a {} +- interface b {} +# - enum c {v1, v2} -- not implemented in grammar yet diff --git a/migrator/test/staticTS/CTS/03.types/03.named_types/named_types.sts b/migrator/test/staticTS/CTS/03.types/03.named_types/named_types.sts new file mode 100644 index 0000000000000000000000000000000000000000..b9537f40af4462547915aeca7fb93e81736a0928 --- /dev/null +++ b/migrator/test/staticTS/CTS/03.types/03.named_types/named_types.sts @@ -0,0 +1,12 @@ +{% for named in named_types %} + +/*--- +desc: Named type {{.named}} +params: {{.named}} +---*/ + +{{.named}} + +function main(): void {} + +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/03.types/03.named_types/named_types_generics.sts b/migrator/test/staticTS/CTS/03.types/03.named_types/named_types_generics.sts new file mode 100644 index 0000000000000000000000000000000000000000..2d52a00941d45576486bd0d57e3c315b823c4728 --- /dev/null +++ b/migrator/test/staticTS/CTS/03.types/03.named_types/named_types_generics.sts @@ -0,0 +1,12 @@ +{% for named in named_types_generics %} + +/*--- +desc: Generic named type {{.named}} +params: {{.named}} +---*/ + +{{.named}} + +function main(): void {} + +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/03.types/04.predefined_named_types/01.object_type/object_type.sts b/migrator/test/staticTS/CTS/03.types/04.predefined_named_types/01.object_type/object_type.sts new file mode 100644 index 0000000000000000000000000000000000000000..f643191df77db1bad778b6800d5e78f4d71c5b4d --- /dev/null +++ b/migrator/test/staticTS/CTS/03.types/04.predefined_named_types/01.object_type/object_type.sts @@ -0,0 +1,8 @@ +/*--- +desc: Object type +---*/ + +let x: Object; +let y: std.core.Object; + +function main(): void {} diff --git a/migrator/test/staticTS/CTS/03.types/04.predefined_named_types/02.string_type/string_type.sts b/migrator/test/staticTS/CTS/03.types/04.predefined_named_types/02.string_type/string_type.sts new file mode 100644 index 0000000000000000000000000000000000000000..57516b073b74945f5500f1f30df5be734ff39af0 --- /dev/null +++ b/migrator/test/staticTS/CTS/03.types/04.predefined_named_types/02.string_type/string_type.sts @@ -0,0 +1,8 @@ +/*--- +desc: String type +---*/ + +let x: String; +let y: std.core.String; + +function main(): void {} diff --git a/migrator/test/staticTS/CTS/03.types/05.type_reference/tbd.type_reference.sts b/migrator/test/staticTS/CTS/03.types/05.type_reference/tbd.type_reference.sts new file mode 100644 index 0000000000000000000000000000000000000000..a65c1eae4c48a2ea0d4ac8bb1836a108981f780f --- /dev/null +++ b/migrator/test/staticTS/CTS/03.types/05.type_reference/tbd.type_reference.sts @@ -0,0 +1,3 @@ +/*--- +desc: Type reference +---*/ \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/01.names/list.qualified_names.yaml b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/01.names/list.qualified_names.yaml new file mode 100644 index 0000000000000000000000000000000000000000..758de0bd4d087a0ff3538a55d836636bcfde8242 --- /dev/null +++ b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/01.names/list.qualified_names.yaml @@ -0,0 +1,10 @@ +--- # All possible qualified names + +- test.Class; +- test.Instance; +- Class.StaticField; +- Class.StaticMethod(); +- test.Class.StaticField; +- test.Class.StaticMethod(); +- Instance.Field; +- Instance.Method(); diff --git a/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/01.names/qualified_name.sts b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/01.names/qualified_name.sts new file mode 100644 index 0000000000000000000000000000000000000000..785a9b37ccf1112bdd44361c3c512ae2f33908a4 --- /dev/null +++ b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/01.names/qualified_name.sts @@ -0,0 +1,24 @@ +{% for qname in qualified_names %} + +/*--- +desc: Qualified name {{.qname}} +params: {{.qname}} +---*/ + +package test; + +class Class { + static StaticField: int; + static StaticMethod(): void {} + + Field: int; + Method(): void {} +} + +let Instance: Class = new Class; + +function main(): void { + {{.qname}} +} + +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/02.declarations/list.unique_decl.yaml b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/02.declarations/list.unique_decl.yaml new file mode 100644 index 0000000000000000000000000000000000000000..65e53847e7476f9a411a61ef8661f9798be7fdfa --- /dev/null +++ b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/02.declarations/list.unique_decl.yaml @@ -0,0 +1,5 @@ +--- # List of declarations to be unique + +- "class A{}" +- "enum E {V1, V2}" +- "function f(): void {}" diff --git a/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/02.declarations/n.unique_block_decl.sts b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/02.declarations/n.unique_block_decl.sts new file mode 100644 index 0000000000000000000000000000000000000000..c714485fcf945f023fc976bc6dcb6351acf78b70 --- /dev/null +++ b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/02.declarations/n.unique_block_decl.sts @@ -0,0 +1,10 @@ +/*--- +desc: A name must be unique in its block space +---*/ + +function main(): void { + { + let x = 0; + let x = 0; + } +} diff --git a/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/02.declarations/n.unique_class_decl.sts b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/02.declarations/n.unique_class_decl.sts new file mode 100644 index 0000000000000000000000000000000000000000..f3c95ac903978f3952283afe93c3a90b0f9178b7 --- /dev/null +++ b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/02.declarations/n.unique_class_decl.sts @@ -0,0 +1,10 @@ +/*--- +desc: A name must be unique in its class space +---*/ + +class A { + x: int; + x: int; +} + +function main(): void {} diff --git a/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/02.declarations/n.unique_decl_name.sts b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/02.declarations/n.unique_decl_name.sts new file mode 100644 index 0000000000000000000000000000000000000000..51feaf76945f8a96ec60bf2866f7f04fc1cc7067 --- /dev/null +++ b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/02.declarations/n.unique_decl_name.sts @@ -0,0 +1,11 @@ +{% for un in unique_decl %} +/*--- +desc: A name must be unique in its declaration space +---*/ + +{{.un}} +{{.un}} + +function main(): void {} + +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/02.declarations/n.unique_enum_decl.sts b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/02.declarations/n.unique_enum_decl.sts new file mode 100644 index 0000000000000000000000000000000000000000..cb7fb7550c23ffb2537e1b6d80f7b2ecc151615a --- /dev/null +++ b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/02.declarations/n.unique_enum_decl.sts @@ -0,0 +1,7 @@ +/*--- +desc: A name must be unique in its enum space +---*/ + +enum E {V1, V1} + +function main(): void {} diff --git a/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/02.declarations/n.unique_func_decl.sts b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/02.declarations/n.unique_func_decl.sts new file mode 100644 index 0000000000000000000000000000000000000000..91f0571e5eafd71e39713f749cc68ad11c7b295a --- /dev/null +++ b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/02.declarations/n.unique_func_decl.sts @@ -0,0 +1,8 @@ +/*--- +desc: A name must be unique in its function space +---*/ + +function main(): void { + let x = 0; + let x = 0; +} diff --git a/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/02.declarations/n.unique_intf_decl.sts b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/02.declarations/n.unique_intf_decl.sts new file mode 100644 index 0000000000000000000000000000000000000000..e9f0b79c6f921c2570ec9a8f2a89ce374290bce7 --- /dev/null +++ b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/02.declarations/n.unique_intf_decl.sts @@ -0,0 +1,10 @@ +/*--- +desc: A name must be unique in its interface space +---*/ + +interface A { + x: int = 0; + x: int = 0; +} + +function main(): void {} diff --git a/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/03.scopes/class_level.sts b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/03.scopes/class_level.sts new file mode 100644 index 0000000000000000000000000000000000000000..86e96e91e075dcc9a5833903f5955bb82fae1256 --- /dev/null +++ b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/03.scopes/class_level.sts @@ -0,0 +1,13 @@ +/*--- +desc: Class level scope +---*/ +package scopes; + +class C { + x: int = 1; + foo(): int { + return this.x; + } +} + +function main(): void {} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/03.scopes/n.hoisting.sts b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/03.scopes/n.hoisting.sts new file mode 100644 index 0000000000000000000000000000000000000000..c9c26a829458cfc152566d998406815831dac010 --- /dev/null +++ b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/03.scopes/n.hoisting.sts @@ -0,0 +1,9 @@ +/*--- +desc: Hoisting not available +---*/ +package scopes; + +function main(): void { + let x = y; + let y = 1; +} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/03.scopes/package_level.sts b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/03.scopes/package_level.sts new file mode 100644 index 0000000000000000000000000000000000000000..ec8fd7b5606e82e029e772905a58cd38a92bde13 --- /dev/null +++ b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/03.scopes/package_level.sts @@ -0,0 +1,21 @@ +/*--- +desc: Package level scope +---*/ +package scopes; + +let x = 1; + +class C { + y: int = x + 1; +} + +interface I { + // TODO: Is that correct? + z: int = x * 2; +} + +function foo(): int { + return x - 1; +} + +function main(): void {} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/03.scopes/tbd.enum_level.sts b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/03.scopes/tbd.enum_level.sts new file mode 100644 index 0000000000000000000000000000000000000000..43d44a378fa230744ea9983e6ca6f971234851ec --- /dev/null +++ b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/03.scopes/tbd.enum_level.sts @@ -0,0 +1,10 @@ +/*--- +desc: Enum level scope +---*/ +package scopes; + +interface I { + x: int = 1; +} + +function main(): void {} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/05.variable_and_constant_declarations/01.variable_declarations/list.var_decl.yaml b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/05.variable_and_constant_declarations/01.variable_declarations/list.var_decl.yaml new file mode 100644 index 0000000000000000000000000000000000000000..58f7ac7724b8f754fe3211010bf8a057f37b84e6 --- /dev/null +++ b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/05.variable_and_constant_declarations/01.variable_declarations/list.var_decl.yaml @@ -0,0 +1,4 @@ +--- # List of all possible var declaration forms +- "let a: int;" +- "let b = 1;" +- "let c: int = 6, d = 1, e = \"hello\";" diff --git a/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/05.variable_and_constant_declarations/01.variable_declarations/n.var_decl.sts b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/05.variable_and_constant_declarations/01.variable_declarations/n.var_decl.sts new file mode 100644 index 0000000000000000000000000000000000000000..f44da71ad9a9f4a49a737bf6220525478aa718d5 --- /dev/null +++ b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/05.variable_and_constant_declarations/01.variable_declarations/n.var_decl.sts @@ -0,0 +1,5 @@ +/*--- +desc: Incorrect variable declaration +---*/ + +var x; diff --git a/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/05.variable_and_constant_declarations/01.variable_declarations/tbd.initialize_before_use.sts b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/05.variable_and_constant_declarations/01.variable_declarations/tbd.initialize_before_use.sts new file mode 100644 index 0000000000000000000000000000000000000000..544722a756c7ef50559364a19e9aced69a8a367e --- /dev/null +++ b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/05.variable_and_constant_declarations/01.variable_declarations/tbd.initialize_before_use.sts @@ -0,0 +1,3 @@ +/*--- +desc: Every variable in a program must have a value before its value is used +---*/ \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/05.variable_and_constant_declarations/01.variable_declarations/var_decl.sts b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/05.variable_and_constant_declarations/01.variable_declarations/var_decl.sts new file mode 100644 index 0000000000000000000000000000000000000000..ea115b03f871c92169166fd5153aeaee5d8f9e7e --- /dev/null +++ b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/05.variable_and_constant_declarations/01.variable_declarations/var_decl.sts @@ -0,0 +1,13 @@ +{% for vd in var_decl %} + +/*--- +desc: A variable declaration introduces a named variable and optionally assigns it an initial value +params: > + {{.vd}} +---*/ + +{{.vd}} + +function main(): void {} + +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/05.variable_and_constant_declarations/02.constant_declarations/const_decl.sts b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/05.variable_and_constant_declarations/02.constant_declarations/const_decl.sts new file mode 100644 index 0000000000000000000000000000000000000000..7dd0185b037e16bb0930c96ef7a8fb94b50aca6f --- /dev/null +++ b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/05.variable_and_constant_declarations/02.constant_declarations/const_decl.sts @@ -0,0 +1,13 @@ +{% for cd in const_decl %} + +/*--- +desc: A constant declaration introduces a named entity with mandatory initial value +params: > + {{.cd}} +---*/ + +{{.cd}} + +function main(): void {} + +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/05.variable_and_constant_declarations/02.constant_declarations/list.bad_const_decl.yaml b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/05.variable_and_constant_declarations/02.constant_declarations/list.bad_const_decl.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2c1d4aa08405dd37d99740e9594552dd8b494159 --- /dev/null +++ b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/05.variable_and_constant_declarations/02.constant_declarations/list.bad_const_decl.yaml @@ -0,0 +1,4 @@ +--- # List of incorrect const declaration forms +- "const x;" +- "const y: int;" + diff --git a/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/05.variable_and_constant_declarations/02.constant_declarations/list.const_decl.yaml b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/05.variable_and_constant_declarations/02.constant_declarations/list.const_decl.yaml new file mode 100644 index 0000000000000000000000000000000000000000..5cade5d2e88cca6b56a2d8d42476376cc6b1cc07 --- /dev/null +++ b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/05.variable_and_constant_declarations/02.constant_declarations/list.const_decl.yaml @@ -0,0 +1,4 @@ +--- # List of all possible correct const declaration forms +- "const a: int = 1;" +- "const b = 1;" +- "const c: int = 6, d = 1, e = \"hello\";" diff --git a/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/05.variable_and_constant_declarations/02.constant_declarations/n.const_decl.sts b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/05.variable_and_constant_declarations/02.constant_declarations/n.const_decl.sts new file mode 100644 index 0000000000000000000000000000000000000000..d332e73e814798df349c1c1eba17e04b2cc26910 --- /dev/null +++ b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/05.variable_and_constant_declarations/02.constant_declarations/n.const_decl.sts @@ -0,0 +1,13 @@ +{% for cd in bad_const_decl %} + +/*--- +desc: Incorrect constant definition +params: > + {{.cd}} +---*/ + +{{.cd}} + +function main(): void {} + +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/05.variable_and_constant_declarations/03.type_compatibility_with_initializer/initializer_compatibility.sts b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/05.variable_and_constant_declarations/03.type_compatibility_with_initializer/initializer_compatibility.sts new file mode 100644 index 0000000000000000000000000000000000000000..076dea90c6316b97d83ed0720b24b20b66ba94a9 --- /dev/null +++ b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/05.variable_and_constant_declarations/03.type_compatibility_with_initializer/initializer_compatibility.sts @@ -0,0 +1,17 @@ +{% for i in type_and_initializer %} + +/*--- +desc: Type {{.i.type}} compartibility with initializer {{.i.value}} +params: !!str + {{.i.typedecl}} + {{.i.type}} + {{.i.value}} +---*/ + +{{.i.typedecl}} + +function main(): void { + let a: {{.i.type}} = {{.i.value}}; +} + +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/05.variable_and_constant_declarations/03.type_compatibility_with_initializer/list.type_and_initializer.yaml b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/05.variable_and_constant_declarations/03.type_compatibility_with_initializer/list.type_and_initializer.yaml new file mode 100644 index 0000000000000000000000000000000000000000..46f65a45e29b91eed3b525399564e9ad4c48452f --- /dev/null +++ b/migrator/test/staticTS/CTS/04.names_declarations_and_scopes/05.variable_and_constant_declarations/03.type_compatibility_with_initializer/list.type_and_initializer.yaml @@ -0,0 +1,38 @@ +--- # Type, TypeDecl and initializer + +# Integer types + +- {type: byte, value: 127} +- {type: byte, value: -128} + +- {type: short, value: 32767} +- {type: short, value: -32768} + +- {type: int, value: 2147483647} +- {type: int, value: -2147483648} + +- {type: long, value: 9223372036854775807} +- {type: long, value: -9223372036854775808} + +# Float types + +- {type: float, value: "3.4028235e38"} +- {type: float, value: "1.40e-45"} + +- {type: double, value: "1.7976931348623157e308"} +- {type: double, value: "4.9e-324"} + +# Char type + +- {type: char, value: \u0000} +- {type: char, value: \uFFFF} + +# Class type + +- {type: "A", typedecl: "class A {}", value: "new A"} +- {type: "A", typedecl: "class A {} \n class B extends A {}", value: "new B"} + +# Interface type + +# Enum type + diff --git a/migrator/test/staticTS/CTS/05.generic_and_parameterized_declarations/01.generic_declarations/01.generic_classes/list.self_dependency.yaml b/migrator/test/staticTS/CTS/05.generic_and_parameterized_declarations/01.generic_declarations/01.generic_classes/list.self_dependency.yaml new file mode 100644 index 0000000000000000000000000000000000000000..5ae3aeb53832ec8890a8ff114a1ced5a11b62380 --- /dev/null +++ b/migrator/test/staticTS/CTS/05.generic_and_parameterized_declarations/01.generic_declarations/01.generic_classes/list.self_dependency.yaml @@ -0,0 +1,7 @@ +--- # Self dependency tests + +- T +- U +- U> +- U> +- T diff --git a/migrator/test/staticTS/CTS/05.generic_and_parameterized_declarations/01.generic_declarations/01.generic_classes/list.toplevel_class_modifiers.yaml b/migrator/test/staticTS/CTS/05.generic_and_parameterized_declarations/01.generic_declarations/01.generic_classes/list.toplevel_class_modifiers.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6bfc2812d8f4c8753a4c18b13049a30d72bbc234 --- /dev/null +++ b/migrator/test/staticTS/CTS/05.generic_and_parameterized_declarations/01.generic_declarations/01.generic_classes/list.toplevel_class_modifiers.yaml @@ -0,0 +1,5 @@ +--- # Toplevel class modifier list + +- "" +- abstract +- open diff --git a/migrator/test/staticTS/CTS/05.generic_and_parameterized_declarations/01.generic_declarations/01.generic_classes/list.wrong_constraints.yaml b/migrator/test/staticTS/CTS/05.generic_and_parameterized_declarations/01.generic_declarations/01.generic_classes/list.wrong_constraints.yaml new file mode 100644 index 0000000000000000000000000000000000000000..bed00fe099d06cb2efd8d133ad88fe554b2e83c1 --- /dev/null +++ b/migrator/test/staticTS/CTS/05.generic_and_parameterized_declarations/01.generic_declarations/01.generic_classes/list.wrong_constraints.yaml @@ -0,0 +1,20 @@ +--- # Wrong type constraints for generic parameters + +- boolean +- byte +- char +- double +- float +- int +- int && Object +- int && Object && String +- long +- Object && int +- Object && int && String +- Object && String && int +- short +- void +- "enum Color { Red, Green, Blue }" +- "int[]" +- "int, extends Object" +- "Object, extends int" diff --git a/migrator/test/staticTS/CTS/05.generic_and_parameterized_declarations/01.generic_declarations/01.generic_classes/n.generic_class_self_dependency.sts b/migrator/test/staticTS/CTS/05.generic_and_parameterized_declarations/01.generic_declarations/01.generic_classes/n.generic_class_self_dependency.sts new file mode 100644 index 0000000000000000000000000000000000000000..d63f0678c8fa40b949e12d9d206da19fa70d5274 --- /dev/null +++ b/migrator/test/staticTS/CTS/05.generic_and_parameterized_declarations/01.generic_declarations/01.generic_classes/n.generic_class_self_dependency.sts @@ -0,0 +1,16 @@ +{% for sd in self_dependency %} +{% for cm in toplevel_class_modifiers %} + +/*--- +desc: Self-dependency is prohibited +params: > + {{.sd}} + {{.cm}} +---*/ + +{{.cm}} class T<{{.sd}}> {} + +function main(): void {} + +{% endfor %} +{% endfor %} diff --git a/migrator/test/staticTS/CTS/05.generic_and_parameterized_declarations/01.generic_declarations/01.generic_classes/n.generic_class_wrong_constraint.sts b/migrator/test/staticTS/CTS/05.generic_and_parameterized_declarations/01.generic_declarations/01.generic_classes/n.generic_class_wrong_constraint.sts new file mode 100644 index 0000000000000000000000000000000000000000..7c6fbddb020c4bf7f359e9b521742b0cd9228c92 --- /dev/null +++ b/migrator/test/staticTS/CTS/05.generic_and_parameterized_declarations/01.generic_declarations/01.generic_classes/n.generic_class_wrong_constraint.sts @@ -0,0 +1,16 @@ +{% for wc in wrong_constraints %} +{% for cm in toplevel_class_modifiers %} + +/*--- +desc: Self-dependency is prohibited +params: > + {{.wc}} + {{.cm}} +---*/ + +{{.cm}} class Point {} + +function main(): void {} + +{% endfor %} +{% endfor %} diff --git a/migrator/test/staticTS/CTS/06.conversions_and_contexts/01.kinds_of_conversion/02.widening_primitive_conversion/list.widening_primitives.yaml b/migrator/test/staticTS/CTS/06.conversions_and_contexts/01.kinds_of_conversion/02.widening_primitive_conversion/list.widening_primitives.yaml new file mode 100644 index 0000000000000000000000000000000000000000..44cf7e865b3cab417e8346a7a1c2992e18b1d08e --- /dev/null +++ b/migrator/test/staticTS/CTS/06.conversions_and_contexts/01.kinds_of_conversion/02.widening_primitive_conversion/list.widening_primitives.yaml @@ -0,0 +1,7 @@ +--- # List of allowed widening primitives conversions + +- {origin: byte, dest: [short, int, long, float, double]} +- {origin: short, dest: [int, long, float, double]} +- {origin: int, dest: [long, float, double]} +- {origin: long, dest: [float, double]} +- {origin: float, dest: [double]} diff --git a/migrator/test/staticTS/CTS/06.conversions_and_contexts/01.kinds_of_conversion/02.widening_primitive_conversion/widening.sts b/migrator/test/staticTS/CTS/06.conversions_and_contexts/01.kinds_of_conversion/02.widening_primitive_conversion/widening.sts new file mode 100644 index 0000000000000000000000000000000000000000..38c58bff3528d2b51f3dbf1d56b80e4d3e98d186 --- /dev/null +++ b/migrator/test/staticTS/CTS/06.conversions_and_contexts/01.kinds_of_conversion/02.widening_primitive_conversion/widening.sts @@ -0,0 +1,13 @@ +{% for wid in widening_primitives %} +/*--- +desc: Widening primitive type {{.wid.origin}} +---*/ +let origin: {{.wid.origin}} = 0; + +function main(): void { +{%- for t in wid['dest'] %} + let x{{.t}}: {{.t}} = origin; +{%- endfor %} +} + +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/06.conversions_and_contexts/01.kinds_of_conversion/07.boxing_conversion/boxing_conversion.sts b/migrator/test/staticTS/CTS/06.conversions_and_contexts/01.kinds_of_conversion/07.boxing_conversion/boxing_conversion.sts new file mode 100644 index 0000000000000000000000000000000000000000..a55012fe92634e3f426c3ef9dc33ac5ab276de4b --- /dev/null +++ b/migrator/test/staticTS/CTS/06.conversions_and_contexts/01.kinds_of_conversion/07.boxing_conversion/boxing_conversion.sts @@ -0,0 +1,15 @@ +{% for conv in boxing_conversion %} + +/*--- +desc: Boxing conversion for types +---*/ + +let origin: {{.conv.origin}} = {{.conv.value}}; +let dest: {{.conv.dest}}; + +function main(): void { + dest = origin; + assert dest.{{.conv.origin}}Value() == origin; +} + +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/06.conversions_and_contexts/01.kinds_of_conversion/07.boxing_conversion/boxing_coversion_nan.sts b/migrator/test/staticTS/CTS/06.conversions_and_contexts/01.kinds_of_conversion/07.boxing_conversion/boxing_coversion_nan.sts new file mode 100644 index 0000000000000000000000000000000000000000..cec19df2242cc6faa17e661b02e8351e707c4ffc --- /dev/null +++ b/migrator/test/staticTS/CTS/06.conversions_and_contexts/01.kinds_of_conversion/07.boxing_conversion/boxing_coversion_nan.sts @@ -0,0 +1,16 @@ +{% for conv in boxing_nan %} + +/*--- +desc: Boxing conversion floating-point types (NaN) +corner-case: true +---*/ + +let origin: {{.conv.origin}} = NaN; +let dest: {{.conv.dest}}; + +function main(): void { + dest = origin; + assert dest.isNaN(); +} + +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/06.conversions_and_contexts/01.kinds_of_conversion/07.boxing_conversion/list.boxing_conversion.yaml b/migrator/test/staticTS/CTS/06.conversions_and_contexts/01.kinds_of_conversion/07.boxing_conversion/list.boxing_conversion.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4322817a7a2660c33cd5b87055c19388ca54c045 --- /dev/null +++ b/migrator/test/staticTS/CTS/06.conversions_and_contexts/01.kinds_of_conversion/07.boxing_conversion/list.boxing_conversion.yaml @@ -0,0 +1,10 @@ +--- # List of boxing conversions + +- {origin: boolean, dest: Boolean, value: "true"} +- {origin: byte, dest: Byte, value: 1} +- {origin: short, dest: Short, value: 1} +- {origin: int, dest: Integer, value: 1} +- {origin: long, dest: Long, value: 1} +- {origin: char, dest: Character, value: 'a'} +- {origin: float, dest: Float, value: 1.0} +- {origin: double, dest: Double, value: 1.0} diff --git a/migrator/test/staticTS/CTS/06.conversions_and_contexts/01.kinds_of_conversion/07.boxing_conversion/list.boxing_nan.yaml b/migrator/test/staticTS/CTS/06.conversions_and_contexts/01.kinds_of_conversion/07.boxing_conversion/list.boxing_nan.yaml new file mode 100644 index 0000000000000000000000000000000000000000..66ce1b026c962885e80bb96b2a576b416d78f85d --- /dev/null +++ b/migrator/test/staticTS/CTS/06.conversions_and_contexts/01.kinds_of_conversion/07.boxing_conversion/list.boxing_nan.yaml @@ -0,0 +1,4 @@ +--- # List of boxing conversion (NaN) + +- {origin: float, dest: Float} +- {origin: double, dest: Double} diff --git a/migrator/test/staticTS/CTS/06.conversions_and_contexts/01.kinds_of_conversion/08.unboxing_conversion/list.unboxing_conversion.yaml b/migrator/test/staticTS/CTS/06.conversions_and_contexts/01.kinds_of_conversion/08.unboxing_conversion/list.unboxing_conversion.yaml new file mode 100644 index 0000000000000000000000000000000000000000..39851730e068a1c08ae05cb7c2b69c3bc1a697ae --- /dev/null +++ b/migrator/test/staticTS/CTS/06.conversions_and_contexts/01.kinds_of_conversion/08.unboxing_conversion/list.unboxing_conversion.yaml @@ -0,0 +1,10 @@ +--- # List of unboxing conversions + +- {origin: Boolean, dest: boolean, value: "true"} +- {origin: Byte, dest: byte, value: 1} +- {origin: Short, dest: short, value: 1} +- {origin: Integer, dest: integer, value: 1} +- {origin: Long, dest: long, value: 1} +- {origin: Character, dest: character, value: 'a'} +- {origin: Float, dest: float, value: 1.0} +- {origin: Double, dest: double, value: 1.0} diff --git a/migrator/test/staticTS/CTS/06.conversions_and_contexts/01.kinds_of_conversion/08.unboxing_conversion/unboxing_conversion.sts b/migrator/test/staticTS/CTS/06.conversions_and_contexts/01.kinds_of_conversion/08.unboxing_conversion/unboxing_conversion.sts new file mode 100644 index 0000000000000000000000000000000000000000..507ac5b2223c936dc811b0ede7465e89a7981faa --- /dev/null +++ b/migrator/test/staticTS/CTS/06.conversions_and_contexts/01.kinds_of_conversion/08.unboxing_conversion/unboxing_conversion.sts @@ -0,0 +1,15 @@ +{% for conv in unboxing_conversion %} + +/*--- +desc: Unboxing conversion for types +---*/ + +let origin: {{.conv.origin}} = {{.conv.value}}; +let dest: {{.conv.dest}}; + +function main(): void { + dest = origin; + assert dest == origin.{{.conv.dest}}Value(); +} + +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/06.evaluation_order/03.evaluation_respects_parentheses_and_precedence/int_parens.sts b/migrator/test/staticTS/CTS/07.expressions/06.evaluation_order/03.evaluation_respects_parentheses_and_precedence/int_parens.sts new file mode 100644 index 0000000000000000000000000000000000000000..d3a75f0b26d024186b68c786a3561fd576025b2c --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/06.evaluation_order/03.evaluation_respects_parentheses_and_precedence/int_parens.sts @@ -0,0 +1,10 @@ +{% for ia in int_assoc %} +/*--- +desc: Integer addition and multiplication are associative +---*/ + +function main(): void { + assert {{.ia.left}} == {{.ia.right}}; +} + +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/06.evaluation_order/03.evaluation_respects_parentheses_and_precedence/list.int_assoc.yaml b/migrator/test/staticTS/CTS/07.expressions/06.evaluation_order/03.evaluation_respects_parentheses_and_precedence/list.int_assoc.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f7928c81cf8009be64379a6a709c61a683acf6d9 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/06.evaluation_order/03.evaluation_respects_parentheses_and_precedence/list.int_assoc.yaml @@ -0,0 +1,17 @@ +--- # List of integer addition and multiplication associative tests + +- {left: "2+3+4+5", right: "(2+3)+4+5"} +- {left: "2+3+4+5", right: "(2+3)+(4+5)"} +- {left: "2+3+4+5", right: "2+(3+4)+5"} +- {left: "2+3+4+5", right: "2+3+(4+5)"} +- {left: "2+3+4+5", right: "(((2+3)+4)+5)"} +- {left: "2+3+4+5", right: "((2+3)+4)+5"} + +- {left: "2*3*4*5", right: "(2*3)*4*5"} +- {left: "2*3*4*5", right: "(2*3)*(4*5)"} +- {left: "2*3*4*5", right: "2*(3*4)*5"} +- {left: "2*3*4*5", right: "2*3*(4*5)"} +- {left: "2*3*4*5", right: "(((2*3)*4)*5)"} +- {left: "2*3*4*5", right: "((2*3)*4)*5"} + + diff --git a/migrator/test/staticTS/CTS/07.expressions/06.evaluation_order/04.arguments_lists_are_evaluated_left_to_right/arg_order_function.sts b/migrator/test/staticTS/CTS/07.expressions/06.evaluation_order/04.arguments_lists_are_evaluated_left_to_right/arg_order_function.sts new file mode 100644 index 0000000000000000000000000000000000000000..94c01420377b6cccaad47c455bedb78b8d2c2223 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/06.evaluation_order/04.arguments_lists_are_evaluated_left_to_right/arg_order_function.sts @@ -0,0 +1,47 @@ +/*--- +desc: Argument list evaluation order (functions) +---*/ + +let a: boolean = false; +let b: boolean = false; +let c: boolean = false; + +function ta(): int { + assert !a; + assert !b; + assert !c; + a = true; + return 0; +} + +function tb(): int { + assert a; + assert !b; + assert !c; + b = true; + return 1; +} + +function tc(): int { + assert a; + assert b; + assert !c; + c = true; + return 2; +} + +function td(): int { + assert a; + assert b; + assert c; + return 3; +} + + +function test(a: int, b: int, c: int, d: int): void { + assert a == 0 && b == 1 && c == 2 && d == 3; +} + +function main(): void { + test(ta(), tb(), tc(), td()); +} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/08.class_literal/class_literal.sts b/migrator/test/staticTS/CTS/07.expressions/08.class_literal/class_literal.sts new file mode 100644 index 0000000000000000000000000000000000000000..6caf04fec3109016fed64ed3cc86aa8e67b67088 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/08.class_literal/class_literal.sts @@ -0,0 +1,9 @@ +/*--- +desc: Class literal +---*/ + +class C {} + +let x = C.class; + +function main(): void {} diff --git a/migrator/test/staticTS/CTS/07.expressions/09.array_literal/array_literal.sts b/migrator/test/staticTS/CTS/07.expressions/09.array_literal/array_literal.sts new file mode 100644 index 0000000000000000000000000000000000000000..c0e6b04c44fd9aba2f9bf9583f680418e2fb0a48 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/09.array_literal/array_literal.sts @@ -0,0 +1,11 @@ +{% for item in array_literal %} + +/*--- +desc: Array literal +params: {{.item.array}} +---*/ + +let x = {{.item.array}}; +function main(): void {} + +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/09.array_literal/list.array_literal.yaml b/migrator/test/staticTS/CTS/07.expressions/09.array_literal/list.array_literal.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6edf37eeaed57a0a29a272a89408a4a9404064ad --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/09.array_literal/list.array_literal.yaml @@ -0,0 +1,8 @@ +--- # List of valid array literals + +- {array: []} +- {array: [1]} +- {array: [1, 2, 3]} +- {array: [1+1, 2, 1+3]} +- {array: ["aaa", "bbb"]} +- {array: [3.1456926]} diff --git a/migrator/test/staticTS/CTS/07.expressions/10.parenthesized_expression/list.paren_expr.yaml b/migrator/test/staticTS/CTS/07.expressions/10.parenthesized_expression/list.paren_expr.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7bbbd27e42f95a6c47b89790f9efd51cea3cae20 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/10.parenthesized_expression/list.paren_expr.yaml @@ -0,0 +1,6 @@ +--- # List of parenthesis expression + +- "(x)" +- "((x))" +- "(((x) + (x) - (x)))" +- "(((x))) + (((x))) - (((x)))" diff --git a/migrator/test/staticTS/CTS/07.expressions/10.parenthesized_expression/paren_expr.sts b/migrator/test/staticTS/CTS/07.expressions/10.parenthesized_expression/paren_expr.sts new file mode 100644 index 0000000000000000000000000000000000000000..349e5acd61ee902e7e39c61031882767f2e2f44d --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/10.parenthesized_expression/paren_expr.sts @@ -0,0 +1,13 @@ +{% for e in paren_expr %} +/*--- +desc: Parenthesized expression +---*/ + +let x = 1; +let y = {{.e}}; + +function main(): void { + assert x == y; +} + +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/14.array_access_expression/array_access.sts b/migrator/test/staticTS/CTS/07.expressions/14.array_access_expression/array_access.sts new file mode 100644 index 0000000000000000000000000000000000000000..dc941311a20335f1311c13ce5e6cce7538cdb76c --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/14.array_access_expression/array_access.sts @@ -0,0 +1,13 @@ +/*--- +desc: Array access expression +---*/ + +let arr = [1, 2, 3]; + +function main(): void { + let x = arr[0]; + let y = arr[x]; + let z = arr[x+1]; + + assert x == 1 && y == 2 && z == 3; +} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/15.function_invocation_expression/function_invocation_expr.sts b/migrator/test/staticTS/CTS/07.expressions/15.function_invocation_expression/function_invocation_expr.sts new file mode 100644 index 0000000000000000000000000000000000000000..56289f5e2c099d7b28670510871500a14a3629e1 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/15.function_invocation_expression/function_invocation_expr.sts @@ -0,0 +1,16 @@ +/*--- +desc: Function invocation expression +---*/ + +function callee(a: int, b: bool): int { + if (b) { + return a; + } else { + return -a; + } +} + +function main(): void { + assert callee(1, true) == 1; + assert callee(1, false) == -1; +} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/16.new_expression/01.class_instance_creation_expression/class_instance.sts b/migrator/test/staticTS/CTS/07.expressions/16.new_expression/01.class_instance_creation_expression/class_instance.sts new file mode 100644 index 0000000000000000000000000000000000000000..aadc9608fd573abd67166c4a2f9c55cb6fe69d9f --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/16.new_expression/01.class_instance_creation_expression/class_instance.sts @@ -0,0 +1,14 @@ +{% for ins in class_instance %} + +/*--- +desc: Class instance creation expression +params: {{.ins.init}} +---*/ + +{{.ins.decl}} + +function main(): void { + let x = {{.ins.init}}; +} + +{% endfor %} diff --git a/migrator/test/staticTS/CTS/07.expressions/16.new_expression/01.class_instance_creation_expression/list.class_instance.yaml b/migrator/test/staticTS/CTS/07.expressions/16.new_expression/01.class_instance_creation_expression/list.class_instance.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b15c2ed9d6187507483a0580d6f3c1ec3ea9e058 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/16.new_expression/01.class_instance_creation_expression/list.class_instance.yaml @@ -0,0 +1,4 @@ +--- # List of valid class instance creation samples + +- {decl: "class A {}", init: "new A"} +- {decl: "", init: "new std.core.String"} diff --git a/migrator/test/staticTS/CTS/07.expressions/16.new_expression/02.array_creation_instance/array_creation.sts b/migrator/test/staticTS/CTS/07.expressions/16.new_expression/02.array_creation_instance/array_creation.sts new file mode 100644 index 0000000000000000000000000000000000000000..edca887d3a7ae38913deb874318a6412e31ee141 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/16.new_expression/02.array_creation_instance/array_creation.sts @@ -0,0 +1,13 @@ +{% for exp in array_creation %} + +/*--- +desc: Array creation expression +---*/ + +class A {} + +let x = new {{.exp}}; + +function main(): void {} + +{% endfor %} diff --git a/migrator/test/staticTS/CTS/07.expressions/16.new_expression/02.array_creation_instance/list.array_creation.yaml b/migrator/test/staticTS/CTS/07.expressions/16.new_expression/02.array_creation_instance/list.array_creation.yaml new file mode 100644 index 0000000000000000000000000000000000000000..60c5f9c3fd05133955613387b461647cc10dcf49 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/16.new_expression/02.array_creation_instance/list.array_creation.yaml @@ -0,0 +1,17 @@ +--- # List of valid array creation expressions + +- "A[1]" +- "byte[1]" +- "int[1]" +- "short[1]" +- "long[1]" +- "float[1]" +- "double[1]" + +- "A[1][1]" +- "byte[1][1]" +- "int[1][1]" +- "short[1][1]" +- "long[1][1]" +- "float[1][1]" +- "double[1][1]" diff --git a/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/01.postfix_increment_operator/postfix_increment.sts b/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/01.postfix_increment_operator/postfix_increment.sts new file mode 100644 index 0000000000000000000000000000000000000000..42c3abdbb0a0b7a3b3db676a22a217d5d47bddec --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/01.postfix_increment_operator/postfix_increment.sts @@ -0,0 +1,9 @@ +/*--- +desc: Postfix increment operator +---*/ + +function main(): void { + let a = 5; + assert a++ == 5; + assert a == 6; +} diff --git a/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/02.postfix_decrement_operator/postfix_decrement.sts b/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/02.postfix_decrement_operator/postfix_decrement.sts new file mode 100644 index 0000000000000000000000000000000000000000..a6ae1105c6923889cecc88677b6aa92cdafaedbc --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/02.postfix_decrement_operator/postfix_decrement.sts @@ -0,0 +1,9 @@ +/*--- +desc: Postfix decrement operator +---*/ + +function main(): void { + let a = 5; + assert a-- == 5; + assert a == 4; +} diff --git a/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/03.prefix_increment_operator/prefix_increment.sts b/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/03.prefix_increment_operator/prefix_increment.sts new file mode 100644 index 0000000000000000000000000000000000000000..2d090210b9dda2cea9e1fdd0055aa205caf04c53 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/03.prefix_increment_operator/prefix_increment.sts @@ -0,0 +1,9 @@ +/*--- +desc: Prefix increment operator +---*/ + +function main(): void { + let a = 5; + assert ++a == 6; + assert a == 6; +} diff --git a/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/04.prefix_decrement_operator/prefix_decrement.sts b/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/04.prefix_decrement_operator/prefix_decrement.sts new file mode 100644 index 0000000000000000000000000000000000000000..48b91947d5de27ef16a52897902505bcd3df76e6 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/04.prefix_decrement_operator/prefix_decrement.sts @@ -0,0 +1,9 @@ +/*--- +desc: Prefix decrement operator +---*/ + +function main(): void { + let a = 5; + assert --a == 4; + assert a == 4; +} diff --git a/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/05.unary_plus_operator/unary_plus.sts b/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/05.unary_plus_operator/unary_plus.sts new file mode 100644 index 0000000000000000000000000000000000000000..4650c205cd5e0041cb81ad6ce0edebb3ef9e38e6 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/05.unary_plus_operator/unary_plus.sts @@ -0,0 +1,8 @@ +/*--- +desc: Unary plus operator +---*/ + +function main(): void { + let a = 5; + assert +a == a; +} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/06.unary_minus_operator/list.unary_minus_corner.yaml b/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/06.unary_minus_operator/list.unary_minus_corner.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7ddd37da8928e16fbf3cfbcd44e8b3d2c9784ca9 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/06.unary_minus_operator/list.unary_minus_corner.yaml @@ -0,0 +1,7 @@ +--- # List of corner cases for unary minus + +- {origin: NaN, dest: NaN} +- {origin: INF, dest: -INF} +- {origin: -INF, dest: INF} +- {origin: 0.0, dest: -0.0} +- {origin: -0.0, dest: 0.0} diff --git a/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/06.unary_minus_operator/list.unary_minus_inbound.yaml b/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/06.unary_minus_operator/list.unary_minus_inbound.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4a606ca15ca2b988a8011c0aa65004f2b7c5acdb --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/06.unary_minus_operator/list.unary_minus_inbound.yaml @@ -0,0 +1,11 @@ +--- # List of valid in-bound integer unary minus tests + +- {type: byte, origin: 127, dest: -127} +- {type: short, origin: 32767, dest: -32767} +- {type: int, origin: 2147483647, dest: -2147483647} +- {type: long, origin: 9223372036854775807, dest: -9223372036854775807} + +- {type: byte, origin: 0, dest: 0} +- {type: short, origin: 0, dest: 0} +- {type: int, origin: 0, dest: 0} +- {type: long, origin: 0, dest: 0} diff --git a/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/06.unary_minus_operator/list.unary_minus_onbound.yaml b/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/06.unary_minus_operator/list.unary_minus_onbound.yaml new file mode 100644 index 0000000000000000000000000000000000000000..03cfd41a3a085b8e4b894082af1f628ecc6d9569 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/06.unary_minus_operator/list.unary_minus_onbound.yaml @@ -0,0 +1,6 @@ +--- # List of valid on-bound integer unary minus tests + +- {type: byte, origin: -128, dest: -128} +- {type: short, origin: -32768, dest: -32768} +- {type: int, origin: -2147483648, dest: -2147483648} +- {type: long, origin: -9223372036854775808, dest: -9223372036854775808} diff --git a/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/06.unary_minus_operator/unary_minus_corner.sts b/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/06.unary_minus_operator/unary_minus_corner.sts new file mode 100644 index 0000000000000000000000000000000000000000..9c3decf3b51c20e8c125a68f734f9b5889710d2a --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/06.unary_minus_operator/unary_minus_corner.sts @@ -0,0 +1,14 @@ +{% for un in unary_minus_corner %} + +/*--- +desc: Unary minus operator (corner cases) +corner-case: true +params: {{.un.origin}} => {{.un.dest}} +---*/ + +function main(): void { + let a = {{.un.origin}}; + assert -a == {{.un.dest}}; +} + +{% endfor %} diff --git a/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/06.unary_minus_operator/unary_minus_inbound.sts b/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/06.unary_minus_operator/unary_minus_inbound.sts new file mode 100644 index 0000000000000000000000000000000000000000..d9a4a48e516a32c43c20dc8df8121e89d709e757 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/06.unary_minus_operator/unary_minus_inbound.sts @@ -0,0 +1,13 @@ +{% for inb in unary_minus_inbound %} + +/*--- +desc: Unary minus operator (inbound) +params: {{.inb.type}} {{.inb.origin}} => {{.inb.dest}} +---*/ + +function main(): void { + let a: {{.inb.type}} = {{.inb.origin}}; + assert -a == {{.inb.dest}}; +} + +{% endfor %} diff --git a/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/06.unary_minus_operator/unary_minus_onbound.sts b/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/06.unary_minus_operator/unary_minus_onbound.sts new file mode 100644 index 0000000000000000000000000000000000000000..eabe6a003fc1e6776a5a0a722de13d5cdbdadbc6 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/06.unary_minus_operator/unary_minus_onbound.sts @@ -0,0 +1,14 @@ +{% for onb in unary_minus_onbound %} + +/*--- +desc: Unary minus operator (inbound) +params: {{.onb.type}} {{.onb.origin}} => {{.onb.dest}} +corner-case: true +---*/ + +function main(): void { + let a: {{.onb.type}} = {{.onb.origin}}; + assert -a == {{.onb.dest}}; +} + +{% endfor %} diff --git a/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/07.bitwise_complement_operator/bitwise_complement.sts b/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/07.bitwise_complement_operator/bitwise_complement.sts new file mode 100644 index 0000000000000000000000000000000000000000..a3aa54556195a97ccecbe36658a7df2cc732fd61 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/07.bitwise_complement_operator/bitwise_complement.sts @@ -0,0 +1,13 @@ +{% for bw in bitwise_complement %} + +/*--- +desc: Bitwise complement operator +params: {{.bw.type}} {{.bw.origin}} => {{.bw.dest}} +---*/ + +function main(): void { + let a: {{.bw.type}} = {{.bw.origin}}; + assert ~a == {{.bw.dest}}; +} + +{% endfor %} diff --git a/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/07.bitwise_complement_operator/list.bitwise_complement.yaml b/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/07.bitwise_complement_operator/list.bitwise_complement.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4944f8fd2b58290b31538350d0fc426085a85832 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/07.bitwise_complement_operator/list.bitwise_complement.yaml @@ -0,0 +1,38 @@ +--- # List of bitwise complement operator values + +- {type: byte, origin: 0, dest: -1} +- {type: byte, origin: 1, dest: -2} +- {type: byte, origin: 127, dest: -128} +- {type: byte, origin: -86, dest: 85} +- {type: byte, origin: 15, dest: -16} +- {type: byte, origin: 51, dest: -52} + +- {type: short, origin: 0, dest: -1} +- {type: short, origin: 1, dest: -2} +- {type: short, origin: 127, dest: -128} +- {type: short, origin: -86, dest: 85} +- {type: short, origin: 15, dest: -16} +- {type: short, origin: 51, dest: -52} +- {type: short, origin: 255, dest: -256} +- {type: short, origin: 21845, dest: -21846} +- {type: short, origin: -3856, dest: 3855} + +- {type: int, origin: 0, dest: -1} +- {type: int, origin: 1, dest: -2} +- {type: int, origin: 127, dest: -128} +- {type: int, origin: -86, dest: 85} +- {type: int, origin: 15, dest: -16} +- {type: int, origin: 51, dest: -52} +- {type: int, origin: 255, dest: -256} +- {type: int, origin: 21845, dest: -21846} +- {type: int, origin: -3856, dest: 3855} + +- {type: long, origin: 0, dest: -1} +- {type: long, origin: 1, dest: -2} +- {type: long, origin: 127, dest: -128} +- {type: long, origin: -86, dest: 85} +- {type: long, origin: 15, dest: -16} +- {type: long, origin: 51, dest: -52} +- {type: long, origin: 255, dest: -256} +- {type: long, origin: 21845, dest: -21846} +- {type: long, origin: -3856, dest: 3855} diff --git a/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/07.bitwise_complement_operator/tbd.bitwise_long_int.sts b/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/07.bitwise_complement_operator/tbd.bitwise_long_int.sts new file mode 100644 index 0000000000000000000000000000000000000000..4d2688ef4d02b917bdbd4de27688f3ce20a4df6c --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/07.bitwise_complement_operator/tbd.bitwise_long_int.sts @@ -0,0 +1,3 @@ +/*--- +desc: More tests for bitwise complement operator for large integers +---*/ \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/08.logical_complement_operator/list.logical_complement.yaml b/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/08.logical_complement_operator/list.logical_complement.yaml new file mode 100644 index 0000000000000000000000000000000000000000..af07c7c244e6ecb44b795a7af3310651a0875874 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/08.logical_complement_operator/list.logical_complement.yaml @@ -0,0 +1,4 @@ +--- # List of logical complement operator values + +- {origin: "true", dest: "false"} +- {origin: "false", dest: "true"} diff --git a/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/08.logical_complement_operator/logical_complement.sts b/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/08.logical_complement_operator/logical_complement.sts new file mode 100644 index 0000000000000000000000000000000000000000..ac8206bfedd65a7ca859f9c8886d758cba48789c --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/17.unary_operators/08.logical_complement_operator/logical_complement.sts @@ -0,0 +1,12 @@ +{% for lc in logical_complement %} +/*--- +desc: Logical complement operator +params: {{.lc.origin}} => {{.lc.dest}} +---*/ + +function main(): void { + let a = {{.lc.origin}}; + assert !a == {{.lc.dest}}; +} + +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/01.multiplication_operator/integer_mul.sts b/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/01.multiplication_operator/integer_mul.sts new file mode 100644 index 0000000000000000000000000000000000000000..1a72adb028c50ba0c245451de98622ac1a02194d --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/01.multiplication_operator/integer_mul.sts @@ -0,0 +1,10 @@ +{% for ni in integer_mul %} +/*--- +desc: Multiplication of integer numbers +params: {{.ni.x}} * {{.ni.y}} == {{.ni.result}} +---*/ + +function main(): void { + assert {{.ni.x}} * {{.ni.y}} == {{.ni.result}}; +} +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/01.multiplication_operator/list.integer_mul.yaml b/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/01.multiplication_operator/list.integer_mul.yaml new file mode 100644 index 0000000000000000000000000000000000000000..5dadd145f3509a789685d98d6abaf56dc3ba64ff --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/01.multiplication_operator/list.integer_mul.yaml @@ -0,0 +1,13 @@ +--- # List of integer multiplication + +- {x: 0, y: 0, result: 0} +- {x: 0, y: 1, result: 0} +- {x: 1, y: 0, result: 0} +- {x: 0, y: -1, result: 0} +- {x: -1, y: 0, result: 0} + +- {x: 2, y: 2, result: 4} +- {x: 2, y: 1, result: 2} +- {x: 1, y: 2, result: 2} +- {x: 2, y: -1, result: -2} +- {x: -2, y: 1, result: -2} diff --git a/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/01.multiplication_operator/list.nan_inf.yaml b/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/01.multiplication_operator/list.nan_inf.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1cc7f148e7d30556cf6ec681c5cd6f679306379d --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/01.multiplication_operator/list.nan_inf.yaml @@ -0,0 +1,15 @@ +--- # List of multiplications where NaN involved + +- {x: NaN, y: NaN, result: NaN} +- {x: NaN, y: 0.0, result: NaN} +- {x: 0.0, y: NaN, result: NaN} +- {x: NaN, y: 1.0, result: NaN} +- {x: 1.0, y: NaN, result: NaN} +- {x: NaN, y: INF, result: NaN} +- {x: INF, y: NaN, result: NaN} +- {x: NaN, y: -INF, result: NaN} +- {x: -INF, y: NaN, result: NaN} +- {x: INF, y: 0.0, result: NaN} +- {x: -INF, y: -0.0, result: NaN} +- {x: INF, y: -1.0, result: -INF} +- {x: -INF, y: -1.0, result: INF} diff --git a/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/01.multiplication_operator/nan_inf.sts b/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/01.multiplication_operator/nan_inf.sts new file mode 100644 index 0000000000000000000000000000000000000000..81e3eba669c244af7d0a01c7f991ba6f9b49b87d --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/01.multiplication_operator/nan_inf.sts @@ -0,0 +1,11 @@ +{% for ni in nan_inf %} +/*--- +desc: Multiplications with NaN and INF +params: {{.ni.x}} * {{.ni.y}} == {{.ni.result}} +corner-case: true +---*/ + +function main(): void { + assert {{.ni.x}} * {{.ni.y}} == {{.ni.result}}; +} +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/02.division_operator/list.integer_div.yaml b/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/02.division_operator/list.integer_div.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a25b96408273504b2779f3d66f19af2171621d69 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/02.division_operator/list.integer_div.yaml @@ -0,0 +1,13 @@ +--- # List of integer division + +- {x: 0, y: 1, result: 0} +- {x: 0, y: 1, result: 0} +- {x: 1, y: 1, result: 1} +- {x: 0, y: -1, result: 0} +- {x: -1, y: -1, result: 1} + +- {x: 2, y: 2, result: 1} +- {x: 2, y: 1, result: 2} +- {x: 1, y: 2, result: 0} +- {x: 2, y: -1, result: -2} +- {x: -2, y: 1, result: -2} diff --git a/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/02.division_operator/list.nan_inf.yaml b/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/02.division_operator/list.nan_inf.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b554d44f68377d8a061ea467cfc6fc852f4ac148 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/02.division_operator/list.nan_inf.yaml @@ -0,0 +1,17 @@ +--- # List of multiplications where NaN involved + +- {x: NaN, y: NaN, result: NaN} +- {x: NaN, y: 1.0, result: NaN} +- {x: 1.0, y: NaN, result: NaN} +- {x: NaN, y: 1.0, result: NaN} +- {x: NaN, y: INF, result: NaN} +- {x: INF, y: NaN, result: NaN} +- {x: NaN, y: -INF, result: NaN} +- {x: -INF, y: NaN, result: NaN} +- {x: 1.0, y: INF, result: 0.0} +- {x: -1.0, y: INF, result: -0.0} +- {x: 1.0, y: -INF, result: -0.0} +- {x: INF, y: INF, result: NaN} +- {x: 0.0, y: 0.0, result: NaN} +- {x: 1.0, y: 0.0, result: INF} +- {x: -1.0, y: 0.0, result: -INF} diff --git a/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/02.division_operator/nan_inf.sts b/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/02.division_operator/nan_inf.sts new file mode 100644 index 0000000000000000000000000000000000000000..cc3fc6fba49da7d065cad96985ca940ca23e9970 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/02.division_operator/nan_inf.sts @@ -0,0 +1,11 @@ +{% for ni in nan_inf %} +/*--- +desc: Division with NaN and INF +params: {{.ni.x}} / {{.ni.y}} == {{.ni.result}} +corner-case: true +---*/ + +function main(): void { + assert {{.ni.x}} / {{.ni.y}} == {{.ni.result}}; +} +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/02.division_operator/tbd.float_div_overflow.sts b/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/02.division_operator/tbd.float_div_overflow.sts new file mode 100644 index 0000000000000000000000000000000000000000..0ff200248b27c7c3871c3fe5e1c85b9edd239020 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/02.division_operator/tbd.float_div_overflow.sts @@ -0,0 +1,3 @@ +/*--- +desc: Float numbers division with overflow +---*/ \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/02.division_operator/tbd.float_division.sts b/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/02.division_operator/tbd.float_division.sts new file mode 100644 index 0000000000000000000000000000000000000000..530c28c15a717042c023d6b55d4d8e3d513110ff --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/02.division_operator/tbd.float_division.sts @@ -0,0 +1,3 @@ +/*--- +desc: Float numbers division +---*/ \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/02.division_operator/tbd.int_div_overflow.sts b/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/02.division_operator/tbd.int_div_overflow.sts new file mode 100644 index 0000000000000000000000000000000000000000..3f0af2948389c49e42ace4decf1909464fd3717b --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/02.division_operator/tbd.int_div_overflow.sts @@ -0,0 +1,3 @@ +/*--- +desc: Integer division with overflow +---*/ \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/03.remainder_operator/integer_remainder.sts b/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/03.remainder_operator/integer_remainder.sts new file mode 100644 index 0000000000000000000000000000000000000000..869ee87df9ea38110836007c15cd7fc5f0232c77 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/03.remainder_operator/integer_remainder.sts @@ -0,0 +1,10 @@ +{% for ni in integer_mod %} +/*--- +desc: Remainder of integer numbers +params: {{.ni.x}} % {{.ni.y}} == {{.ni.result}} +---*/ + +function main(): void { + assert {{.ni.x}} % {{.ni.y}} == {{.ni.result}}; +} +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/03.remainder_operator/list.integer_mod.yaml b/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/03.remainder_operator/list.integer_mod.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9026910fe086608926dc9b1ed435b3c0db42eaf0 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/03.remainder_operator/list.integer_mod.yaml @@ -0,0 +1,18 @@ +--- # List of integer remainder tests + +- {x: 0, y: 1, result: 0} +- {x: 1, y: 1, result: 0} +- {x: 0, y: -1, result: 0} +- {x: -1, y: -1, result: 0} + +- {x: 2, y: 2, result: 0} +- {x: 2, y: 1, result: 0} +- {x: 1, y: 2, result: 1} +- {x: 2, y: -1, result: 0} +- {x: -2, y: 1, result: 0} + +- {x: 5, y: 2, result: 1} +- {x: 7, y: 2, result: 1} +- {x: 7, y: 3, result: 1} +- {x: 3, y: 7, result: 3} +- {x: 8, y: 3, result: 2} diff --git a/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/03.remainder_operator/list.nan_inf.yaml b/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/03.remainder_operator/list.nan_inf.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d4a77a92c4a4fbfd1ca8082941d354a7e037f004 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/03.remainder_operator/list.nan_inf.yaml @@ -0,0 +1,27 @@ +--- # List of remainder tests where NaN and INF involved + +- {x: NaN, y: NaN, result: NaN} +- {x: NaN, y: 1.0, result: NaN} +- {x: 1.0, y: NaN, result: NaN} +- {x: NaN, y: -1.0, result: NaN} +- {x: NaN, y: INF, result: NaN} +- {x: INF, y: NaN, result: NaN} +- {x: NaN, y: -INF, result: NaN} +- {x: -INF, y: NaN, result: NaN} + +- {x: INF, y: 1.0, result: NaN} +- {x: -INF, y: 1.0, result: NaN} +- {x: 1.0, y: 0.0, result: NaN} +- {x: -1.0, y: 0.0, result: NaN} + +- {x: 1.0, y: INF, result: 1.0} +- {x: -1.0, y: -INF, result: -1.0} + +- {x: 0.0, y: 1.0, result: 0.0} +- {x: 0.0, y: -1.0, result: 0.0} + +- {x: 1.0, y: 1.0, result: 0.0} +- {x: 1.0, y: -1.0, result: 0.0} + +- {x: 2.0, y: 0.5, result: 0.0} +- {x: -2.0, y: 0.5, result: -0.0} diff --git a/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/03.remainder_operator/nan_inf.sts b/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/03.remainder_operator/nan_inf.sts new file mode 100644 index 0000000000000000000000000000000000000000..1bb8ba40ea9a639df58213a152c0c394c3921709 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/19.multiplicative_operators/03.remainder_operator/nan_inf.sts @@ -0,0 +1,11 @@ +{% for ni in nan_inf %} +/*--- +desc: Remainder with NaN, INF and zeroes +params: {{.ni.x}} % {{.ni.y}} == {{.ni.result}} +corner-case: true +---*/ + +function main(): void { + assert {{.ni.x}} % {{.ni.y}} == {{.ni.result}}; +} +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/20.additive_operators/01.string_concatenation_operator/list.string_concat.yaml b/migrator/test/staticTS/CTS/07.expressions/20.additive_operators/01.string_concatenation_operator/list.string_concat.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2b70c3f5b370ecb13d57e49a4deace075dc97c6b --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/20.additive_operators/01.string_concatenation_operator/list.string_concat.yaml @@ -0,0 +1,9 @@ +--- # List of string concatenation operation tests + +- {x: "\"\"", y: "\"\"", result: "\"\""} +- {x: "\"\"", y: "\"a\"", result: "\"a\""} +- {x: "\"a\"", y: "\"\"", result: "\"a\""} +- {x: "\"a\"", y: "\"a\"", result: "\"aa\""} +- {x: "\"aaa\"", y: "\"AAA\"", result: "\"aaaAAA\""} + +- {x: "\"фыва\"", y: "\"ФЫВА\"", result: "\"фываФЫВА\""} # Text in Russian diff --git a/migrator/test/staticTS/CTS/07.expressions/20.additive_operators/01.string_concatenation_operator/string_concat.sts b/migrator/test/staticTS/CTS/07.expressions/20.additive_operators/01.string_concatenation_operator/string_concat.sts new file mode 100644 index 0000000000000000000000000000000000000000..f0d2c63a3138eb1c36d04d1ea8cf1bd8a36be9b6 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/20.additive_operators/01.string_concatenation_operator/string_concat.sts @@ -0,0 +1,11 @@ +{% for sc in string_concat %} +/*--- +desc: String concatenation +params: | + {{.sc.x}} + {{.sc.y}} == {{.sc.result}} +---*/ + +function main(): void { + assert ({{.sc.x}} + {{.sc.y}}) == {{.sc.result}}; +} +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/20.additive_operators/02.additive_operators_for_numeric_types/list.nan_inf.yaml b/migrator/test/staticTS/CTS/07.expressions/20.additive_operators/02.additive_operators_for_numeric_types/list.nan_inf.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4e400d58d796bf6f942d9977b67c4cdc9e66b848 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/20.additive_operators/02.additive_operators_for_numeric_types/list.nan_inf.yaml @@ -0,0 +1,16 @@ +--- # List of addition tests where NaN, INF and zeroes involved + +- {x: NaN, y: NaN, result: NaN} +- {x: 0.0, y: NaN, result: NaN} +- {x: NaN, y: 0.0, result: NaN} +- {x: -INF, y: INF, result: NaN} +- {x: INF, y: -INF, result: NaN} +- {x: -INF, y: 1.0, result: -INF} +- {x: INF, y: 1.0, result: INF} +- {x: 0.0, y: -0.0, result: 0.0} +- {x: -0.0, y: 0.0, result: 0.0} +- {x: -0.0, y: -0.0, result: -0.0} +- {x: 0.0, y: 0.0, result: 0.0} +- {x: 0.0, y: 1.0, result: 1.0} +- {x: 1.0, y: 0.0, result: 1.0} +- {x: 1.0, y: -1.0, result: 0.0} diff --git a/migrator/test/staticTS/CTS/07.expressions/20.additive_operators/02.additive_operators_for_numeric_types/nan_inf.sts b/migrator/test/staticTS/CTS/07.expressions/20.additive_operators/02.additive_operators_for_numeric_types/nan_inf.sts new file mode 100644 index 0000000000000000000000000000000000000000..f3be1258baeff0b9072b2a1665c096a50d186370 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/20.additive_operators/02.additive_operators_for_numeric_types/nan_inf.sts @@ -0,0 +1,11 @@ +{% for ni in nan_inf %} +/*--- +desc: Additions with NaN and INF +params: {{.ni.x}} + {{.ni.y}} == {{.ni.result}} +corner-case: true +---*/ + +function main(): void { + assert ({{.ni.x}} + {{.ni.y}}) == {{.ni.result}}; +} +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/22.relational_operators/01.numerical_comparison_operators/float_comparison.sts b/migrator/test/staticTS/CTS/07.expressions/22.relational_operators/01.numerical_comparison_operators/float_comparison.sts new file mode 100644 index 0000000000000000000000000000000000000000..105299a383bb6d564611b8d88ca61fadb628a072 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/22.relational_operators/01.numerical_comparison_operators/float_comparison.sts @@ -0,0 +1,13 @@ +{% for fc in float_comparison %} + +/*--- +desc: Integer comparison {{.fc.xvalue}} {{.fc.op}} {{.fc.yvalue}} +---*/ + +function main(): void { + let x: {{.fc.xtype}} = {{.fc.xvalue}}; + let y: {{.fc.ytype}} = {{.fc.yvalue}}; + assert (x {{.fc.op}} y) == {{.fc.result}}; +} + +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/22.relational_operators/01.numerical_comparison_operators/integer_comparison.sts b/migrator/test/staticTS/CTS/07.expressions/22.relational_operators/01.numerical_comparison_operators/integer_comparison.sts new file mode 100644 index 0000000000000000000000000000000000000000..d25f36816fbea3d07778c9acd1a0c821b5646de5 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/22.relational_operators/01.numerical_comparison_operators/integer_comparison.sts @@ -0,0 +1,13 @@ +{% for ic in integer_comparison %} + +/*--- +desc: Integer comparison {{.ic.xvalue}} {{.ic.op}} {{.ic.yvalue}} +---*/ + +function main(): void { + let x: {{.ic.xtype}} = {{.ic.xvalue}}; + let y: {{.ic.ytype}} = {{.ic.yvalue}}; + assert (x {{.ic.op}} y) == {{.ic.result}}; +} + +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/22.relational_operators/01.numerical_comparison_operators/list.float_comparison.yaml b/migrator/test/staticTS/CTS/07.expressions/22.relational_operators/01.numerical_comparison_operators/list.float_comparison.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d543d624ff6d1650eaa5f52d85a3b276a963532c --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/22.relational_operators/01.numerical_comparison_operators/list.float_comparison.yaml @@ -0,0 +1,137 @@ +--- # List of integer comparison tests + +# >, no type promotion + +- {xtype: double, xvalue: 0.0, ytype: double, yvalue: 1.0, op: ">", result: "false"} +- {xtype: double, xvalue: 1.0, ytype: double, yvalue: 0.0, op: ">", result: "true"} +- {xtype: double, xvalue: -1.0, ytype: double, yvalue: 0.0, op: ">", result: "false"} +- {xtype: double, xvalue: 0.0, ytype: double, yvalue: -1.0, op: ">", result: "true"} + +# >, with type promotion + +- {xtype: float, xvalue: 0.0, ytype: float, yvalue: 1.0, op: ">", result: "false"} +- {xtype: float, xvalue: 1.0, ytype: float, yvalue: 0.0, op: ">", result: "true"} +- {xtype: float, xvalue: -1.0, ytype: float, yvalue: 0.0, op: ">", result: "false"} +- {xtype: float, xvalue: 0.0, ytype: float, yvalue: -1.0, op: ">", result: "true"} + +# <, no type promotion + +- {xtype: double, xvalue: 0.0, ytype: double, yvalue: 1.0, op: "<", result: "true"} +- {xtype: double, xvalue: 1.0, ytype: double, yvalue: 0.0, op: "<", result: "false"} +- {xtype: double, xvalue: -1.0, ytype: double, yvalue: 0.0, op: "<", result: "true"} +- {xtype: double, xvalue: 0.0, ytype: double, yvalue: -1.0, op: "<", result: "false"} + +# <, with type promotion + +- {xtype: float, xvalue: 0.0, ytype: float, yvalue: 1.0, op: "<", result: "true"} +- {xtype: float, xvalue: 1.0, ytype: float, yvalue: 0.0, op: "<", result: "false"} +- {xtype: float, xvalue: -1.0, ytype: float, yvalue: 0.0, op: "<", result: "true"} +- {xtype: float, xvalue: 0.0, ytype: float, yvalue: -1.0, op: "<", result: "false"} + +# >=, no type promotion + +- {xtype: double, xvalue: 0.0, ytype: double, yvalue: 1.0, op: ">=", result: "false"} +- {xtype: double, xvalue: 1.0, ytype: double, yvalue: 0.0, op: ">=", result: "true"} +- {xtype: double, xvalue: -1.0, ytype: double, yvalue: 0.0, op: ">=", result: "false"} +- {xtype: double, xvalue: 0.0, ytype: double, yvalue: -1.0, op: ">=", result: "true"} + +# >=, with type promotion + +- {xtype: double, xvalue: 0.0, ytype: float, yvalue: 1.0, op: ">=", result: "false"} +- {xtype: double, xvalue: 1.0, ytype: float, yvalue: 0.0, op: ">=", result: "true"} +- {xtype: double, xvalue: -1.0, ytype: float, yvalue: 0.0, op: ">=", result: "false"} +- {xtype: double, xvalue: 0.0, ytype: float, yvalue: -1.0, op: ">=", result: "true"} + +# <=, no type promotion + +- {xtype: double, xvalue: 0.0, ytype: double, yvalue: 1.0, op: "<=", result: "true"} +- {xtype: double, xvalue: 1.0, ytype: double, yvalue: 0.0, op: "<=", result: "false"} +- {xtype: double, xvalue: -1.0, ytype: double, yvalue: 0.0, op: "<=", result: "true"} +- {xtype: double, xvalue: 0.0, ytype: double, yvalue: -1.0, op: "<=", result: "false"} + +# <=, with type promotion + +- {xtype: float, xvalue: 0.0, ytype: float, yvalue: 1.0, op: "<=", result: "true"} +- {xtype: float, xvalue: 1.0, ytype: float, yvalue: 0.0, op: "<=", result: "false"} +- {xtype: float, xvalue: -1.0, ytype: float, yvalue: 0.0, op: "<=", result: "true"} +- {xtype: float, xvalue: 0.0, ytype: float, yvalue: -1.0, op: "<=", result: "false"} + +# >=, <= + +- {xtype: float, xvalue: 0.0, ytype: float, yvalue: -0.0, op: ">=", result: "true"} +- {xtype: float, xvalue: 0.0, ytype: float, yvalue: -0.0, op: "<=", result: "true"} + +- {xtype: float, xvalue: 1.0, ytype: float, yvalue: 1.0, op: ">=", result: "true"} +- {xtype: float, xvalue: 1.0, ytype: float, yvalue: 1.0, op: "<=", result: "true"} + +- {xtype: float, xvalue: -1.0, ytype: float, yvalue: -1.0, op: ">=", result: "true"} +- {xtype: float, xvalue: -1.0, ytype: float, yvalue: -1.0, op: "<=", result: "true"} + + +- {xtype: double, xvalue: 0.0, ytype: double, yvalue: -0.0, op: ">=", result: "true"} +- {xtype: double, xvalue: 0.0, ytype: double, yvalue: -0.0, op: "<=", result: "true"} + +- {xtype: double, xvalue: 1.0, ytype: double, yvalue: 1.0, op: ">=", result: "true"} +- {xtype: double, xvalue: 1.0, ytype: double, yvalue: 1.0, op: "<=", result: "true"} + +- {xtype: double, xvalue: -1.0, ytype: double, yvalue: -1.0, op: ">=", result: "true"} +- {xtype: double, xvalue: -1.0, ytype: double, yvalue: -1.0, op: "<=", result: "true"} + +# NaNs + +- {xtype: float, xvalue: NaN, ytype: float, yvalue: 0.0, op: ">", result: "false"} +- {xtype: float, xvalue: 0.0, ytype: float, yvalue: NaN, op: ">", result: "false"} + +- {xtype: float, xvalue: NaN, ytype: float, yvalue: 0.0, op: "<", result: "false"} +- {xtype: float, xvalue: 0.0, ytype: float, yvalue: NaN, op: "<", result: "false"} + +- {xtype: float, xvalue: NaN, ytype: float, yvalue: 0.0, op: ">=", result: "false"} +- {xtype: float, xvalue: 0.0, ytype: float, yvalue: NaN, op: ">=", result: "false"} + +- {xtype: float, xvalue: NaN, ytype: float, yvalue: 0.0, op: "<=", result: "false"} +- {xtype: float, xvalue: 0.0, ytype: float, yvalue: NaN, op: "<=", result: "false"} + +- {xtype: double, xvalue: NaN, ytype: double, yvalue: 0.0, op: ">", result: "false"} +- {xtype: double, xvalue: 0.0, ytype: double, yvalue: NaN, op: ">", result: "false"} + +- {xtype: double, xvalue: NaN, ytype: double, yvalue: 0.0, op: "<", result: "false"} +- {xtype: double, xvalue: 0.0, ytype: double, yvalue: NaN, op: "<", result: "false"} + +- {xtype: double, xvalue: NaN, ytype: double, yvalue: 0.0, op: ">=", result: "false"} +- {xtype: double, xvalue: 0.0, ytype: double, yvalue: NaN, op: ">=", result: "false"} + +- {xtype: double, xvalue: NaN, ytype: double, yvalue: 0.0, op: "<=", result: "false"} +- {xtype: double, xvalue: 0.0, ytype: double, yvalue: NaN, op: "<=", result: "false"} + +# INFs + +- {xtype: float, xvalue: -INF, ytype: float, yvalue: 0.0, op: "<", result: "true"} +- {xtype: float, xvalue: -INF, ytype: float, yvalue: 0.0, op: "<=", result: "true"} +- {xtype: float, xvalue: -INF, ytype: float, yvalue: 0.0, op: ">", result: "false"} +- {xtype: float, xvalue: -INF, ytype: float, yvalue: 0.0, op: ">=", result: "false"} + +- {xtype: float, xvalue: 0.0, ytype: float, yvalue: INF, op: "<", result: "true"} +- {xtype: float, xvalue: 0.0, ytype: float, yvalue: INF, op: "<=", result: "true"} +- {xtype: float, xvalue: 0.0, ytype: float, yvalue: INF, op: ">", result: "false"} +- {xtype: float, xvalue: 0.0, ytype: float, yvalue: INF, op: ">=", result: "false"} + +- {xtype: float, xvalue: -INF, ytype: float, yvalue: INF, op: "<", result: "true"} +- {xtype: float, xvalue: -INF, ytype: float, yvalue: INF, op: "<=", result: "true"} +- {xtype: float, xvalue: -INF, ytype: float, yvalue: INF, op: ">", result: "false"} +- {xtype: float, xvalue: -INF, ytype: float, yvalue: INF, op: ">=", result: "false"} + + +- {xtype: double, xvalue: -INF, ytype: double, yvalue: 0.0, op: "<", result: "true"} +- {xtype: double, xvalue: -INF, ytype: double, yvalue: 0.0, op: "<=", result: "true"} +- {xtype: double, xvalue: -INF, ytype: double, yvalue: 0.0, op: ">", result: "false"} +- {xtype: double, xvalue: -INF, ytype: double, yvalue: 0.0, op: ">=", result: "false"} + +- {xtype: double, xvalue: 0.0, ytype: double, yvalue: INF, op: "<", result: "true"} +- {xtype: double, xvalue: 0.0, ytype: double, yvalue: INF, op: "<=", result: "true"} +- {xtype: double, xvalue: 0.0, ytype: double, yvalue: INF, op: ">", result: "false"} +- {xtype: double, xvalue: 0.0, ytype: double, yvalue: INF, op: ">=", result: "false"} + +- {xtype: double, xvalue: -INF, ytype: double, yvalue: INF, op: "<", result: "true"} +- {xtype: double, xvalue: -INF, ytype: double, yvalue: INF, op: "<=", result: "true"} +- {xtype: double, xvalue: -INF, ytype: double, yvalue: INF, op: ">", result: "false"} +- {xtype: double, xvalue: -INF, ytype: double, yvalue: INF, op: ">=", result: "false"} diff --git a/migrator/test/staticTS/CTS/07.expressions/22.relational_operators/01.numerical_comparison_operators/list.integer_comparison.yaml b/migrator/test/staticTS/CTS/07.expressions/22.relational_operators/01.numerical_comparison_operators/list.integer_comparison.yaml new file mode 100644 index 0000000000000000000000000000000000000000..da04ae629765a4010d5f44cbec400feb8ce8128c --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/22.relational_operators/01.numerical_comparison_operators/list.integer_comparison.yaml @@ -0,0 +1,69 @@ +--- # List of integer comparison tests + +# >, no type promotion + +- {xtype: int, xvalue: 0, ytype: int, yvalue: 1, op: ">", result: "false"} +- {xtype: int, xvalue: 1, ytype: int, yvalue: 0, op: ">", result: "true"} +- {xtype: int, xvalue: -1, ytype: int, yvalue: 0, op: ">", result: "false"} +- {xtype: int, xvalue: 0, ytype: int, yvalue: -1, op: ">", result: "true"} + +# >, with type promotion + +- {xtype: byte, xvalue: 0, ytype: byte, yvalue: 1, op: ">", result: "false"} +- {xtype: byte, xvalue: 1, ytype: byte, yvalue: 0, op: ">", result: "true"} +- {xtype: byte, xvalue: -1, ytype: byte, yvalue: 0, op: ">", result: "false"} +- {xtype: byte, xvalue: 0, ytype: byte, yvalue: -1, op: ">", result: "true"} + +# <, no type promotion + +- {xtype: int, xvalue: 0, ytype: int, yvalue: 1, op: "<", result: "true"} +- {xtype: int, xvalue: 1, ytype: int, yvalue: 0, op: "<", result: "false"} +- {xtype: int, xvalue: -1, ytype: int, yvalue: 0, op: "<", result: "true"} +- {xtype: int, xvalue: 0, ytype: int, yvalue: -1, op: "<", result: "false"} + +# <, with type promotion + +- {xtype: byte, xvalue: 0, ytype: byte, yvalue: 1, op: "<", result: "true"} +- {xtype: byte, xvalue: 1, ytype: byte, yvalue: 0, op: "<", result: "false"} +- {xtype: byte, xvalue: -1, ytype: byte, yvalue: 0, op: "<", result: "true"} +- {xtype: byte, xvalue: 0, ytype: byte, yvalue: -1, op: "<", result: "false"} + +# >=, no type promotion + +- {xtype: int, xvalue: 0, ytype: int, yvalue: 1, op: ">=", result: "false"} +- {xtype: int, xvalue: 1, ytype: int, yvalue: 0, op: ">=", result: "true"} +- {xtype: int, xvalue: -1, ytype: int, yvalue: 0, op: ">=", result: "false"} +- {xtype: int, xvalue: 0, ytype: int, yvalue: -1, op: ">=", result: "true"} + +# >=, with type promotion + +- {xtype: int, xvalue: 0, ytype: byte, yvalue: 1, op: ">=", result: "false"} +- {xtype: int, xvalue: 1, ytype: byte, yvalue: 0, op: ">=", result: "true"} +- {xtype: int, xvalue: -1, ytype: byte, yvalue: 0, op: ">=", result: "false"} +- {xtype: int, xvalue: 0, ytype: byte, yvalue: -1, op: ">=", result: "true"} + +# <=, no type promotion + +- {xtype: int, xvalue: 0, ytype: int, yvalue: 1, op: "<=", result: "true"} +- {xtype: int, xvalue: 1, ytype: int, yvalue: 0, op: "<=", result: "false"} +- {xtype: int, xvalue: -1, ytype: int, yvalue: 0, op: "<=", result: "true"} +- {xtype: int, xvalue: 0, ytype: int, yvalue: -1, op: "<=", result: "false"} + +# <=, with type promotion + +- {xtype: byte, xvalue: 0, ytype: byte, yvalue: 1, op: "<=", result: "true"} +- {xtype: byte, xvalue: 1, ytype: byte, yvalue: 0, op: "<=", result: "false"} +- {xtype: byte, xvalue: -1, ytype: byte, yvalue: 0, op: "<=", result: "true"} +- {xtype: byte, xvalue: 0, ytype: byte, yvalue: -1, op: "<=", result: "false"} + +# >=, <= + +- {xtype: int, xvalue: 0, ytype: int, yvalue: -0, op: ">=", result: "true"} +- {xtype: int, xvalue: 0, ytype: int, yvalue: -0, op: "<=", result: "true"} + +- {xtype: int, xvalue: 1, ytype: int, yvalue: 1, op: ">=", result: "true"} +- {xtype: int, xvalue: 1, ytype: int, yvalue: 1, op: "<=", result: "true"} + +- {xtype: int, xvalue: -1, ytype: int, yvalue: -1, op: ">=", result: "true"} +- {xtype: int, xvalue: -1, ytype: int, yvalue: -1, op: "<=", result: "true"} + diff --git a/migrator/test/staticTS/CTS/07.expressions/23.type_comparison_operator/instanceof.sts b/migrator/test/staticTS/CTS/07.expressions/23.type_comparison_operator/instanceof.sts new file mode 100644 index 0000000000000000000000000000000000000000..b7c54dff12603214ed56844f8df8a03a364943e0 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/23.type_comparison_operator/instanceof.sts @@ -0,0 +1,19 @@ +{% for io in instanceof %} +/*--- +desc: instanceof operator test +params: | + {{.io.negation}}({{.io.left}} instanceof {{.io.right}}) +---*/ + +class A {} +class B {} + +function main(): void { + let a = new A; + let b = new B; + let n = null; + + assert {{.io.negation}}({{.io.left}} instanceof {{.io.right}}); +} + +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/23.type_comparison_operator/list.instanceof.yaml b/migrator/test/staticTS/CTS/07.expressions/23.type_comparison_operator/list.instanceof.yaml new file mode 100644 index 0000000000000000000000000000000000000000..fe6279a2764928543b9df91a792691cf1877658d --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/23.type_comparison_operator/list.instanceof.yaml @@ -0,0 +1,8 @@ +--- # List of instanceof tests + +- {left: a, right: A, negation: ""} +- {left: a, right: B, negation: "!"} +- {left: b, right: A, negation: "!"} +- {left: b, right: B, negation: ""} +- {left: n, right: A, negation: "!"} +- {left: n, right: B, negation: "!"} diff --git a/migrator/test/staticTS/CTS/07.expressions/24.equality_operator/01.numerical_equality_operators/float_equality_00.sts b/migrator/test/staticTS/CTS/07.expressions/24.equality_operator/01.numerical_equality_operators/float_equality_00.sts new file mode 100644 index 0000000000000000000000000000000000000000..03fac4cd4f68e2f6f337050e6f910ceb1347e86a --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/24.equality_operator/01.numerical_equality_operators/float_equality_00.sts @@ -0,0 +1,13 @@ +/*--- +desc: Floating number equality +corner-case: true +---*/ + +function main(): void { + let a = 0.1; + assert a != NaN; + assert NaN != a; + + assert !(a == NaN); + assert !(NaN == a); +} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/24.equality_operator/01.numerical_equality_operators/float_equality_01.sts b/migrator/test/staticTS/CTS/07.expressions/24.equality_operator/01.numerical_equality_operators/float_equality_01.sts new file mode 100644 index 0000000000000000000000000000000000000000..5c0a6a84a458ff46b6166b19cfe0fdd58c6ab078 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/24.equality_operator/01.numerical_equality_operators/float_equality_01.sts @@ -0,0 +1,9 @@ +/*--- +desc: Floating number equality +corner-case: true +---*/ + +function main(): void { + let a = NaN; + assert a != a; +} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/24.equality_operator/01.numerical_equality_operators/float_equality_02.sts b/migrator/test/staticTS/CTS/07.expressions/24.equality_operator/01.numerical_equality_operators/float_equality_02.sts new file mode 100644 index 0000000000000000000000000000000000000000..03db42676a337437d7bab90f8a81ee2fa76d851c --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/24.equality_operator/01.numerical_equality_operators/float_equality_02.sts @@ -0,0 +1,11 @@ +/*--- +desc: Floating number equality +corner-case: true +---*/ + +function main(): void { + let a = +0.0; + let b = -0.0; + + assert a == b; +} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/24.equality_operator/01.numerical_equality_operators/float_equality_03.sts b/migrator/test/staticTS/CTS/07.expressions/24.equality_operator/01.numerical_equality_operators/float_equality_03.sts new file mode 100644 index 0000000000000000000000000000000000000000..68f66bf0da55b3b0af66f44134117420792ce793 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/24.equality_operator/01.numerical_equality_operators/float_equality_03.sts @@ -0,0 +1,12 @@ +/*--- +desc: Floating number equality +corner-case: true +---*/ + +function main(): void { + let a = 0.1; + let b = 0.0; + + assert a != b; + assert b != a; +} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/24.equality_operator/01.numerical_equality_operators/float_equality_04.sts b/migrator/test/staticTS/CTS/07.expressions/24.equality_operator/01.numerical_equality_operators/float_equality_04.sts new file mode 100644 index 0000000000000000000000000000000000000000..5e4ece226414592898fbbcc4d7e4ecd427457d5f --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/24.equality_operator/01.numerical_equality_operators/float_equality_04.sts @@ -0,0 +1,13 @@ +/*--- +desc: Floating number equality +corner-case: true +---*/ + +function main(): void { + let a = 0.1; + assert a != INF; + assert INF != a; + assert a != -INF; + assert -INF != a; + +} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/24.equality_operator/02.boolean_equality_operators/boolean_eq.sts b/migrator/test/staticTS/CTS/07.expressions/24.equality_operator/02.boolean_equality_operators/boolean_eq.sts new file mode 100644 index 0000000000000000000000000000000000000000..3a4c00122c238ddba7442202d79895668f310062 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/24.equality_operator/02.boolean_equality_operators/boolean_eq.sts @@ -0,0 +1,11 @@ +{% for eq in boolean_eq %} +/*--- +desc: Boolean equality +params: {{.eq.left}} {{.eq.op}} {{.eq.right}} is {{.eq.result}} +---*/ + +function main(): void { + assert ({{.eq.left}} {{.eq.op}} {{.eq.right}}) == {{.eq.result}}; +} + +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/24.equality_operator/02.boolean_equality_operators/list.boolean_eq.yaml b/migrator/test/staticTS/CTS/07.expressions/24.equality_operator/02.boolean_equality_operators/list.boolean_eq.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d2d4887cf531c7ec824f0e13a52cc12b4417350e --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/24.equality_operator/02.boolean_equality_operators/list.boolean_eq.yaml @@ -0,0 +1,11 @@ +--- # List of boolean equality operators + +- {left: "true", right: "true", op: "==", result: "true"} +- {left: "true", right: "false", op: "==", result: "false"} +- {left: "false", right: "true", op: "==", result: "false"} +- {left: "false", right: "false", op: "==", result: "true"} + +- {left: "true", right: "true", op: "!=", result: "false"} +- {left: "true", right: "false", op: "!=", result: "true"} +- {left: "false", right: "true", op: "!=", result: "true"} +- {left: "false", right: "false", op: "!=", result: "false"} diff --git a/migrator/test/staticTS/CTS/07.expressions/24.equality_operator/03.string_equality_operators/list.string_eq.yaml b/migrator/test/staticTS/CTS/07.expressions/24.equality_operator/03.string_equality_operators/list.string_eq.yaml new file mode 100644 index 0000000000000000000000000000000000000000..25b0e6ab0ec519163f2c1b8bb9a9f6db60cfcd42 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/24.equality_operator/03.string_equality_operators/list.string_eq.yaml @@ -0,0 +1,18 @@ +--- # List of boolean equality operators + +- {left: "\"a\"", right: "\"a\"", op: "==", result: "true"} +- {left: "\"aa\"", right: "\"aa\"", op: "==", result: "true"} +- {left: "\"aaa\"", right: "\"aaa\"", op: "==", result: "true"} + +- {left: "\"a\"", right: "\"b\"", op: "==", result: "false"} +- {left: "\"aa\"", right: "\"ba\"", op: "==", result: "false"} +- {left: "\"aaa\"", right: "\"aba\"", op: "==", result: "false"} + +- {left: "\"a\"", right: "\"a\"", op: "!=", result: "false"} +- {left: "\"aa\"", right: "\"aa\"", op: "!=", result: "false"} +- {left: "\"aaa\"", right: "\"aaa\"", op: "!=", result: "false"} + +- {left: "\"a\"", right: "\"b\"", op: "!=", result: "true"} +- {left: "\"aa\"", right: "\"ba\"", op: "!=", result: "true"} +- {left: "\"aaa\"", right: "\"aba\"", op: "!=", result: "true"} + diff --git a/migrator/test/staticTS/CTS/07.expressions/24.equality_operator/03.string_equality_operators/string_eq.sts b/migrator/test/staticTS/CTS/07.expressions/24.equality_operator/03.string_equality_operators/string_eq.sts new file mode 100644 index 0000000000000000000000000000000000000000..d7abd70fa26a59a8728e29c164e577f310fb02de --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/24.equality_operator/03.string_equality_operators/string_eq.sts @@ -0,0 +1,14 @@ +{% for eq in string_eq %} +/*--- +desc: String equality +params: | + {{.eq.left}} {{.eq.op}} {{.eq.right}} is {{.eq.result}} +---*/ + +function main(): void { + let a: String = {{.eq.left}}; + let b: String = {{.eq.right}}; + assert (a {{.eq.op}} b) == {{.eq.result}}; +} + +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/24.equality_operator/general_equality_00.sts b/migrator/test/staticTS/CTS/07.expressions/24.equality_operator/general_equality_00.sts new file mode 100644 index 0000000000000000000000000000000000000000..8cfaf2d30fac27dbaf3f13ab2daeb9318c6a096a --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/24.equality_operator/general_equality_00.sts @@ -0,0 +1,14 @@ +/*--- +desc: Equality operators, common rules +---*/ + +function main(): void { + let a = 0; + let b = 0; + let c = 1; + + let cmp1 = a == b != c; + let cmp2 = (a == b) != c; + + assert cmp1 == cmp2; +} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/24.equality_operator/general_equality_01.sts b/migrator/test/staticTS/CTS/07.expressions/24.equality_operator/general_equality_01.sts new file mode 100644 index 0000000000000000000000000000000000000000..491b19eb25f4ab31c42bbcdec2b1f3f7be60764a --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/24.equality_operator/general_equality_01.sts @@ -0,0 +1,11 @@ +/*--- +desc: Equality operators, common rules +---*/ + +function main(): void { + let a = 0; + let b = 0; + let c = 1; + + assert a < c == b < c; +} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/24.equality_operator/general_equality_02.sts b/migrator/test/staticTS/CTS/07.expressions/24.equality_operator/general_equality_02.sts new file mode 100644 index 0000000000000000000000000000000000000000..b7dbe1872648d897a8a97b58da1f9d7df4c25db0 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/24.equality_operator/general_equality_02.sts @@ -0,0 +1,13 @@ +/*--- +desc: Equality operators, common rules +---*/ + +function main(): void { + let a = 0; + let b = 1; + + let cmp1 = a != b; + let cmp2 = !(a == b); + + assert cmp1 == cmp2; +} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/25.bitwise_and_logical_operators/01.integer_bitwise_operators/gen.go.txt b/migrator/test/staticTS/CTS/07.expressions/25.bitwise_and_logical_operators/01.integer_bitwise_operators/gen.go.txt new file mode 100644 index 0000000000000000000000000000000000000000..6a1946062d2b8381d7ec396b81dbb042ef8fc260 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/25.bitwise_and_logical_operators/01.integer_bitwise_operators/gen.go.txt @@ -0,0 +1,45 @@ +package main + +import "fmt" + +var and8_op = func(x uint8, y uint8) uint8 { + return x & y +} + +var or8_op = func(x uint8, y uint8) uint8 { + return x | y +} + +var xor8_op = func(x uint8, y uint8) uint8 { + return x ^ y +} + +var data = []uint8{ + 0b00000000, + 0b01010101, + 0b10101010, + 0b00001111, + 0b11110000, + 0b00110011, + 0b11001100, + 0b10000001, + 0b10011001, + 0b01100110, +} + +func main() { + op := "\"^\"" + op1 := "xor" + _op := xor8_op + fmt.Println("--- # List of integer " + op1 + " " + op + " operations") + + for _, x := range data { + for _, y := range data { + res := _op(x, y) + fmt.Printf( + "- {xorigin: %4d, yorigin: %4d, op: %s, dest: %4d, xbits: \"0b%08b\", xbits: \"0b%08b\", dbits: \"0b%08b\"}\n", + int8(x), int8(y), op, int8(res), x, y, res, + ) + } + } +} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/25.bitwise_and_logical_operators/01.integer_bitwise_operators/integer_and.sts b/migrator/test/staticTS/CTS/07.expressions/25.bitwise_and_logical_operators/01.integer_bitwise_operators/integer_and.sts new file mode 100644 index 0000000000000000000000000000000000000000..25fd6911a02ceab9a1dce6392f143cd78c52f8c2 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/25.bitwise_and_logical_operators/01.integer_bitwise_operators/integer_and.sts @@ -0,0 +1,15 @@ +{% for i in integer_and %} + +/*--- +desc: Integer 'and' operation +params: {{.i.xorigin}} {{.i.op}} {{.i.yorigin}} == {{.i.dest}} ({{.i.xbits}} {{.i.op}} {{.i.ybits}} == {{.i.dbits}} ) +---*/ + +function main(): void { + let x: byte = {{.i.xorigin}}; + let y: byte = {{.i.yorigin}}; + let dest: byte = {{.i.dest}}; + assert (x {{.i.op}} y) == dest; +} + +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/25.bitwise_and_logical_operators/01.integer_bitwise_operators/integer_or.sts b/migrator/test/staticTS/CTS/07.expressions/25.bitwise_and_logical_operators/01.integer_bitwise_operators/integer_or.sts new file mode 100644 index 0000000000000000000000000000000000000000..1578c5aa930e55fb62a246ee9a77ee3163e5d91b --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/25.bitwise_and_logical_operators/01.integer_bitwise_operators/integer_or.sts @@ -0,0 +1,15 @@ +{% for i in integer_or %} + +/*--- +desc: Integer 'or' operation +params: {{.i.xorigin}} {{.i.op}} {{.i.yorigin}} == {{.i.dest}} ({{.i.xbits}} {{.i.op}} {{.i.ybits}} == {{.i.dbits}} ) +---*/ + +function main(): void { + let x: byte = {{.i.xorigin}}; + let y: byte = {{.i.yorigin}}; + let dest: byte = {{.i.dest}}; + assert (x {{.i.op}} y) == dest; +} + +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/25.bitwise_and_logical_operators/01.integer_bitwise_operators/integer_xor.sts b/migrator/test/staticTS/CTS/07.expressions/25.bitwise_and_logical_operators/01.integer_bitwise_operators/integer_xor.sts new file mode 100644 index 0000000000000000000000000000000000000000..893197551483d58ea6771c7895298478602a7eb2 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/25.bitwise_and_logical_operators/01.integer_bitwise_operators/integer_xor.sts @@ -0,0 +1,15 @@ +{% for i in integer_xor %} + +/*--- +desc: Integer 'xor' operation +params: {{.i.xorigin}} {{.i.op}} {{.i.yorigin}} == {{.i.dest}} ({{.i.xbits}} {{.i.op}} {{.i.ybits}} == {{.i.dbits}} ) +---*/ + +function main(): void { + let x: byte = {{.i.xorigin}}; + let y: byte = {{.i.yorigin}}; + let dest: byte = {{.i.dest}}; + assert (x {{.i.op}} y) == dest; +} + +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/25.bitwise_and_logical_operators/01.integer_bitwise_operators/list.integer_and.yaml b/migrator/test/staticTS/CTS/07.expressions/25.bitwise_and_logical_operators/01.integer_bitwise_operators/list.integer_and.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7fcc8d3dae101797aac27f1990ee810bc0087af6 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/25.bitwise_and_logical_operators/01.integer_bitwise_operators/list.integer_and.yaml @@ -0,0 +1,101 @@ +--- # List of integer and "&" operations +- {xorigin: 0, yorigin: 0, op: "&", dest: 0, xbits: "0b00000000", xbits: "0b00000000", dbits: "0b00000000"} +- {xorigin: 0, yorigin: 85, op: "&", dest: 0, xbits: "0b00000000", xbits: "0b01010101", dbits: "0b00000000"} +- {xorigin: 0, yorigin: -86, op: "&", dest: 0, xbits: "0b00000000", xbits: "0b10101010", dbits: "0b00000000"} +- {xorigin: 0, yorigin: 15, op: "&", dest: 0, xbits: "0b00000000", xbits: "0b00001111", dbits: "0b00000000"} +- {xorigin: 0, yorigin: -16, op: "&", dest: 0, xbits: "0b00000000", xbits: "0b11110000", dbits: "0b00000000"} +- {xorigin: 0, yorigin: 51, op: "&", dest: 0, xbits: "0b00000000", xbits: "0b00110011", dbits: "0b00000000"} +- {xorigin: 0, yorigin: -52, op: "&", dest: 0, xbits: "0b00000000", xbits: "0b11001100", dbits: "0b00000000"} +- {xorigin: 0, yorigin: -127, op: "&", dest: 0, xbits: "0b00000000", xbits: "0b10000001", dbits: "0b00000000"} +- {xorigin: 0, yorigin: -103, op: "&", dest: 0, xbits: "0b00000000", xbits: "0b10011001", dbits: "0b00000000"} +- {xorigin: 0, yorigin: 102, op: "&", dest: 0, xbits: "0b00000000", xbits: "0b01100110", dbits: "0b00000000"} +- {xorigin: 85, yorigin: 0, op: "&", dest: 0, xbits: "0b01010101", xbits: "0b00000000", dbits: "0b00000000"} +- {xorigin: 85, yorigin: 85, op: "&", dest: 85, xbits: "0b01010101", xbits: "0b01010101", dbits: "0b01010101"} +- {xorigin: 85, yorigin: -86, op: "&", dest: 0, xbits: "0b01010101", xbits: "0b10101010", dbits: "0b00000000"} +- {xorigin: 85, yorigin: 15, op: "&", dest: 5, xbits: "0b01010101", xbits: "0b00001111", dbits: "0b00000101"} +- {xorigin: 85, yorigin: -16, op: "&", dest: 80, xbits: "0b01010101", xbits: "0b11110000", dbits: "0b01010000"} +- {xorigin: 85, yorigin: 51, op: "&", dest: 17, xbits: "0b01010101", xbits: "0b00110011", dbits: "0b00010001"} +- {xorigin: 85, yorigin: -52, op: "&", dest: 68, xbits: "0b01010101", xbits: "0b11001100", dbits: "0b01000100"} +- {xorigin: 85, yorigin: -127, op: "&", dest: 1, xbits: "0b01010101", xbits: "0b10000001", dbits: "0b00000001"} +- {xorigin: 85, yorigin: -103, op: "&", dest: 17, xbits: "0b01010101", xbits: "0b10011001", dbits: "0b00010001"} +- {xorigin: 85, yorigin: 102, op: "&", dest: 68, xbits: "0b01010101", xbits: "0b01100110", dbits: "0b01000100"} +- {xorigin: -86, yorigin: 0, op: "&", dest: 0, xbits: "0b10101010", xbits: "0b00000000", dbits: "0b00000000"} +- {xorigin: -86, yorigin: 85, op: "&", dest: 0, xbits: "0b10101010", xbits: "0b01010101", dbits: "0b00000000"} +- {xorigin: -86, yorigin: -86, op: "&", dest: -86, xbits: "0b10101010", xbits: "0b10101010", dbits: "0b10101010"} +- {xorigin: -86, yorigin: 15, op: "&", dest: 10, xbits: "0b10101010", xbits: "0b00001111", dbits: "0b00001010"} +- {xorigin: -86, yorigin: -16, op: "&", dest: -96, xbits: "0b10101010", xbits: "0b11110000", dbits: "0b10100000"} +- {xorigin: -86, yorigin: 51, op: "&", dest: 34, xbits: "0b10101010", xbits: "0b00110011", dbits: "0b00100010"} +- {xorigin: -86, yorigin: -52, op: "&", dest: -120, xbits: "0b10101010", xbits: "0b11001100", dbits: "0b10001000"} +- {xorigin: -86, yorigin: -127, op: "&", dest: -128, xbits: "0b10101010", xbits: "0b10000001", dbits: "0b10000000"} +- {xorigin: -86, yorigin: -103, op: "&", dest: -120, xbits: "0b10101010", xbits: "0b10011001", dbits: "0b10001000"} +- {xorigin: -86, yorigin: 102, op: "&", dest: 34, xbits: "0b10101010", xbits: "0b01100110", dbits: "0b00100010"} +- {xorigin: 15, yorigin: 0, op: "&", dest: 0, xbits: "0b00001111", xbits: "0b00000000", dbits: "0b00000000"} +- {xorigin: 15, yorigin: 85, op: "&", dest: 5, xbits: "0b00001111", xbits: "0b01010101", dbits: "0b00000101"} +- {xorigin: 15, yorigin: -86, op: "&", dest: 10, xbits: "0b00001111", xbits: "0b10101010", dbits: "0b00001010"} +- {xorigin: 15, yorigin: 15, op: "&", dest: 15, xbits: "0b00001111", xbits: "0b00001111", dbits: "0b00001111"} +- {xorigin: 15, yorigin: -16, op: "&", dest: 0, xbits: "0b00001111", xbits: "0b11110000", dbits: "0b00000000"} +- {xorigin: 15, yorigin: 51, op: "&", dest: 3, xbits: "0b00001111", xbits: "0b00110011", dbits: "0b00000011"} +- {xorigin: 15, yorigin: -52, op: "&", dest: 12, xbits: "0b00001111", xbits: "0b11001100", dbits: "0b00001100"} +- {xorigin: 15, yorigin: -127, op: "&", dest: 1, xbits: "0b00001111", xbits: "0b10000001", dbits: "0b00000001"} +- {xorigin: 15, yorigin: -103, op: "&", dest: 9, xbits: "0b00001111", xbits: "0b10011001", dbits: "0b00001001"} +- {xorigin: 15, yorigin: 102, op: "&", dest: 6, xbits: "0b00001111", xbits: "0b01100110", dbits: "0b00000110"} +- {xorigin: -16, yorigin: 0, op: "&", dest: 0, xbits: "0b11110000", xbits: "0b00000000", dbits: "0b00000000"} +- {xorigin: -16, yorigin: 85, op: "&", dest: 80, xbits: "0b11110000", xbits: "0b01010101", dbits: "0b01010000"} +- {xorigin: -16, yorigin: -86, op: "&", dest: -96, xbits: "0b11110000", xbits: "0b10101010", dbits: "0b10100000"} +- {xorigin: -16, yorigin: 15, op: "&", dest: 0, xbits: "0b11110000", xbits: "0b00001111", dbits: "0b00000000"} +- {xorigin: -16, yorigin: -16, op: "&", dest: -16, xbits: "0b11110000", xbits: "0b11110000", dbits: "0b11110000"} +- {xorigin: -16, yorigin: 51, op: "&", dest: 48, xbits: "0b11110000", xbits: "0b00110011", dbits: "0b00110000"} +- {xorigin: -16, yorigin: -52, op: "&", dest: -64, xbits: "0b11110000", xbits: "0b11001100", dbits: "0b11000000"} +- {xorigin: -16, yorigin: -127, op: "&", dest: -128, xbits: "0b11110000", xbits: "0b10000001", dbits: "0b10000000"} +- {xorigin: -16, yorigin: -103, op: "&", dest: -112, xbits: "0b11110000", xbits: "0b10011001", dbits: "0b10010000"} +- {xorigin: -16, yorigin: 102, op: "&", dest: 96, xbits: "0b11110000", xbits: "0b01100110", dbits: "0b01100000"} +- {xorigin: 51, yorigin: 0, op: "&", dest: 0, xbits: "0b00110011", xbits: "0b00000000", dbits: "0b00000000"} +- {xorigin: 51, yorigin: 85, op: "&", dest: 17, xbits: "0b00110011", xbits: "0b01010101", dbits: "0b00010001"} +- {xorigin: 51, yorigin: -86, op: "&", dest: 34, xbits: "0b00110011", xbits: "0b10101010", dbits: "0b00100010"} +- {xorigin: 51, yorigin: 15, op: "&", dest: 3, xbits: "0b00110011", xbits: "0b00001111", dbits: "0b00000011"} +- {xorigin: 51, yorigin: -16, op: "&", dest: 48, xbits: "0b00110011", xbits: "0b11110000", dbits: "0b00110000"} +- {xorigin: 51, yorigin: 51, op: "&", dest: 51, xbits: "0b00110011", xbits: "0b00110011", dbits: "0b00110011"} +- {xorigin: 51, yorigin: -52, op: "&", dest: 0, xbits: "0b00110011", xbits: "0b11001100", dbits: "0b00000000"} +- {xorigin: 51, yorigin: -127, op: "&", dest: 1, xbits: "0b00110011", xbits: "0b10000001", dbits: "0b00000001"} +- {xorigin: 51, yorigin: -103, op: "&", dest: 17, xbits: "0b00110011", xbits: "0b10011001", dbits: "0b00010001"} +- {xorigin: 51, yorigin: 102, op: "&", dest: 34, xbits: "0b00110011", xbits: "0b01100110", dbits: "0b00100010"} +- {xorigin: -52, yorigin: 0, op: "&", dest: 0, xbits: "0b11001100", xbits: "0b00000000", dbits: "0b00000000"} +- {xorigin: -52, yorigin: 85, op: "&", dest: 68, xbits: "0b11001100", xbits: "0b01010101", dbits: "0b01000100"} +- {xorigin: -52, yorigin: -86, op: "&", dest: -120, xbits: "0b11001100", xbits: "0b10101010", dbits: "0b10001000"} +- {xorigin: -52, yorigin: 15, op: "&", dest: 12, xbits: "0b11001100", xbits: "0b00001111", dbits: "0b00001100"} +- {xorigin: -52, yorigin: -16, op: "&", dest: -64, xbits: "0b11001100", xbits: "0b11110000", dbits: "0b11000000"} +- {xorigin: -52, yorigin: 51, op: "&", dest: 0, xbits: "0b11001100", xbits: "0b00110011", dbits: "0b00000000"} +- {xorigin: -52, yorigin: -52, op: "&", dest: -52, xbits: "0b11001100", xbits: "0b11001100", dbits: "0b11001100"} +- {xorigin: -52, yorigin: -127, op: "&", dest: -128, xbits: "0b11001100", xbits: "0b10000001", dbits: "0b10000000"} +- {xorigin: -52, yorigin: -103, op: "&", dest: -120, xbits: "0b11001100", xbits: "0b10011001", dbits: "0b10001000"} +- {xorigin: -52, yorigin: 102, op: "&", dest: 68, xbits: "0b11001100", xbits: "0b01100110", dbits: "0b01000100"} +- {xorigin: -127, yorigin: 0, op: "&", dest: 0, xbits: "0b10000001", xbits: "0b00000000", dbits: "0b00000000"} +- {xorigin: -127, yorigin: 85, op: "&", dest: 1, xbits: "0b10000001", xbits: "0b01010101", dbits: "0b00000001"} +- {xorigin: -127, yorigin: -86, op: "&", dest: -128, xbits: "0b10000001", xbits: "0b10101010", dbits: "0b10000000"} +- {xorigin: -127, yorigin: 15, op: "&", dest: 1, xbits: "0b10000001", xbits: "0b00001111", dbits: "0b00000001"} +- {xorigin: -127, yorigin: -16, op: "&", dest: -128, xbits: "0b10000001", xbits: "0b11110000", dbits: "0b10000000"} +- {xorigin: -127, yorigin: 51, op: "&", dest: 1, xbits: "0b10000001", xbits: "0b00110011", dbits: "0b00000001"} +- {xorigin: -127, yorigin: -52, op: "&", dest: -128, xbits: "0b10000001", xbits: "0b11001100", dbits: "0b10000000"} +- {xorigin: -127, yorigin: -127, op: "&", dest: -127, xbits: "0b10000001", xbits: "0b10000001", dbits: "0b10000001"} +- {xorigin: -127, yorigin: -103, op: "&", dest: -127, xbits: "0b10000001", xbits: "0b10011001", dbits: "0b10000001"} +- {xorigin: -127, yorigin: 102, op: "&", dest: 0, xbits: "0b10000001", xbits: "0b01100110", dbits: "0b00000000"} +- {xorigin: -103, yorigin: 0, op: "&", dest: 0, xbits: "0b10011001", xbits: "0b00000000", dbits: "0b00000000"} +- {xorigin: -103, yorigin: 85, op: "&", dest: 17, xbits: "0b10011001", xbits: "0b01010101", dbits: "0b00010001"} +- {xorigin: -103, yorigin: -86, op: "&", dest: -120, xbits: "0b10011001", xbits: "0b10101010", dbits: "0b10001000"} +- {xorigin: -103, yorigin: 15, op: "&", dest: 9, xbits: "0b10011001", xbits: "0b00001111", dbits: "0b00001001"} +- {xorigin: -103, yorigin: -16, op: "&", dest: -112, xbits: "0b10011001", xbits: "0b11110000", dbits: "0b10010000"} +- {xorigin: -103, yorigin: 51, op: "&", dest: 17, xbits: "0b10011001", xbits: "0b00110011", dbits: "0b00010001"} +- {xorigin: -103, yorigin: -52, op: "&", dest: -120, xbits: "0b10011001", xbits: "0b11001100", dbits: "0b10001000"} +- {xorigin: -103, yorigin: -127, op: "&", dest: -127, xbits: "0b10011001", xbits: "0b10000001", dbits: "0b10000001"} +- {xorigin: -103, yorigin: -103, op: "&", dest: -103, xbits: "0b10011001", xbits: "0b10011001", dbits: "0b10011001"} +- {xorigin: -103, yorigin: 102, op: "&", dest: 0, xbits: "0b10011001", xbits: "0b01100110", dbits: "0b00000000"} +- {xorigin: 102, yorigin: 0, op: "&", dest: 0, xbits: "0b01100110", xbits: "0b00000000", dbits: "0b00000000"} +- {xorigin: 102, yorigin: 85, op: "&", dest: 68, xbits: "0b01100110", xbits: "0b01010101", dbits: "0b01000100"} +- {xorigin: 102, yorigin: -86, op: "&", dest: 34, xbits: "0b01100110", xbits: "0b10101010", dbits: "0b00100010"} +- {xorigin: 102, yorigin: 15, op: "&", dest: 6, xbits: "0b01100110", xbits: "0b00001111", dbits: "0b00000110"} +- {xorigin: 102, yorigin: -16, op: "&", dest: 96, xbits: "0b01100110", xbits: "0b11110000", dbits: "0b01100000"} +- {xorigin: 102, yorigin: 51, op: "&", dest: 34, xbits: "0b01100110", xbits: "0b00110011", dbits: "0b00100010"} +- {xorigin: 102, yorigin: -52, op: "&", dest: 68, xbits: "0b01100110", xbits: "0b11001100", dbits: "0b01000100"} +- {xorigin: 102, yorigin: -127, op: "&", dest: 0, xbits: "0b01100110", xbits: "0b10000001", dbits: "0b00000000"} +- {xorigin: 102, yorigin: -103, op: "&", dest: 0, xbits: "0b01100110", xbits: "0b10011001", dbits: "0b00000000"} +- {xorigin: 102, yorigin: 102, op: "&", dest: 102, xbits: "0b01100110", xbits: "0b01100110", dbits: "0b01100110"} diff --git a/migrator/test/staticTS/CTS/07.expressions/25.bitwise_and_logical_operators/01.integer_bitwise_operators/list.integer_or.yaml b/migrator/test/staticTS/CTS/07.expressions/25.bitwise_and_logical_operators/01.integer_bitwise_operators/list.integer_or.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d592c27651bed6904c5536a3930b31b52b313a52 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/25.bitwise_and_logical_operators/01.integer_bitwise_operators/list.integer_or.yaml @@ -0,0 +1,101 @@ +--- # List of integer or "|" operations +- {xorigin: 0, yorigin: 0, op: "|", dest: 0, xbits: "0b00000000", xbits: "0b00000000", dbits: "0b00000000"} +- {xorigin: 0, yorigin: 85, op: "|", dest: 85, xbits: "0b00000000", xbits: "0b01010101", dbits: "0b01010101"} +- {xorigin: 0, yorigin: -86, op: "|", dest: -86, xbits: "0b00000000", xbits: "0b10101010", dbits: "0b10101010"} +- {xorigin: 0, yorigin: 15, op: "|", dest: 15, xbits: "0b00000000", xbits: "0b00001111", dbits: "0b00001111"} +- {xorigin: 0, yorigin: -16, op: "|", dest: -16, xbits: "0b00000000", xbits: "0b11110000", dbits: "0b11110000"} +- {xorigin: 0, yorigin: 51, op: "|", dest: 51, xbits: "0b00000000", xbits: "0b00110011", dbits: "0b00110011"} +- {xorigin: 0, yorigin: -52, op: "|", dest: -52, xbits: "0b00000000", xbits: "0b11001100", dbits: "0b11001100"} +- {xorigin: 0, yorigin: -127, op: "|", dest: -127, xbits: "0b00000000", xbits: "0b10000001", dbits: "0b10000001"} +- {xorigin: 0, yorigin: -103, op: "|", dest: -103, xbits: "0b00000000", xbits: "0b10011001", dbits: "0b10011001"} +- {xorigin: 0, yorigin: 102, op: "|", dest: 102, xbits: "0b00000000", xbits: "0b01100110", dbits: "0b01100110"} +- {xorigin: 85, yorigin: 0, op: "|", dest: 85, xbits: "0b01010101", xbits: "0b00000000", dbits: "0b01010101"} +- {xorigin: 85, yorigin: 85, op: "|", dest: 85, xbits: "0b01010101", xbits: "0b01010101", dbits: "0b01010101"} +- {xorigin: 85, yorigin: -86, op: "|", dest: -1, xbits: "0b01010101", xbits: "0b10101010", dbits: "0b11111111"} +- {xorigin: 85, yorigin: 15, op: "|", dest: 95, xbits: "0b01010101", xbits: "0b00001111", dbits: "0b01011111"} +- {xorigin: 85, yorigin: -16, op: "|", dest: -11, xbits: "0b01010101", xbits: "0b11110000", dbits: "0b11110101"} +- {xorigin: 85, yorigin: 51, op: "|", dest: 119, xbits: "0b01010101", xbits: "0b00110011", dbits: "0b01110111"} +- {xorigin: 85, yorigin: -52, op: "|", dest: -35, xbits: "0b01010101", xbits: "0b11001100", dbits: "0b11011101"} +- {xorigin: 85, yorigin: -127, op: "|", dest: -43, xbits: "0b01010101", xbits: "0b10000001", dbits: "0b11010101"} +- {xorigin: 85, yorigin: -103, op: "|", dest: -35, xbits: "0b01010101", xbits: "0b10011001", dbits: "0b11011101"} +- {xorigin: 85, yorigin: 102, op: "|", dest: 119, xbits: "0b01010101", xbits: "0b01100110", dbits: "0b01110111"} +- {xorigin: -86, yorigin: 0, op: "|", dest: -86, xbits: "0b10101010", xbits: "0b00000000", dbits: "0b10101010"} +- {xorigin: -86, yorigin: 85, op: "|", dest: -1, xbits: "0b10101010", xbits: "0b01010101", dbits: "0b11111111"} +- {xorigin: -86, yorigin: -86, op: "|", dest: -86, xbits: "0b10101010", xbits: "0b10101010", dbits: "0b10101010"} +- {xorigin: -86, yorigin: 15, op: "|", dest: -81, xbits: "0b10101010", xbits: "0b00001111", dbits: "0b10101111"} +- {xorigin: -86, yorigin: -16, op: "|", dest: -6, xbits: "0b10101010", xbits: "0b11110000", dbits: "0b11111010"} +- {xorigin: -86, yorigin: 51, op: "|", dest: -69, xbits: "0b10101010", xbits: "0b00110011", dbits: "0b10111011"} +- {xorigin: -86, yorigin: -52, op: "|", dest: -18, xbits: "0b10101010", xbits: "0b11001100", dbits: "0b11101110"} +- {xorigin: -86, yorigin: -127, op: "|", dest: -85, xbits: "0b10101010", xbits: "0b10000001", dbits: "0b10101011"} +- {xorigin: -86, yorigin: -103, op: "|", dest: -69, xbits: "0b10101010", xbits: "0b10011001", dbits: "0b10111011"} +- {xorigin: -86, yorigin: 102, op: "|", dest: -18, xbits: "0b10101010", xbits: "0b01100110", dbits: "0b11101110"} +- {xorigin: 15, yorigin: 0, op: "|", dest: 15, xbits: "0b00001111", xbits: "0b00000000", dbits: "0b00001111"} +- {xorigin: 15, yorigin: 85, op: "|", dest: 95, xbits: "0b00001111", xbits: "0b01010101", dbits: "0b01011111"} +- {xorigin: 15, yorigin: -86, op: "|", dest: -81, xbits: "0b00001111", xbits: "0b10101010", dbits: "0b10101111"} +- {xorigin: 15, yorigin: 15, op: "|", dest: 15, xbits: "0b00001111", xbits: "0b00001111", dbits: "0b00001111"} +- {xorigin: 15, yorigin: -16, op: "|", dest: -1, xbits: "0b00001111", xbits: "0b11110000", dbits: "0b11111111"} +- {xorigin: 15, yorigin: 51, op: "|", dest: 63, xbits: "0b00001111", xbits: "0b00110011", dbits: "0b00111111"} +- {xorigin: 15, yorigin: -52, op: "|", dest: -49, xbits: "0b00001111", xbits: "0b11001100", dbits: "0b11001111"} +- {xorigin: 15, yorigin: -127, op: "|", dest: -113, xbits: "0b00001111", xbits: "0b10000001", dbits: "0b10001111"} +- {xorigin: 15, yorigin: -103, op: "|", dest: -97, xbits: "0b00001111", xbits: "0b10011001", dbits: "0b10011111"} +- {xorigin: 15, yorigin: 102, op: "|", dest: 111, xbits: "0b00001111", xbits: "0b01100110", dbits: "0b01101111"} +- {xorigin: -16, yorigin: 0, op: "|", dest: -16, xbits: "0b11110000", xbits: "0b00000000", dbits: "0b11110000"} +- {xorigin: -16, yorigin: 85, op: "|", dest: -11, xbits: "0b11110000", xbits: "0b01010101", dbits: "0b11110101"} +- {xorigin: -16, yorigin: -86, op: "|", dest: -6, xbits: "0b11110000", xbits: "0b10101010", dbits: "0b11111010"} +- {xorigin: -16, yorigin: 15, op: "|", dest: -1, xbits: "0b11110000", xbits: "0b00001111", dbits: "0b11111111"} +- {xorigin: -16, yorigin: -16, op: "|", dest: -16, xbits: "0b11110000", xbits: "0b11110000", dbits: "0b11110000"} +- {xorigin: -16, yorigin: 51, op: "|", dest: -13, xbits: "0b11110000", xbits: "0b00110011", dbits: "0b11110011"} +- {xorigin: -16, yorigin: -52, op: "|", dest: -4, xbits: "0b11110000", xbits: "0b11001100", dbits: "0b11111100"} +- {xorigin: -16, yorigin: -127, op: "|", dest: -15, xbits: "0b11110000", xbits: "0b10000001", dbits: "0b11110001"} +- {xorigin: -16, yorigin: -103, op: "|", dest: -7, xbits: "0b11110000", xbits: "0b10011001", dbits: "0b11111001"} +- {xorigin: -16, yorigin: 102, op: "|", dest: -10, xbits: "0b11110000", xbits: "0b01100110", dbits: "0b11110110"} +- {xorigin: 51, yorigin: 0, op: "|", dest: 51, xbits: "0b00110011", xbits: "0b00000000", dbits: "0b00110011"} +- {xorigin: 51, yorigin: 85, op: "|", dest: 119, xbits: "0b00110011", xbits: "0b01010101", dbits: "0b01110111"} +- {xorigin: 51, yorigin: -86, op: "|", dest: -69, xbits: "0b00110011", xbits: "0b10101010", dbits: "0b10111011"} +- {xorigin: 51, yorigin: 15, op: "|", dest: 63, xbits: "0b00110011", xbits: "0b00001111", dbits: "0b00111111"} +- {xorigin: 51, yorigin: -16, op: "|", dest: -13, xbits: "0b00110011", xbits: "0b11110000", dbits: "0b11110011"} +- {xorigin: 51, yorigin: 51, op: "|", dest: 51, xbits: "0b00110011", xbits: "0b00110011", dbits: "0b00110011"} +- {xorigin: 51, yorigin: -52, op: "|", dest: -1, xbits: "0b00110011", xbits: "0b11001100", dbits: "0b11111111"} +- {xorigin: 51, yorigin: -127, op: "|", dest: -77, xbits: "0b00110011", xbits: "0b10000001", dbits: "0b10110011"} +- {xorigin: 51, yorigin: -103, op: "|", dest: -69, xbits: "0b00110011", xbits: "0b10011001", dbits: "0b10111011"} +- {xorigin: 51, yorigin: 102, op: "|", dest: 119, xbits: "0b00110011", xbits: "0b01100110", dbits: "0b01110111"} +- {xorigin: -52, yorigin: 0, op: "|", dest: -52, xbits: "0b11001100", xbits: "0b00000000", dbits: "0b11001100"} +- {xorigin: -52, yorigin: 85, op: "|", dest: -35, xbits: "0b11001100", xbits: "0b01010101", dbits: "0b11011101"} +- {xorigin: -52, yorigin: -86, op: "|", dest: -18, xbits: "0b11001100", xbits: "0b10101010", dbits: "0b11101110"} +- {xorigin: -52, yorigin: 15, op: "|", dest: -49, xbits: "0b11001100", xbits: "0b00001111", dbits: "0b11001111"} +- {xorigin: -52, yorigin: -16, op: "|", dest: -4, xbits: "0b11001100", xbits: "0b11110000", dbits: "0b11111100"} +- {xorigin: -52, yorigin: 51, op: "|", dest: -1, xbits: "0b11001100", xbits: "0b00110011", dbits: "0b11111111"} +- {xorigin: -52, yorigin: -52, op: "|", dest: -52, xbits: "0b11001100", xbits: "0b11001100", dbits: "0b11001100"} +- {xorigin: -52, yorigin: -127, op: "|", dest: -51, xbits: "0b11001100", xbits: "0b10000001", dbits: "0b11001101"} +- {xorigin: -52, yorigin: -103, op: "|", dest: -35, xbits: "0b11001100", xbits: "0b10011001", dbits: "0b11011101"} +- {xorigin: -52, yorigin: 102, op: "|", dest: -18, xbits: "0b11001100", xbits: "0b01100110", dbits: "0b11101110"} +- {xorigin: -127, yorigin: 0, op: "|", dest: -127, xbits: "0b10000001", xbits: "0b00000000", dbits: "0b10000001"} +- {xorigin: -127, yorigin: 85, op: "|", dest: -43, xbits: "0b10000001", xbits: "0b01010101", dbits: "0b11010101"} +- {xorigin: -127, yorigin: -86, op: "|", dest: -85, xbits: "0b10000001", xbits: "0b10101010", dbits: "0b10101011"} +- {xorigin: -127, yorigin: 15, op: "|", dest: -113, xbits: "0b10000001", xbits: "0b00001111", dbits: "0b10001111"} +- {xorigin: -127, yorigin: -16, op: "|", dest: -15, xbits: "0b10000001", xbits: "0b11110000", dbits: "0b11110001"} +- {xorigin: -127, yorigin: 51, op: "|", dest: -77, xbits: "0b10000001", xbits: "0b00110011", dbits: "0b10110011"} +- {xorigin: -127, yorigin: -52, op: "|", dest: -51, xbits: "0b10000001", xbits: "0b11001100", dbits: "0b11001101"} +- {xorigin: -127, yorigin: -127, op: "|", dest: -127, xbits: "0b10000001", xbits: "0b10000001", dbits: "0b10000001"} +- {xorigin: -127, yorigin: -103, op: "|", dest: -103, xbits: "0b10000001", xbits: "0b10011001", dbits: "0b10011001"} +- {xorigin: -127, yorigin: 102, op: "|", dest: -25, xbits: "0b10000001", xbits: "0b01100110", dbits: "0b11100111"} +- {xorigin: -103, yorigin: 0, op: "|", dest: -103, xbits: "0b10011001", xbits: "0b00000000", dbits: "0b10011001"} +- {xorigin: -103, yorigin: 85, op: "|", dest: -35, xbits: "0b10011001", xbits: "0b01010101", dbits: "0b11011101"} +- {xorigin: -103, yorigin: -86, op: "|", dest: -69, xbits: "0b10011001", xbits: "0b10101010", dbits: "0b10111011"} +- {xorigin: -103, yorigin: 15, op: "|", dest: -97, xbits: "0b10011001", xbits: "0b00001111", dbits: "0b10011111"} +- {xorigin: -103, yorigin: -16, op: "|", dest: -7, xbits: "0b10011001", xbits: "0b11110000", dbits: "0b11111001"} +- {xorigin: -103, yorigin: 51, op: "|", dest: -69, xbits: "0b10011001", xbits: "0b00110011", dbits: "0b10111011"} +- {xorigin: -103, yorigin: -52, op: "|", dest: -35, xbits: "0b10011001", xbits: "0b11001100", dbits: "0b11011101"} +- {xorigin: -103, yorigin: -127, op: "|", dest: -103, xbits: "0b10011001", xbits: "0b10000001", dbits: "0b10011001"} +- {xorigin: -103, yorigin: -103, op: "|", dest: -103, xbits: "0b10011001", xbits: "0b10011001", dbits: "0b10011001"} +- {xorigin: -103, yorigin: 102, op: "|", dest: -1, xbits: "0b10011001", xbits: "0b01100110", dbits: "0b11111111"} +- {xorigin: 102, yorigin: 0, op: "|", dest: 102, xbits: "0b01100110", xbits: "0b00000000", dbits: "0b01100110"} +- {xorigin: 102, yorigin: 85, op: "|", dest: 119, xbits: "0b01100110", xbits: "0b01010101", dbits: "0b01110111"} +- {xorigin: 102, yorigin: -86, op: "|", dest: -18, xbits: "0b01100110", xbits: "0b10101010", dbits: "0b11101110"} +- {xorigin: 102, yorigin: 15, op: "|", dest: 111, xbits: "0b01100110", xbits: "0b00001111", dbits: "0b01101111"} +- {xorigin: 102, yorigin: -16, op: "|", dest: -10, xbits: "0b01100110", xbits: "0b11110000", dbits: "0b11110110"} +- {xorigin: 102, yorigin: 51, op: "|", dest: 119, xbits: "0b01100110", xbits: "0b00110011", dbits: "0b01110111"} +- {xorigin: 102, yorigin: -52, op: "|", dest: -18, xbits: "0b01100110", xbits: "0b11001100", dbits: "0b11101110"} +- {xorigin: 102, yorigin: -127, op: "|", dest: -25, xbits: "0b01100110", xbits: "0b10000001", dbits: "0b11100111"} +- {xorigin: 102, yorigin: -103, op: "|", dest: -1, xbits: "0b01100110", xbits: "0b10011001", dbits: "0b11111111"} +- {xorigin: 102, yorigin: 102, op: "|", dest: 102, xbits: "0b01100110", xbits: "0b01100110", dbits: "0b01100110"} diff --git a/migrator/test/staticTS/CTS/07.expressions/25.bitwise_and_logical_operators/01.integer_bitwise_operators/list.integer_xor.yaml b/migrator/test/staticTS/CTS/07.expressions/25.bitwise_and_logical_operators/01.integer_bitwise_operators/list.integer_xor.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c098333e1347e748647b9128c0db83d481bf48fa --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/25.bitwise_and_logical_operators/01.integer_bitwise_operators/list.integer_xor.yaml @@ -0,0 +1,101 @@ +--- # List of integer xor "^" operations +- {xorigin: 0, yorigin: 0, op: "^", dest: 0, xbits: "0b00000000", xbits: "0b00000000", dbits: "0b00000000"} +- {xorigin: 0, yorigin: 85, op: "^", dest: 85, xbits: "0b00000000", xbits: "0b01010101", dbits: "0b01010101"} +- {xorigin: 0, yorigin: -86, op: "^", dest: -86, xbits: "0b00000000", xbits: "0b10101010", dbits: "0b10101010"} +- {xorigin: 0, yorigin: 15, op: "^", dest: 15, xbits: "0b00000000", xbits: "0b00001111", dbits: "0b00001111"} +- {xorigin: 0, yorigin: -16, op: "^", dest: -16, xbits: "0b00000000", xbits: "0b11110000", dbits: "0b11110000"} +- {xorigin: 0, yorigin: 51, op: "^", dest: 51, xbits: "0b00000000", xbits: "0b00110011", dbits: "0b00110011"} +- {xorigin: 0, yorigin: -52, op: "^", dest: -52, xbits: "0b00000000", xbits: "0b11001100", dbits: "0b11001100"} +- {xorigin: 0, yorigin: -127, op: "^", dest: -127, xbits: "0b00000000", xbits: "0b10000001", dbits: "0b10000001"} +- {xorigin: 0, yorigin: -103, op: "^", dest: -103, xbits: "0b00000000", xbits: "0b10011001", dbits: "0b10011001"} +- {xorigin: 0, yorigin: 102, op: "^", dest: 102, xbits: "0b00000000", xbits: "0b01100110", dbits: "0b01100110"} +- {xorigin: 85, yorigin: 0, op: "^", dest: 85, xbits: "0b01010101", xbits: "0b00000000", dbits: "0b01010101"} +- {xorigin: 85, yorigin: 85, op: "^", dest: 0, xbits: "0b01010101", xbits: "0b01010101", dbits: "0b00000000"} +- {xorigin: 85, yorigin: -86, op: "^", dest: -1, xbits: "0b01010101", xbits: "0b10101010", dbits: "0b11111111"} +- {xorigin: 85, yorigin: 15, op: "^", dest: 90, xbits: "0b01010101", xbits: "0b00001111", dbits: "0b01011010"} +- {xorigin: 85, yorigin: -16, op: "^", dest: -91, xbits: "0b01010101", xbits: "0b11110000", dbits: "0b10100101"} +- {xorigin: 85, yorigin: 51, op: "^", dest: 102, xbits: "0b01010101", xbits: "0b00110011", dbits: "0b01100110"} +- {xorigin: 85, yorigin: -52, op: "^", dest: -103, xbits: "0b01010101", xbits: "0b11001100", dbits: "0b10011001"} +- {xorigin: 85, yorigin: -127, op: "^", dest: -44, xbits: "0b01010101", xbits: "0b10000001", dbits: "0b11010100"} +- {xorigin: 85, yorigin: -103, op: "^", dest: -52, xbits: "0b01010101", xbits: "0b10011001", dbits: "0b11001100"} +- {xorigin: 85, yorigin: 102, op: "^", dest: 51, xbits: "0b01010101", xbits: "0b01100110", dbits: "0b00110011"} +- {xorigin: -86, yorigin: 0, op: "^", dest: -86, xbits: "0b10101010", xbits: "0b00000000", dbits: "0b10101010"} +- {xorigin: -86, yorigin: 85, op: "^", dest: -1, xbits: "0b10101010", xbits: "0b01010101", dbits: "0b11111111"} +- {xorigin: -86, yorigin: -86, op: "^", dest: 0, xbits: "0b10101010", xbits: "0b10101010", dbits: "0b00000000"} +- {xorigin: -86, yorigin: 15, op: "^", dest: -91, xbits: "0b10101010", xbits: "0b00001111", dbits: "0b10100101"} +- {xorigin: -86, yorigin: -16, op: "^", dest: 90, xbits: "0b10101010", xbits: "0b11110000", dbits: "0b01011010"} +- {xorigin: -86, yorigin: 51, op: "^", dest: -103, xbits: "0b10101010", xbits: "0b00110011", dbits: "0b10011001"} +- {xorigin: -86, yorigin: -52, op: "^", dest: 102, xbits: "0b10101010", xbits: "0b11001100", dbits: "0b01100110"} +- {xorigin: -86, yorigin: -127, op: "^", dest: 43, xbits: "0b10101010", xbits: "0b10000001", dbits: "0b00101011"} +- {xorigin: -86, yorigin: -103, op: "^", dest: 51, xbits: "0b10101010", xbits: "0b10011001", dbits: "0b00110011"} +- {xorigin: -86, yorigin: 102, op: "^", dest: -52, xbits: "0b10101010", xbits: "0b01100110", dbits: "0b11001100"} +- {xorigin: 15, yorigin: 0, op: "^", dest: 15, xbits: "0b00001111", xbits: "0b00000000", dbits: "0b00001111"} +- {xorigin: 15, yorigin: 85, op: "^", dest: 90, xbits: "0b00001111", xbits: "0b01010101", dbits: "0b01011010"} +- {xorigin: 15, yorigin: -86, op: "^", dest: -91, xbits: "0b00001111", xbits: "0b10101010", dbits: "0b10100101"} +- {xorigin: 15, yorigin: 15, op: "^", dest: 0, xbits: "0b00001111", xbits: "0b00001111", dbits: "0b00000000"} +- {xorigin: 15, yorigin: -16, op: "^", dest: -1, xbits: "0b00001111", xbits: "0b11110000", dbits: "0b11111111"} +- {xorigin: 15, yorigin: 51, op: "^", dest: 60, xbits: "0b00001111", xbits: "0b00110011", dbits: "0b00111100"} +- {xorigin: 15, yorigin: -52, op: "^", dest: -61, xbits: "0b00001111", xbits: "0b11001100", dbits: "0b11000011"} +- {xorigin: 15, yorigin: -127, op: "^", dest: -114, xbits: "0b00001111", xbits: "0b10000001", dbits: "0b10001110"} +- {xorigin: 15, yorigin: -103, op: "^", dest: -106, xbits: "0b00001111", xbits: "0b10011001", dbits: "0b10010110"} +- {xorigin: 15, yorigin: 102, op: "^", dest: 105, xbits: "0b00001111", xbits: "0b01100110", dbits: "0b01101001"} +- {xorigin: -16, yorigin: 0, op: "^", dest: -16, xbits: "0b11110000", xbits: "0b00000000", dbits: "0b11110000"} +- {xorigin: -16, yorigin: 85, op: "^", dest: -91, xbits: "0b11110000", xbits: "0b01010101", dbits: "0b10100101"} +- {xorigin: -16, yorigin: -86, op: "^", dest: 90, xbits: "0b11110000", xbits: "0b10101010", dbits: "0b01011010"} +- {xorigin: -16, yorigin: 15, op: "^", dest: -1, xbits: "0b11110000", xbits: "0b00001111", dbits: "0b11111111"} +- {xorigin: -16, yorigin: -16, op: "^", dest: 0, xbits: "0b11110000", xbits: "0b11110000", dbits: "0b00000000"} +- {xorigin: -16, yorigin: 51, op: "^", dest: -61, xbits: "0b11110000", xbits: "0b00110011", dbits: "0b11000011"} +- {xorigin: -16, yorigin: -52, op: "^", dest: 60, xbits: "0b11110000", xbits: "0b11001100", dbits: "0b00111100"} +- {xorigin: -16, yorigin: -127, op: "^", dest: 113, xbits: "0b11110000", xbits: "0b10000001", dbits: "0b01110001"} +- {xorigin: -16, yorigin: -103, op: "^", dest: 105, xbits: "0b11110000", xbits: "0b10011001", dbits: "0b01101001"} +- {xorigin: -16, yorigin: 102, op: "^", dest: -106, xbits: "0b11110000", xbits: "0b01100110", dbits: "0b10010110"} +- {xorigin: 51, yorigin: 0, op: "^", dest: 51, xbits: "0b00110011", xbits: "0b00000000", dbits: "0b00110011"} +- {xorigin: 51, yorigin: 85, op: "^", dest: 102, xbits: "0b00110011", xbits: "0b01010101", dbits: "0b01100110"} +- {xorigin: 51, yorigin: -86, op: "^", dest: -103, xbits: "0b00110011", xbits: "0b10101010", dbits: "0b10011001"} +- {xorigin: 51, yorigin: 15, op: "^", dest: 60, xbits: "0b00110011", xbits: "0b00001111", dbits: "0b00111100"} +- {xorigin: 51, yorigin: -16, op: "^", dest: -61, xbits: "0b00110011", xbits: "0b11110000", dbits: "0b11000011"} +- {xorigin: 51, yorigin: 51, op: "^", dest: 0, xbits: "0b00110011", xbits: "0b00110011", dbits: "0b00000000"} +- {xorigin: 51, yorigin: -52, op: "^", dest: -1, xbits: "0b00110011", xbits: "0b11001100", dbits: "0b11111111"} +- {xorigin: 51, yorigin: -127, op: "^", dest: -78, xbits: "0b00110011", xbits: "0b10000001", dbits: "0b10110010"} +- {xorigin: 51, yorigin: -103, op: "^", dest: -86, xbits: "0b00110011", xbits: "0b10011001", dbits: "0b10101010"} +- {xorigin: 51, yorigin: 102, op: "^", dest: 85, xbits: "0b00110011", xbits: "0b01100110", dbits: "0b01010101"} +- {xorigin: -52, yorigin: 0, op: "^", dest: -52, xbits: "0b11001100", xbits: "0b00000000", dbits: "0b11001100"} +- {xorigin: -52, yorigin: 85, op: "^", dest: -103, xbits: "0b11001100", xbits: "0b01010101", dbits: "0b10011001"} +- {xorigin: -52, yorigin: -86, op: "^", dest: 102, xbits: "0b11001100", xbits: "0b10101010", dbits: "0b01100110"} +- {xorigin: -52, yorigin: 15, op: "^", dest: -61, xbits: "0b11001100", xbits: "0b00001111", dbits: "0b11000011"} +- {xorigin: -52, yorigin: -16, op: "^", dest: 60, xbits: "0b11001100", xbits: "0b11110000", dbits: "0b00111100"} +- {xorigin: -52, yorigin: 51, op: "^", dest: -1, xbits: "0b11001100", xbits: "0b00110011", dbits: "0b11111111"} +- {xorigin: -52, yorigin: -52, op: "^", dest: 0, xbits: "0b11001100", xbits: "0b11001100", dbits: "0b00000000"} +- {xorigin: -52, yorigin: -127, op: "^", dest: 77, xbits: "0b11001100", xbits: "0b10000001", dbits: "0b01001101"} +- {xorigin: -52, yorigin: -103, op: "^", dest: 85, xbits: "0b11001100", xbits: "0b10011001", dbits: "0b01010101"} +- {xorigin: -52, yorigin: 102, op: "^", dest: -86, xbits: "0b11001100", xbits: "0b01100110", dbits: "0b10101010"} +- {xorigin: -127, yorigin: 0, op: "^", dest: -127, xbits: "0b10000001", xbits: "0b00000000", dbits: "0b10000001"} +- {xorigin: -127, yorigin: 85, op: "^", dest: -44, xbits: "0b10000001", xbits: "0b01010101", dbits: "0b11010100"} +- {xorigin: -127, yorigin: -86, op: "^", dest: 43, xbits: "0b10000001", xbits: "0b10101010", dbits: "0b00101011"} +- {xorigin: -127, yorigin: 15, op: "^", dest: -114, xbits: "0b10000001", xbits: "0b00001111", dbits: "0b10001110"} +- {xorigin: -127, yorigin: -16, op: "^", dest: 113, xbits: "0b10000001", xbits: "0b11110000", dbits: "0b01110001"} +- {xorigin: -127, yorigin: 51, op: "^", dest: -78, xbits: "0b10000001", xbits: "0b00110011", dbits: "0b10110010"} +- {xorigin: -127, yorigin: -52, op: "^", dest: 77, xbits: "0b10000001", xbits: "0b11001100", dbits: "0b01001101"} +- {xorigin: -127, yorigin: -127, op: "^", dest: 0, xbits: "0b10000001", xbits: "0b10000001", dbits: "0b00000000"} +- {xorigin: -127, yorigin: -103, op: "^", dest: 24, xbits: "0b10000001", xbits: "0b10011001", dbits: "0b00011000"} +- {xorigin: -127, yorigin: 102, op: "^", dest: -25, xbits: "0b10000001", xbits: "0b01100110", dbits: "0b11100111"} +- {xorigin: -103, yorigin: 0, op: "^", dest: -103, xbits: "0b10011001", xbits: "0b00000000", dbits: "0b10011001"} +- {xorigin: -103, yorigin: 85, op: "^", dest: -52, xbits: "0b10011001", xbits: "0b01010101", dbits: "0b11001100"} +- {xorigin: -103, yorigin: -86, op: "^", dest: 51, xbits: "0b10011001", xbits: "0b10101010", dbits: "0b00110011"} +- {xorigin: -103, yorigin: 15, op: "^", dest: -106, xbits: "0b10011001", xbits: "0b00001111", dbits: "0b10010110"} +- {xorigin: -103, yorigin: -16, op: "^", dest: 105, xbits: "0b10011001", xbits: "0b11110000", dbits: "0b01101001"} +- {xorigin: -103, yorigin: 51, op: "^", dest: -86, xbits: "0b10011001", xbits: "0b00110011", dbits: "0b10101010"} +- {xorigin: -103, yorigin: -52, op: "^", dest: 85, xbits: "0b10011001", xbits: "0b11001100", dbits: "0b01010101"} +- {xorigin: -103, yorigin: -127, op: "^", dest: 24, xbits: "0b10011001", xbits: "0b10000001", dbits: "0b00011000"} +- {xorigin: -103, yorigin: -103, op: "^", dest: 0, xbits: "0b10011001", xbits: "0b10011001", dbits: "0b00000000"} +- {xorigin: -103, yorigin: 102, op: "^", dest: -1, xbits: "0b10011001", xbits: "0b01100110", dbits: "0b11111111"} +- {xorigin: 102, yorigin: 0, op: "^", dest: 102, xbits: "0b01100110", xbits: "0b00000000", dbits: "0b01100110"} +- {xorigin: 102, yorigin: 85, op: "^", dest: 51, xbits: "0b01100110", xbits: "0b01010101", dbits: "0b00110011"} +- {xorigin: 102, yorigin: -86, op: "^", dest: -52, xbits: "0b01100110", xbits: "0b10101010", dbits: "0b11001100"} +- {xorigin: 102, yorigin: 15, op: "^", dest: 105, xbits: "0b01100110", xbits: "0b00001111", dbits: "0b01101001"} +- {xorigin: 102, yorigin: -16, op: "^", dest: -106, xbits: "0b01100110", xbits: "0b11110000", dbits: "0b10010110"} +- {xorigin: 102, yorigin: 51, op: "^", dest: 85, xbits: "0b01100110", xbits: "0b00110011", dbits: "0b01010101"} +- {xorigin: 102, yorigin: -52, op: "^", dest: -86, xbits: "0b01100110", xbits: "0b11001100", dbits: "0b10101010"} +- {xorigin: 102, yorigin: -127, op: "^", dest: -25, xbits: "0b01100110", xbits: "0b10000001", dbits: "0b11100111"} +- {xorigin: 102, yorigin: -103, op: "^", dest: -1, xbits: "0b01100110", xbits: "0b10011001", dbits: "0b11111111"} +- {xorigin: 102, yorigin: 102, op: "^", dest: 0, xbits: "0b01100110", xbits: "0b01100110", dbits: "0b00000000"} diff --git a/migrator/test/staticTS/CTS/07.expressions/25.bitwise_and_logical_operators/01.integer_bitwise_operators/tbd.large_size_operations.sts b/migrator/test/staticTS/CTS/07.expressions/25.bitwise_and_logical_operators/01.integer_bitwise_operators/tbd.large_size_operations.sts new file mode 100644 index 0000000000000000000000000000000000000000..e863c0ab828a1a526ef1361fbf3352f2a8372858 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/25.bitwise_and_logical_operators/01.integer_bitwise_operators/tbd.large_size_operations.sts @@ -0,0 +1,3 @@ +/*--- +desc: Same checks for values of larger types (short, int, long) +---*/ \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/25.bitwise_and_logical_operators/02.logical_bitwise_operators/list.logical_ops.yaml b/migrator/test/staticTS/CTS/07.expressions/25.bitwise_and_logical_operators/02.logical_bitwise_operators/list.logical_ops.yaml new file mode 100644 index 0000000000000000000000000000000000000000..26fc7d231ea134540eec5f21d82763dd3581cc85 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/25.bitwise_and_logical_operators/02.logical_bitwise_operators/list.logical_ops.yaml @@ -0,0 +1,16 @@ +--- # List of logical bitwise operations + +- {xorigin: "false", yorigin: "false", op: "&", dest: "false"} +- {xorigin: "true", yorigin: "false", op: "&", dest: "false"} +- {xorigin: "false", yorigin: "true", op: "&", dest: "false"} +- {xorigin: "true", yorigin: "true", op: "&", dest: "true"} + +- {xorigin: "false", yorigin: "false", op: "|", dest: "false"} +- {xorigin: "true", yorigin: "false", op: "|", dest: "true"} +- {xorigin: "false", yorigin: "true", op: "|", dest: "true"} +- {xorigin: "true", yorigin: "true", op: "|", dest: "true"} + +- {xorigin: "false", yorigin: "false", op: "^", dest: "false"} +- {xorigin: "true", yorigin: "false", op: "^", dest: "true"} +- {xorigin: "false", yorigin: "true", op: "^", dest: "true"} +- {xorigin: "true", yorigin: "true", op: "^", dest: "false"} diff --git a/migrator/test/staticTS/CTS/07.expressions/25.bitwise_and_logical_operators/02.logical_bitwise_operators/logical_bitwise_bool.sts b/migrator/test/staticTS/CTS/07.expressions/25.bitwise_and_logical_operators/02.logical_bitwise_operators/logical_bitwise_bool.sts new file mode 100644 index 0000000000000000000000000000000000000000..9fa3e28c5f29e67361df9a7217b2d7c92f3b4e9a --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/25.bitwise_and_logical_operators/02.logical_bitwise_operators/logical_bitwise_bool.sts @@ -0,0 +1,15 @@ +{% for i in logical_ops %} + +/*--- +desc: Bitwise logical operations (boolean) +params: {{.i.xorigin}} {{.i.op}} {{.i.yorigin}} == {{.i.dest}} +---*/ + +function main(): void { + let x: boolean = {{.i.xorigin}}; + let y: boolean = {{.i.yorigin}}; + let dest: boolean = {{.i.dest}}; + assert (x {{.i.op}} y) == dest; +} + +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/25.bitwise_and_logical_operators/02.logical_bitwise_operators/logical_bitwise_boolean.sts b/migrator/test/staticTS/CTS/07.expressions/25.bitwise_and_logical_operators/02.logical_bitwise_operators/logical_bitwise_boolean.sts new file mode 100644 index 0000000000000000000000000000000000000000..d6d4616b036bbbb90b5ffca447dc2256728804a8 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/25.bitwise_and_logical_operators/02.logical_bitwise_operators/logical_bitwise_boolean.sts @@ -0,0 +1,15 @@ +{% for i in logical_ops %} + +/*--- +desc: Bitwise logical operations (Boolean) +params: {{.i.xorigin}} {{.i.op}} {{.i.yorigin}} == {{.i.dest}} +---*/ + +function main(): void { + let x: Boolean = {{.i.xorigin}}; + let y: Boolean = {{.i.yorigin}}; + let dest: Boolean = {{.i.dest}}; + assert (x {{.i.op}} y) == dest; +} + +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/26.conditional_and_operator/conditional_and_bool.sts b/migrator/test/staticTS/CTS/07.expressions/26.conditional_and_operator/conditional_and_bool.sts new file mode 100644 index 0000000000000000000000000000000000000000..222ca2a2375875e83192a9e7daab20ac783042f7 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/26.conditional_and_operator/conditional_and_bool.sts @@ -0,0 +1,13 @@ +/*--- +desc: Conditional and operator +---*/ + +function check(): boolean { + assert false; + return true; +} + +function main(): void { + let x: boolean = false; + assert !(x && check()); +} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/26.conditional_and_operator/conditional_and_boolean.sts b/migrator/test/staticTS/CTS/07.expressions/26.conditional_and_operator/conditional_and_boolean.sts new file mode 100644 index 0000000000000000000000000000000000000000..c1ccddfc13552aa859680b9476aebecf01f2bdf9 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/26.conditional_and_operator/conditional_and_boolean.sts @@ -0,0 +1,13 @@ +/*--- +desc: Conditional and operator +---*/ + +function check(): Boolean { + assert false; + return true; +} + +function main(): void { + let x: Boolean = false; + assert !(x && check()); +} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/26.conditional_and_operator/tbd.n.conditional_and_bool.sts b/migrator/test/staticTS/CTS/07.expressions/26.conditional_and_operator/tbd.n.conditional_and_bool.sts new file mode 100644 index 0000000000000000000000000000000000000000..7579222487a250721c21d04d9e4f13fe15070094 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/26.conditional_and_operator/tbd.n.conditional_and_bool.sts @@ -0,0 +1,3 @@ +/*--- +desc: Conditional and operator must be applied to boolean arguments only +---*/ \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/27.conditional_or_operator/conditional_or_bool.sts b/migrator/test/staticTS/CTS/07.expressions/27.conditional_or_operator/conditional_or_bool.sts new file mode 100644 index 0000000000000000000000000000000000000000..2dfc05764f4441236c0b4060e4367383b25d2a28 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/27.conditional_or_operator/conditional_or_bool.sts @@ -0,0 +1,13 @@ +/*--- +desc: Conditional or operator +---*/ + +function check(): boolean { + assert false; + return true; +} + +function main(): void { + let x: boolean = true; + assert x || check(); +} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/27.conditional_or_operator/conditional_or_boolean.sts b/migrator/test/staticTS/CTS/07.expressions/27.conditional_or_operator/conditional_or_boolean.sts new file mode 100644 index 0000000000000000000000000000000000000000..22c27c5faf737d7a79d905982ef1088662052a9c --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/27.conditional_or_operator/conditional_or_boolean.sts @@ -0,0 +1,13 @@ +/*--- +desc: Conditional or operator +---*/ + +function check(): Boolean { + assert false; + return true; +} + +function main(): void { + let x: Boolean = true; + assert x || check(); +} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/27.conditional_or_operator/tbd.n.conditional_or_bool.sts b/migrator/test/staticTS/CTS/07.expressions/27.conditional_or_operator/tbd.n.conditional_or_bool.sts new file mode 100644 index 0000000000000000000000000000000000000000..df1ff604f85a3dfdf07ce9d1f78a7f1c2603806f --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/27.conditional_or_operator/tbd.n.conditional_or_bool.sts @@ -0,0 +1,3 @@ +/*--- +desc: Conditional or operator must be applied to boolean arguments only +---*/ \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/29.conditional_expressions/conditional_expression_evaluation.sts b/migrator/test/staticTS/CTS/07.expressions/29.conditional_expressions/conditional_expression_evaluation.sts new file mode 100644 index 0000000000000000000000000000000000000000..61e428e56338240662de5cd1a8748629bd2ce23a --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/29.conditional_expressions/conditional_expression_evaluation.sts @@ -0,0 +1,22 @@ +/*--- +desc: Conditional expression order +---*/ + +function f1(): int { + assert false; + return 1; +} +function f2(): int { + assert false; + return 2; +} +function f3(): int { + assert false; + return 3; +} + +function main(): void { + let cond = false; + let a = cond?f1():cond?f2():cond?f3():0; + assert a == 0; +} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/07.expressions/29.conditional_expressions/conditional_expression_order.sts b/migrator/test/staticTS/CTS/07.expressions/29.conditional_expressions/conditional_expression_order.sts new file mode 100644 index 0000000000000000000000000000000000000000..8c1864a994756a91cfe7b88729d04e66799e3050 --- /dev/null +++ b/migrator/test/staticTS/CTS/07.expressions/29.conditional_expressions/conditional_expression_order.sts @@ -0,0 +1,10 @@ +/*--- +desc: Conditional expression order +---*/ + +function main(): void { + let cond = false; + let a = cond?1:cond?2:cond?3:0; + let b = cond?1:(cond?2:(cond?3:0)); + assert a == b; +} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/08.statements/01.expression_statement/expression_statement.sts b/migrator/test/staticTS/CTS/08.statements/01.expression_statement/expression_statement.sts new file mode 100644 index 0000000000000000000000000000000000000000..6ec969abb7ac35fd69004c1a6f2e29090f5529ba --- /dev/null +++ b/migrator/test/staticTS/CTS/08.statements/01.expression_statement/expression_statement.sts @@ -0,0 +1,13 @@ +{% for item in expression_statements %} + +/*--- +desc: Expression statement +params: > + {{.item.expr}} +---*/ + +function main(): void { + {{.item.expr}}; +} + +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/08.statements/01.expression_statement/list.expression_statements.yaml b/migrator/test/staticTS/CTS/08.statements/01.expression_statement/list.expression_statements.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b0fe8b7fc508f336633b1f89a14f67cdbbce3b82 --- /dev/null +++ b/migrator/test/staticTS/CTS/08.statements/01.expression_statement/list.expression_statements.yaml @@ -0,0 +1,6 @@ +--- # List of valid expression statements + +- {expr: "5"} +- {expr: "1 + 2"} +- {expr: "[\"hello\", \"world\"]"} +- {expr: "[]"} diff --git a/migrator/test/staticTS/CTS/08.statements/02.block/block_statement.sts b/migrator/test/staticTS/CTS/08.statements/02.block/block_statement.sts new file mode 100644 index 0000000000000000000000000000000000000000..4b180a1993cb311d20c293226744b82eecf72c7e --- /dev/null +++ b/migrator/test/staticTS/CTS/08.statements/02.block/block_statement.sts @@ -0,0 +1,15 @@ +{% for item in block_statements %} + +/*--- +desc: Block statement +params: > + {{.item.expr}} +---*/ + +function main(): void { + { + {{.item.expr}}; + } +} + +{% endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/08.statements/02.block/list.block_statements.yaml b/migrator/test/staticTS/CTS/08.statements/02.block/list.block_statements.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2b91019c2a0f3879e869916a566741d27a83a9bb --- /dev/null +++ b/migrator/test/staticTS/CTS/08.statements/02.block/list.block_statements.yaml @@ -0,0 +1,8 @@ +--- # List of valid expression statements + +- {expr: "5"} +- {expr: "1 + 2"} +- {expr: "[\"hello\", \"world\"]"} +- {expr: "[]"} +- {expr: "let a: int"} +- {expr: "let b = 1"} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/08.statements/03.labeled_statement/labeled_statement.sts b/migrator/test/staticTS/CTS/08.statements/03.labeled_statement/labeled_statement.sts new file mode 100644 index 0000000000000000000000000000000000000000..976d22706c75edb1fbbb0c1dc3dd5cbf59330066 --- /dev/null +++ b/migrator/test/staticTS/CTS/08.statements/03.labeled_statement/labeled_statement.sts @@ -0,0 +1,8 @@ +/*--- +desc: Labeled statement +---*/ + +function main(): void { + let x = 0; + lbl: {} +} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/08.statements/04.local_declarations/local_class.sts b/migrator/test/staticTS/CTS/08.statements/04.local_declarations/local_class.sts new file mode 100644 index 0000000000000000000000000000000000000000..bd418d8f2379ce33c78370eeb97d3167a6deb15d --- /dev/null +++ b/migrator/test/staticTS/CTS/08.statements/04.local_declarations/local_class.sts @@ -0,0 +1,9 @@ +/*--- +desc: Local declaration in statement (const) +---*/ + +function main(): void { + class A {} + let a: A = new A; + assert a != null; +} diff --git a/migrator/test/staticTS/CTS/08.statements/04.local_declarations/local_const.sts b/migrator/test/staticTS/CTS/08.statements/04.local_declarations/local_const.sts new file mode 100644 index 0000000000000000000000000000000000000000..43aa3b91392975882cb70f404b90b127f5e4500d --- /dev/null +++ b/migrator/test/staticTS/CTS/08.statements/04.local_declarations/local_const.sts @@ -0,0 +1,8 @@ +/*--- +desc: Local declaration in statement (const) +---*/ + +function main(): void { + const a: int = 0; + assert a == 0; +} diff --git a/migrator/test/staticTS/CTS/08.statements/04.local_declarations/local_var.sts b/migrator/test/staticTS/CTS/08.statements/04.local_declarations/local_var.sts new file mode 100644 index 0000000000000000000000000000000000000000..381559b3ffe3f7ccc57eac42da919bdb9c2b96a5 --- /dev/null +++ b/migrator/test/staticTS/CTS/08.statements/04.local_declarations/local_var.sts @@ -0,0 +1,8 @@ +/*--- +desc: Local declaration in statement (var) +---*/ + +function main(): void { + let a: int = 0; + assert a == 0; +} diff --git a/migrator/test/staticTS/CTS/08.statements/04.local_declarations/n.local_class.sts b/migrator/test/staticTS/CTS/08.statements/04.local_declarations/n.local_class.sts new file mode 100644 index 0000000000000000000000000000000000000000..6ab336afc0d2d3fbb41e9d036d24cce6a4948537 --- /dev/null +++ b/migrator/test/staticTS/CTS/08.statements/04.local_declarations/n.local_class.sts @@ -0,0 +1,12 @@ +/*--- +desc: Local declaration in statement (const) +---*/ + +function main(): void { + { + class A {} + let a: A = new A; + assert a != null; + } + assert a != null; +} diff --git a/migrator/test/staticTS/CTS/08.statements/04.local_declarations/n.local_const.sts b/migrator/test/staticTS/CTS/08.statements/04.local_declarations/n.local_const.sts new file mode 100644 index 0000000000000000000000000000000000000000..417d3273fc1a396b9596a876944496c85fd481de --- /dev/null +++ b/migrator/test/staticTS/CTS/08.statements/04.local_declarations/n.local_const.sts @@ -0,0 +1,11 @@ +/*--- +desc: Local declaration in statement (const) +---*/ + +function main(): void { + { + const a: int = 0; + assert a == 0; + } + assert a == 0; +} diff --git a/migrator/test/staticTS/CTS/08.statements/04.local_declarations/n.local_var.sts b/migrator/test/staticTS/CTS/08.statements/04.local_declarations/n.local_var.sts new file mode 100644 index 0000000000000000000000000000000000000000..8dbb54a0e8153954fe0a7b6ef63998ec3e04c77e --- /dev/null +++ b/migrator/test/staticTS/CTS/08.statements/04.local_declarations/n.local_var.sts @@ -0,0 +1,11 @@ +/*--- +desc: Local declaration in statement (var) +---*/ + +function main(): void { + { + let a: int = 0; + assert a == 0; + } + assert a == 0; +} diff --git a/migrator/test/staticTS/CTS/08.statements/06.while_and_do_statements/do.sts b/migrator/test/staticTS/CTS/08.statements/06.while_and_do_statements/do.sts new file mode 100644 index 0000000000000000000000000000000000000000..998665991bd3322a7e3d27efbabd49b24c1a6d37 --- /dev/null +++ b/migrator/test/staticTS/CTS/08.statements/06.while_and_do_statements/do.sts @@ -0,0 +1,12 @@ +/*--- +desc: While statement +---*/ + +function main(): void { + let i = 1; + do { + i--; + } while (i > 0); + + assert i == 0; +} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/08.statements/06.while_and_do_statements/while.sts b/migrator/test/staticTS/CTS/08.statements/06.while_and_do_statements/while.sts new file mode 100644 index 0000000000000000000000000000000000000000..ca0ef5297ee3aa5ed0cc4ac0320a217bdd744aea --- /dev/null +++ b/migrator/test/staticTS/CTS/08.statements/06.while_and_do_statements/while.sts @@ -0,0 +1,11 @@ +/*--- +desc: While statement +---*/ + +function main(): void { + let i = 1; + while (i > 0) { + i--; + } + assert i == 0; +} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/08.statements/06.while_and_do_statements/while_not_executed.sts b/migrator/test/staticTS/CTS/08.statements/06.while_and_do_statements/while_not_executed.sts new file mode 100644 index 0000000000000000000000000000000000000000..533fda4d5a458ffb88046bcfe17fe29c45121113 --- /dev/null +++ b/migrator/test/staticTS/CTS/08.statements/06.while_and_do_statements/while_not_executed.sts @@ -0,0 +1,9 @@ +/*--- +desc: While statement (not executed) +---*/ + +function main(): void { + while (false) { + assert false; + } +} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/08.statements/09.break_statement/break.sts b/migrator/test/staticTS/CTS/08.statements/09.break_statement/break.sts new file mode 100644 index 0000000000000000000000000000000000000000..b8c12692c3a2a3a1cdb3531377bc74de191502fd --- /dev/null +++ b/migrator/test/staticTS/CTS/08.statements/09.break_statement/break.sts @@ -0,0 +1,14 @@ +/*--- +desc: Break statement +---*/ + +function main(): void { + let i = 2; + + while (i > 0) { + break; + i--; + } + + assert i == 2; +} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/08.statements/10.continue_statement/continue_while.sts b/migrator/test/staticTS/CTS/08.statements/10.continue_statement/continue_while.sts new file mode 100644 index 0000000000000000000000000000000000000000..b4f744debfb152290a4b891b0ef532bdb9b9727c --- /dev/null +++ b/migrator/test/staticTS/CTS/08.statements/10.continue_statement/continue_while.sts @@ -0,0 +1,13 @@ +/*--- +desc: Continue statement (inside while statement) +---*/ + +function main(): void { + let i: int = 0; + while (i <= 2) { + i++; + continue; + assert false; + } + assert i == 3; +} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/08.statements/11.return_statement/return.sts b/migrator/test/staticTS/CTS/08.statements/11.return_statement/return.sts new file mode 100644 index 0000000000000000000000000000000000000000..4139d43a9f635c5098a12f03f9c9d138bfa04222 --- /dev/null +++ b/migrator/test/staticTS/CTS/08.statements/11.return_statement/return.sts @@ -0,0 +1,9 @@ +/*--- +desc: Return statement +---*/ + +function main(): void { + return; + + assert false; +} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/08.statements/13.assert_statement/assert.sts b/migrator/test/staticTS/CTS/08.statements/13.assert_statement/assert.sts new file mode 100644 index 0000000000000000000000000000000000000000..ea25149d93a0e97ab013c2d49f9d40a42c47ec3f --- /dev/null +++ b/migrator/test/staticTS/CTS/08.statements/13.assert_statement/assert.sts @@ -0,0 +1,7 @@ +/*--- +desc: Assert statement +---*/ + +function main(): void { + assert true; +} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/08.statements/13.assert_statement/n.assert.sts b/migrator/test/staticTS/CTS/08.statements/13.assert_statement/n.assert.sts new file mode 100644 index 0000000000000000000000000000000000000000..aa79839892c18a6ff80b7e3bf14ca370d77e6afb --- /dev/null +++ b/migrator/test/staticTS/CTS/08.statements/13.assert_statement/n.assert.sts @@ -0,0 +1,7 @@ +/*--- +desc: Assert statement (failed) +---*/ + +function main(): void { + assert false; +} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/08.statements/13.assert_statement/n.assert_str.sts b/migrator/test/staticTS/CTS/08.statements/13.assert_statement/n.assert_str.sts new file mode 100644 index 0000000000000000000000000000000000000000..a3d762a680db126b215ba42f9e417c996e6fa052 --- /dev/null +++ b/migrator/test/staticTS/CTS/08.statements/13.assert_statement/n.assert_str.sts @@ -0,0 +1,7 @@ +/*--- +desc: Assert statement (failed) +---*/ + +function main(): void { + assert false : "Assert failed"; +} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/08.statements/16.panic_statement/n.panic_statement.sts b/migrator/test/staticTS/CTS/08.statements/16.panic_statement/n.panic_statement.sts new file mode 100644 index 0000000000000000000000000000000000000000..9e942ff65315bdaa7de0bee0c33750a884803bee --- /dev/null +++ b/migrator/test/staticTS/CTS/08.statements/16.panic_statement/n.panic_statement.sts @@ -0,0 +1,7 @@ +/*--- +desc: Panic statement +---*/ + +function main(): void { + panic "Stop"; +} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/10.interfaces/01.interface_declarations/empty_interface_declaration.sts b/migrator/test/staticTS/CTS/10.interfaces/01.interface_declarations/empty_interface_declaration.sts new file mode 100644 index 0000000000000000000000000000000000000000..be31704921aced326f1c30e5a530a6b2141129e2 --- /dev/null +++ b/migrator/test/staticTS/CTS/10.interfaces/01.interface_declarations/empty_interface_declaration.sts @@ -0,0 +1,15 @@ +{% for id in identifiers %} +{% for static in ["", "static"] %} +{% for ancestors in identifiers_list %} + +/*--- +desc: Empty interface declaration without type parameters +params: {{.static}} interface {{.id}} extends {{.ancestors}}{} +---*/ + +{{.static}} interface {{.id}} extends {{.ancestors}}{} +function main(): void {} + +{% endfor %} +{% endfor %} +{% endfor %} diff --git a/migrator/test/staticTS/CTS/10.interfaces/01.interface_declarations/empty_interface_declaration_with_type_params.sts b/migrator/test/staticTS/CTS/10.interfaces/01.interface_declarations/empty_interface_declaration_with_type_params.sts new file mode 100644 index 0000000000000000000000000000000000000000..cb1995da3a8c44fc1ab623389a2b932f7d5267ec --- /dev/null +++ b/migrator/test/staticTS/CTS/10.interfaces/01.interface_declarations/empty_interface_declaration_with_type_params.sts @@ -0,0 +1,15 @@ +{% for id in identifiers %} +{% for static in ["", "static"] %} +{% for params in identifiers_list %} + +/*--- +desc: Empty interface declaration with type parameters +params: {{.static}} interface {{.id}}<{{.params}}>{} +---*/ + +{{.static}} interface {{.id}}<{{.params}}>{} +function main(): void {} + +{% endfor %} +{% endfor %} +{% endfor %} diff --git a/migrator/test/staticTS/CTS/10.interfaces/01.interface_declarations/interface_fields.sts b/migrator/test/staticTS/CTS/10.interfaces/01.interface_declarations/interface_fields.sts new file mode 100644 index 0000000000000000000000000000000000000000..4468ec1663210ef5379fb5450a4be2985340840d --- /dev/null +++ b/migrator/test/staticTS/CTS/10.interfaces/01.interface_declarations/interface_fields.sts @@ -0,0 +1,14 @@ +{% for id in identifiers %} +{% for item in default_value %} + +/*--- +desc: Interface fields with specified types +params: "{{.id}}: {{.item.type}} = {{.item.value}}" +---*/ + +interface Name { + {{.id}}: {{.item.type}} = {{.item.value}}; +} + +{% endfor %} +{% endfor %} diff --git a/migrator/test/staticTS/CTS/10.interfaces/01.interface_declarations/interface_fields_without_types.sts b/migrator/test/staticTS/CTS/10.interfaces/01.interface_declarations/interface_fields_without_types.sts new file mode 100644 index 0000000000000000000000000000000000000000..139a0b27a2d7d96824265bbf170e7a1193fdbc3e --- /dev/null +++ b/migrator/test/staticTS/CTS/10.interfaces/01.interface_declarations/interface_fields_without_types.sts @@ -0,0 +1,14 @@ +{% for id in identifiers %} +{% for item in default_value %} + +/*--- +desc: Interface fields without types +params: "{{.id}} = {{.item.value}}" +---*/ + +interface Name { + {{.id}} = {{.item.value}}; +} + +{% endfor %} +{% endfor %} diff --git a/migrator/test/staticTS/CTS/10.interfaces/01.interface_declarations/list.default_value.yaml b/migrator/test/staticTS/CTS/10.interfaces/01.interface_declarations/list.default_value.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9ffc292f9149ff299af735ba7f392e8bbb9bbce6 --- /dev/null +++ b/migrator/test/staticTS/CTS/10.interfaces/01.interface_declarations/list.default_value.yaml @@ -0,0 +1,10 @@ +--- # List of default values for primitive types + +- {type: byte, value: 0} +- {type: short, value: 0} +- {type: int, value: 0} +- {type: long, value: 0} +- {type: float, value: 0.0} +- {type: double, value: 0.0} +- {type: char, value: '\u0000'} +- {type: boolean, value: false} diff --git a/migrator/test/staticTS/CTS/10.interfaces/01.interface_declarations/list.identifiers.yaml b/migrator/test/staticTS/CTS/10.interfaces/01.interface_declarations/list.identifiers.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ab7ecdcdc919edf11438e87354143a8ae8be509c --- /dev/null +++ b/migrator/test/staticTS/CTS/10.interfaces/01.interface_declarations/list.identifiers.yaml @@ -0,0 +1,8 @@ +--- # List of identifiers + +- debug +- test +- main +- x +- y +- z diff --git a/migrator/test/staticTS/CTS/10.interfaces/01.interface_declarations/list.identifiers_list.yaml b/migrator/test/staticTS/CTS/10.interfaces/01.interface_declarations/list.identifiers_list.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0b4dd3b2d7c0599c70e5726661c54b2c57088094 --- /dev/null +++ b/migrator/test/staticTS/CTS/10.interfaces/01.interface_declarations/list.identifiers_list.yaml @@ -0,0 +1,6 @@ +--- # List containing comma separated identifiers + +- A +- A, B +- A, B, C +- A, B, C, D diff --git a/migrator/test/staticTS/CTS/10.interfaces/01.interface_declarations/n.interface_extends_without_type.sts b/migrator/test/staticTS/CTS/10.interfaces/01.interface_declarations/n.interface_extends_without_type.sts new file mode 100644 index 0000000000000000000000000000000000000000..c9e86e0d284bb5d503bf162d9ee04cd61ea7b670 --- /dev/null +++ b/migrator/test/staticTS/CTS/10.interfaces/01.interface_declarations/n.interface_extends_without_type.sts @@ -0,0 +1,5 @@ +/*--- +desc: Inteface extends must be followed by a type +---*/ + +interface Name extends {} diff --git a/migrator/test/staticTS/CTS/10.interfaces/01.interface_declarations/several_interface_fields.sts b/migrator/test/staticTS/CTS/10.interfaces/01.interface_declarations/several_interface_fields.sts new file mode 100644 index 0000000000000000000000000000000000000000..86fd9ac2c1f14e642e5393d3e9c683d7a2ed648e --- /dev/null +++ b/migrator/test/staticTS/CTS/10.interfaces/01.interface_declarations/several_interface_fields.sts @@ -0,0 +1,9 @@ +/*--- +desc: Several interface fields at the same time +---*/ + +interface Name { +{% for item in default_value %} + {{.item.type}}Field: {{.item.type}} = {{.item.value}}; +{% endfor %} +} diff --git a/migrator/test/staticTS/CTS/10.interfaces/05.interface_field_declarations/interface_field_decl.sts b/migrator/test/staticTS/CTS/10.interfaces/05.interface_field_declarations/interface_field_decl.sts new file mode 100644 index 0000000000000000000000000000000000000000..87d5c914386341b9b354ed8644f1d93e216abbbb --- /dev/null +++ b/migrator/test/staticTS/CTS/10.interfaces/05.interface_field_declarations/interface_field_decl.sts @@ -0,0 +1,15 @@ +/*--- +desc: Interface field declaration +---*/ + +interface BaseColors { + RED: int = 1; + GREEN: int = 2; + BLUE: int = 3; +} + +interface ExtendedColors extends BaseColors { + YELLOW: int = 4; +} + +function main(): void {} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/10.interfaces/06.interface_method_declaration/01.static_interface_methods/n.static_interface_methods.sts b/migrator/test/staticTS/CTS/10.interfaces/06.interface_method_declaration/01.static_interface_methods/n.static_interface_methods.sts new file mode 100644 index 0000000000000000000000000000000000000000..dd6ed91e0466ca828fb9b58846f9d1b60ab1fd23 --- /dev/null +++ b/migrator/test/staticTS/CTS/10.interfaces/06.interface_method_declaration/01.static_interface_methods/n.static_interface_methods.sts @@ -0,0 +1,9 @@ +/*--- +desc: Static interface methods should have a body +---*/ + +interface Vehicle { + static getHorsePower(rpm: int, torque: int): int +} + +function main(): void {} diff --git a/migrator/test/staticTS/CTS/10.interfaces/06.interface_method_declaration/01.static_interface_methods/static_interface_methods.sts b/migrator/test/staticTS/CTS/10.interfaces/06.interface_method_declaration/01.static_interface_methods/static_interface_methods.sts new file mode 100644 index 0000000000000000000000000000000000000000..777d0f9130789a3cc6e5ecf08b01c5902d739f19 --- /dev/null +++ b/migrator/test/staticTS/CTS/10.interfaces/06.interface_method_declaration/01.static_interface_methods/static_interface_methods.sts @@ -0,0 +1,11 @@ +/*--- +desc: Static interface methods +---*/ + +interface Vehicle { + static getHorsePower(rpm: int, torque: int): int { + return (rpm * torque) / 5252; + } +} + +function main(): void {} diff --git a/migrator/test/staticTS/CTS/10.interfaces/06.interface_method_declaration/02.private_interface_methods/n.private_interface_methods.sts b/migrator/test/staticTS/CTS/10.interfaces/06.interface_method_declaration/02.private_interface_methods/n.private_interface_methods.sts new file mode 100644 index 0000000000000000000000000000000000000000..28c2fc94a349cbca3c4eb3557a8ad67bd030f329 --- /dev/null +++ b/migrator/test/staticTS/CTS/10.interfaces/06.interface_method_declaration/02.private_interface_methods/n.private_interface_methods.sts @@ -0,0 +1,9 @@ +/*--- +desc: Private interface methods +---*/ + +interface Vehicle { + private getHorsePower(rpm: int, torque: int): int +} + +function main(): void {} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/10.interfaces/06.interface_method_declaration/02.private_interface_methods/n.private_interface_methods_static.sts b/migrator/test/staticTS/CTS/10.interfaces/06.interface_method_declaration/02.private_interface_methods/n.private_interface_methods_static.sts new file mode 100644 index 0000000000000000000000000000000000000000..bfe508da49ea739060f54d86e971e9c68e3629df --- /dev/null +++ b/migrator/test/staticTS/CTS/10.interfaces/06.interface_method_declaration/02.private_interface_methods/n.private_interface_methods_static.sts @@ -0,0 +1,9 @@ +/*--- +desc: Private interface methods +---*/ + +interface Vehicle { + private static getHorsePower(rpm: int, torque: int): int +} + +function main(): void {} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/10.interfaces/06.interface_method_declaration/02.private_interface_methods/private_interface_methods.sts b/migrator/test/staticTS/CTS/10.interfaces/06.interface_method_declaration/02.private_interface_methods/private_interface_methods.sts new file mode 100644 index 0000000000000000000000000000000000000000..a7b52dbe473feff0865546b1b2cf97fd045b5ff5 --- /dev/null +++ b/migrator/test/staticTS/CTS/10.interfaces/06.interface_method_declaration/02.private_interface_methods/private_interface_methods.sts @@ -0,0 +1,14 @@ +/*--- +desc: Private interface methods +---*/ + +interface Vehicle { + private static getHorsePower(rpm: int, torque: int): int { + return (rpm * torque) / 5252; + } + private getHorsePower2(rpm: int, torque: int): int { + return (rpm * torque) / 5252; + } +} + +function main(): void {} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/11.enums/01.enum_constants/any_number_of_constants.sts b/migrator/test/staticTS/CTS/11.enums/01.enum_constants/any_number_of_constants.sts new file mode 100644 index 0000000000000000000000000000000000000000..fed57f69b20ac73f6d4698ddfdcd0a280cb244f4 --- /dev/null +++ b/migrator/test/staticTS/CTS/11.enums/01.enum_constants/any_number_of_constants.sts @@ -0,0 +1,14 @@ +{% for i in range(100, 1000, 100) %} + +/*--- +desc: Enum must support any number of constants +params: number of consts = {{.i}} +---*/ + +enum GeneratedEnum { +{% for length in range (1, i) -%} + {% for _ in range(length) %}A{% endfor %}{% if length is lt(i - 1)%},{% endif %} +{% endfor %} +} + +{%- endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/11.enums/01.enum_constants/list.identifiers.yaml b/migrator/test/staticTS/CTS/11.enums/01.enum_constants/list.identifiers.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ab7ecdcdc919edf11438e87354143a8ae8be509c --- /dev/null +++ b/migrator/test/staticTS/CTS/11.enums/01.enum_constants/list.identifiers.yaml @@ -0,0 +1,8 @@ +--- # List of identifiers + +- debug +- test +- main +- x +- y +- z diff --git a/migrator/test/staticTS/CTS/11.enums/01.enum_constants/n.empty_enum.sts b/migrator/test/staticTS/CTS/11.enums/01.enum_constants/n.empty_enum.sts new file mode 100644 index 0000000000000000000000000000000000000000..2eb3f73b9e9300b8a927e44cbb671d391bc8044c --- /dev/null +++ b/migrator/test/staticTS/CTS/11.enums/01.enum_constants/n.empty_enum.sts @@ -0,0 +1,6 @@ +/*--- +desc: A enum must have at least one enum constant +---*/ + +enum EmptyEnum {} + diff --git a/migrator/test/staticTS/CTS/11.enums/01.enum_constants/n.repeating_constants.sts b/migrator/test/staticTS/CTS/11.enums/01.enum_constants/n.repeating_constants.sts new file mode 100644 index 0000000000000000000000000000000000000000..62f77fdc24a9f6cf2e6cff79c30cc4b9dd1a1528 --- /dev/null +++ b/migrator/test/staticTS/CTS/11.enums/01.enum_constants/n.repeating_constants.sts @@ -0,0 +1,9 @@ +/*--- +desc: Enum cannot have two constants with equal names +---*/ + +enum Colors { + Red, + {% for id in identifiers %} {{.id}} {% endfor %} + Red +} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/11.enums/01.enum_constants/n.trailing_comma_enum.sts b/migrator/test/staticTS/CTS/11.enums/01.enum_constants/n.trailing_comma_enum.sts new file mode 100644 index 0000000000000000000000000000000000000000..bd252e8c785bdee978d70409409bf91ec1ecf9bc --- /dev/null +++ b/migrator/test/staticTS/CTS/11.enums/01.enum_constants/n.trailing_comma_enum.sts @@ -0,0 +1,9 @@ +/*--- +desc: Trailing commas are not allowed in enum constant lists +---*/ + +enum Colors { + Red, + Green, + Blue, +} diff --git a/migrator/test/staticTS/CTS/11.enums/01.enum_constants/simple_enum.sts b/migrator/test/staticTS/CTS/11.enums/01.enum_constants/simple_enum.sts new file mode 100644 index 0000000000000000000000000000000000000000..984f71d8ac7f1b7d6ccce5fa91fd187a946f567c --- /dev/null +++ b/migrator/test/staticTS/CTS/11.enums/01.enum_constants/simple_enum.sts @@ -0,0 +1,9 @@ +/*--- +desc: Simple enum +---*/ + +enum Colors { + Red, + Green, + Blue +} diff --git a/migrator/test/staticTS/CTS/11.enums/02.enum_type_methods/enum_type_methods_valueof.sts b/migrator/test/staticTS/CTS/11.enums/02.enum_type_methods/enum_type_methods_valueof.sts new file mode 100644 index 0000000000000000000000000000000000000000..70edec03058547810b96ab66a490736f122e7a24 --- /dev/null +++ b/migrator/test/staticTS/CTS/11.enums/02.enum_type_methods/enum_type_methods_valueof.sts @@ -0,0 +1,11 @@ +/*--- +desc: Enum type methods (valueOf) +---*/ + +enum Colors {Red, Green, Blue} + +function main(): void { + let colors = Color.values(); + let red = Color.valueOf("Red"); + assert red == colors[0]; +} diff --git a/migrator/test/staticTS/CTS/11.enums/02.enum_type_methods/enum_type_methods_values.sts b/migrator/test/staticTS/CTS/11.enums/02.enum_type_methods/enum_type_methods_values.sts new file mode 100644 index 0000000000000000000000000000000000000000..fb75f11e747557085d6417b6b3f0ebefade5a8db --- /dev/null +++ b/migrator/test/staticTS/CTS/11.enums/02.enum_type_methods/enum_type_methods_values.sts @@ -0,0 +1,10 @@ +/*--- +desc: Enum type methods (values) +---*/ + +enum Colors {Red, Green, Blue} + +function main(): void { + let colors = Color.values(); + assert colors != []; +} diff --git a/migrator/test/staticTS/CTS/11.enums/03.enum_constant_methods/enum_constant_ordinals.sts b/migrator/test/staticTS/CTS/11.enums/03.enum_constant_methods/enum_constant_ordinals.sts new file mode 100644 index 0000000000000000000000000000000000000000..1861264d855c87176fbf80aa445fba0e1a0f7b17 --- /dev/null +++ b/migrator/test/staticTS/CTS/11.enums/03.enum_constant_methods/enum_constant_ordinals.sts @@ -0,0 +1,15 @@ +/*--- +desc: Enum constant should have an ordinal() method returning its index starting from 0 +---*/ + +enum GeneratedEnum { +{% for length in range(1, 10) -%} + {% for _ in range(length) %}A{% endfor %}{% if length is lt(9)%},{% endif %} +{% endfor %} +} + +function main(): void { +{% for i in range(0, 9) %} + assert GeneratedEnum.{% for _ in range(i + 1)%}A{% endfor %}.ordinal() == {{.i}}; +{%- endfor %} +} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/11.enums/03.enum_constant_methods/enum_constant_to_string.sts b/migrator/test/staticTS/CTS/11.enums/03.enum_constant_methods/enum_constant_to_string.sts new file mode 100644 index 0000000000000000000000000000000000000000..6ab6ee6752b3c9311a8ff64ad6f90d8504711436 --- /dev/null +++ b/migrator/test/staticTS/CTS/11.enums/03.enum_constant_methods/enum_constant_to_string.sts @@ -0,0 +1,15 @@ +/*--- +desc: Enum constant should have an toString() method returning its name +---*/ + +enum GeneratedEnum { +{% for length in range(1, 10) -%} + {% for _ in range(length) %}A{% endfor %}{% if length is lt(9)%},{% endif %} +{% endfor %} +} + +function main(): void { +{% for i in range(0, 9) %} + assert GeneratedEnum.{% for _ in range(i + 1)%}A{% endfor %}.toString() == "{% for _ in range(i + 1)%}A{% endfor %}"; +{%- endfor %} +} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/13.packages/02.import_declarations/import.sts b/migrator/test/staticTS/CTS/13.packages/02.import_declarations/import.sts new file mode 100644 index 0000000000000000000000000000000000000000..238b9f4c37fe6ebc8d940097b1b86996acb82ff5 --- /dev/null +++ b/migrator/test/staticTS/CTS/13.packages/02.import_declarations/import.sts @@ -0,0 +1,11 @@ +{% for name in qualified_names %} + +/*--- +desc: Import declaration without 'as' like 'import a.b.c.d' or 'import a.b.c.*'; +params: qualified name = {{.name}} +---*/ + +import {{.name}}; +import {{.name}}.*; + +{% endfor %} diff --git a/migrator/test/staticTS/CTS/13.packages/02.import_declarations/import_as.sts b/migrator/test/staticTS/CTS/13.packages/02.import_declarations/import_as.sts new file mode 100644 index 0000000000000000000000000000000000000000..031d250d47ff0556b96aa230099e7446a2d9b81a --- /dev/null +++ b/migrator/test/staticTS/CTS/13.packages/02.import_declarations/import_as.sts @@ -0,0 +1,11 @@ +{% for name in qualified_names %} +{% for id in words %} +/*--- +desc: Import declaration with 'as' like 'import a.b.c.d as name' +params: qualified name = {{.name}}, identifier = {{.id}} +---*/ + +import {{.name}} as {{.id}}; + +{% endfor %} +{% endfor %} diff --git a/migrator/test/staticTS/CTS/13.packages/02.import_declarations/list.qualified_names.yaml b/migrator/test/staticTS/CTS/13.packages/02.import_declarations/list.qualified_names.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7432a843f5075c1e7bf08a873e2f65fe91441ebf --- /dev/null +++ b/migrator/test/staticTS/CTS/13.packages/02.import_declarations/list.qualified_names.yaml @@ -0,0 +1,6 @@ +--- # List of qualified names + +- A.B.C +- java.lang.String +- A.B.C.D.R +- java.concurrency.BlockingQueue diff --git a/migrator/test/staticTS/CTS/13.packages/02.import_declarations/list.words.yaml b/migrator/test/staticTS/CTS/13.packages/02.import_declarations/list.words.yaml new file mode 100644 index 0000000000000000000000000000000000000000..cc2d8e915af45c29e917812b6f835f19e15c83de --- /dev/null +++ b/migrator/test/staticTS/CTS/13.packages/02.import_declarations/list.words.yaml @@ -0,0 +1,8 @@ +--- # List of simple words that can be used as an identifier + +- "yes" +- "no" +- x +- xx +- y +- identifier diff --git a/migrator/test/staticTS/CTS/13.packages/02.import_declarations/n.import_all_as.sts b/migrator/test/staticTS/CTS/13.packages/02.import_declarations/n.import_all_as.sts new file mode 100644 index 0000000000000000000000000000000000000000..c04038ab3394ecf973f0f443bb3f824852348d5e --- /dev/null +++ b/migrator/test/staticTS/CTS/13.packages/02.import_declarations/n.import_all_as.sts @@ -0,0 +1,11 @@ +{% for name in qualified_names %} +{% for id in words %} +/*--- +desc: In import declaration usage of '*' and 'as' simultaneously is prohibited +params: qualified name = {{.name}}, identifier = {{.id}} +---*/ + +import {{.name}}.* as {{.id}}; + +{% endfor %} +{% endfor %} diff --git a/migrator/test/staticTS/CTS/13.packages/05.export_declarations/export_declarations.sts b/migrator/test/staticTS/CTS/13.packages/05.export_declarations/export_declarations.sts new file mode 100644 index 0000000000000000000000000000000000000000..bd832f9627701373cfdc055f232272c3d3444f44 --- /dev/null +++ b/migrator/test/staticTS/CTS/13.packages/05.export_declarations/export_declarations.sts @@ -0,0 +1,12 @@ +{% for decl in toplevel_declarations %} + +/*--- +desc: \'export\' keyword can be added to any toplevel declaration +params: | + {{.decl}} +---*/ + +export {{.decl}} +function main(): void {} + +{%- endfor %} diff --git a/migrator/test/staticTS/CTS/13.packages/05.export_declarations/list.grouped_declarations.yaml b/migrator/test/staticTS/CTS/13.packages/05.export_declarations/list.grouped_declarations.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c23f924f4ac5f68e186b2fd6864c24422225c13d --- /dev/null +++ b/migrator/test/staticTS/CTS/13.packages/05.export_declarations/list.grouped_declarations.yaml @@ -0,0 +1,5 @@ +--- # List of declarations, grouped into list. These cannot be used as toplevel declarations + +- "let c = 1, b = 2;" +- "let c: int = 2, b = 1.0, z = \"hello\";" +- "const a: int = 1, b = \"a string\";" diff --git a/migrator/test/staticTS/CTS/13.packages/05.export_declarations/list.toplevel_declarations.yaml b/migrator/test/staticTS/CTS/13.packages/05.export_declarations/list.toplevel_declarations.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c0cb417eb0cc7b0b35ffae97a5af92196b012258 --- /dev/null +++ b/migrator/test/staticTS/CTS/13.packages/05.export_declarations/list.toplevel_declarations.yaml @@ -0,0 +1,21 @@ +--- # List of toplevel declarations + +- "class Point {}" +- "interface A {}" +- "enum Enum { v1, v2 }" + +# Variable declarations + +- "let origin = 1;" +- "let i: int = 1;" +- "let b: byte;" + +# Constant declarations + +- "const b = 1;" +- "const s = \"str\";" +- "const a: int = 1;" + +# Function declarations + +- "function dist(x: int, y: int): void {}" diff --git a/migrator/test/staticTS/CTS/13.packages/05.export_declarations/n.exported_grouped_declarations.sts b/migrator/test/staticTS/CTS/13.packages/05.export_declarations/n.exported_grouped_declarations.sts new file mode 100644 index 0000000000000000000000000000000000000000..4ac879a76af210b503a80dca90f27a2dc038586a --- /dev/null +++ b/migrator/test/staticTS/CTS/13.packages/05.export_declarations/n.exported_grouped_declarations.sts @@ -0,0 +1,12 @@ +{% for decl in grouped_declarations %} + +/*--- +desc: Grouped declarations cannot be exported +params: | + {{.decl}} +---*/ + +export {{.decl}} +function main(): void {} + +{%- endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/CTS/13.packages/06.program_entry_point/list.identifiers.yaml b/migrator/test/staticTS/CTS/13.packages/06.program_entry_point/list.identifiers.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ab7ecdcdc919edf11438e87354143a8ae8be509c --- /dev/null +++ b/migrator/test/staticTS/CTS/13.packages/06.program_entry_point/list.identifiers.yaml @@ -0,0 +1,8 @@ +--- # List of identifiers + +- debug +- test +- main +- x +- y +- z diff --git a/migrator/test/staticTS/CTS/13.packages/06.program_entry_point/multiple_entrypoints.sts b/migrator/test/staticTS/CTS/13.packages/06.program_entry_point/multiple_entrypoints.sts new file mode 100644 index 0000000000000000000000000000000000000000..cf7b3080cbf4a7f8ea90ba51f194e15ea8e36c42 --- /dev/null +++ b/migrator/test/staticTS/CTS/13.packages/06.program_entry_point/multiple_entrypoints.sts @@ -0,0 +1,13 @@ +/*--- +desc: Multiple entrypoints with different names +---*/ + +package test; + +function main(): void {} + +{% for id in identifiers %} + +function main${{.id}}(): void {} + +{%- endfor %} \ No newline at end of file diff --git a/migrator/test/staticTS/SimpleLanguage/invalid/AccessFannkuch.sts b/migrator/test/staticTS/SimpleLanguage/AccessFannkuch.sts similarity index 92% rename from migrator/test/staticTS/SimpleLanguage/invalid/AccessFannkuch.sts rename to migrator/test/staticTS/SimpleLanguage/AccessFannkuch.sts index b63d71b8bbbd1cbe72110a85e7a914834264150c..e737cae6db4cd1c905f9998e9422836f1fde3359 100644 --- a/migrator/test/staticTS/SimpleLanguage/invalid/AccessFannkuch.sts +++ b/migrator/test/staticTS/SimpleLanguage/AccessFannkuch.sts @@ -25,13 +25,9 @@ export class AccessFannkuch { public setup(): void {} public fannkuch(n: int): int { - // Not parsed new int[n] let perm: int[] = new int[n]; - // Not parsed new int[n] let perm1: int[] = new int[n]; - // Not parsed new int[n] let count: int[] = new int[n]; - // Not parsed new int[n] let maxPerm: int[] = new int[n]; let maxFlipsCount: int = 0; let m: int = n - 1; @@ -42,7 +38,8 @@ export class AccessFannkuch { while (r != 1) { count[r - 1] = r; r--; - } if (!(perm1[0] == 0 || perm1[m] == m)) { + } + if (!(perm1[0] == 0 || perm1[m] == m)) { for (let i: int = 0; i < n; i++) perm[i] = perm1[i]; let flipsCount: int = 0; diff --git a/migrator/test/staticTS/SimpleLanguage/invalid/AccessNBody.sts b/migrator/test/staticTS/SimpleLanguage/AccessNBody.sts similarity index 76% rename from migrator/test/staticTS/SimpleLanguage/invalid/AccessNBody.sts rename to migrator/test/staticTS/SimpleLanguage/AccessNBody.sts index 0e4b84079dedcdbc57734e50ad9344444b16ed62..f35b7a3ec8f42c7fdc655b155fa50c42e44846b1 100644 --- a/migrator/test/staticTS/SimpleLanguage/invalid/AccessNBody.sts +++ b/migrator/test/staticTS/SimpleLanguage/AccessNBody.sts @@ -122,7 +122,7 @@ export class AccessNBody { for (let i: int = 0; i < size; i++) { let bodyi: Body = this.bodies[i]; - e += 0.5 * bodyi.mass * (bodyi.vx * bodyi.vx + bodyi.vy * bodyi.vy + bodyi.vz * bodyi.vz); + e += 0.5 * bodyi.mass * (bodyi.vx * bodyi.vx + bodyi.vy * bodyi.vy + bodyi.vz * bodyi.vz); for (let j: int = i + 1; j < size; j++) { let bodyj: Body = this.bodies[j]; @@ -141,49 +141,49 @@ export class AccessNBody { private static jupiter(): Body { return new Body( - 4.84143144246472090e+00, - -1.16032004402742839e+00, - -1.03622044471123109e-01, - 1.66007664274403694e-03 * DAYS_PER_YEAR, - 7.69901118419740425e-03 * DAYS_PER_YEAR, - -6.90460016972063023e-05 * DAYS_PER_YEAR, - 9.54791938424326609e-04 * SOLAR_MASS + 4.84143144246472090e+0, + -1.16032004402742839e+0, + -1.03622044471123109e-1, + 1.66007664274403694e-3 * DAYS_PER_YEAR, + 7.69901118419740425e-3 * DAYS_PER_YEAR, + -6.90460016972063023e-5 * DAYS_PER_YEAR, + 9.54791938424326609e-4 * SOLAR_MASS ); } private static saturn(): Body { return new Body( - 8.34336671824457987e+00, - 4.12479856412430479e+00, - -4.03523417114321381e-01, - -2.76742510726862411e-03 * DAYS_PER_YEAR, - 4.99852801234917238e-03 * DAYS_PER_YEAR, - 2.30417297573763929e-05 * DAYS_PER_YEAR, - 2.85885980666130812e-04 * SOLAR_MASS + 8.34336671824457987e+0, + 4.12479856412430479e+0, + -4.03523417114321381e-1, + -2.76742510726862411e-3 * DAYS_PER_YEAR, + 4.99852801234917238e-3 * DAYS_PER_YEAR, + 2.30417297573763929e-5 * DAYS_PER_YEAR, + 2.85885980666130812e-4 * SOLAR_MASS ); } private static uranus(): Body { return new Body( - 1.28943695621391310e+01, - -1.51111514016986312e+01, - -2.23307578892655734e-01, - 2.96460137564761618e-03 * DAYS_PER_YEAR, - 2.37847173959480950e-03 * DAYS_PER_YEAR, - -2.96589568540237556e-05 * DAYS_PER_YEAR, - 4.36624404335156298e-05 * SOLAR_MASS + 1.28943695621391310e+1, + -1.51111514016986312e+1, + -2.23307578892655734e-1, + 2.96460137564761618e-3 * DAYS_PER_YEAR, + 2.37847173959480950e-3 * DAYS_PER_YEAR, + -2.96589568540237556e-5 * DAYS_PER_YEAR, + 4.36624404335156298e-5 * SOLAR_MASS ); } private static neptune(): Body { return new Body( - 1.53796971148509165e+01, - -2.59193146099879641e+01, - 1.79258772950371181e-01, - 2.68067772490389322e-03 * DAYS_PER_YEAR, - 1.62824170038242295e-03 * DAYS_PER_YEAR, - -9.51592254519715870e-05 * DAYS_PER_YEAR, - 5.15138902046611451e-05 * SOLAR_MASS + 1.53796971148509165e+1, + -2.59193146099879641e+1, + 1.79258772950371181e-1, + 2.68067772490389322e-3 * DAYS_PER_YEAR, + 1.62824170038242295e-3 * DAYS_PER_YEAR, + -9.51592254519715870e-5 * DAYS_PER_YEAR, + 5.15138902046611451e-5 * SOLAR_MASS ); } @@ -191,13 +191,11 @@ export class AccessNBody { return new Body(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, SOLAR_MASS); } - public run(): void { let ret: double = 0.0; for (let n: int = this.n1; n <= this.n2; n *= 2) { let bodies: NBodySystem = new NBodySystem( - // Not parsed new Body[...] - new Body[]([sun(), jupiter(), saturn(), uranus(), neptune()]) + // [sun(), jupiter(), saturn(), uranus(), neptune()] ); let max: int = n * 100; ret += bodies.energy(); @@ -212,5 +210,6 @@ export class AccessNBody { } Consumer.consumeDouble(ret); } + } diff --git a/migrator/test/staticTS/SimpleLanguage/invalid/AccessNSieve.sts b/migrator/test/staticTS/SimpleLanguage/AccessNSieve.sts similarity index 97% rename from migrator/test/staticTS/SimpleLanguage/invalid/AccessNSieve.sts rename to migrator/test/staticTS/SimpleLanguage/AccessNSieve.sts index 80a744a7f38bbbb870e911eda246a69a94cefb2c..e1eca649b59af4e5ea14cb62f802a3af4cf298bc 100644 --- a/migrator/test/staticTS/SimpleLanguage/invalid/AccessNSieve.sts +++ b/migrator/test/staticTS/SimpleLanguage/AccessNSieve.sts @@ -22,7 +22,6 @@ export class AccessNSieve { static isPrime: boolean[]; public setup(): void { - // Not parsed new boolean[...] this.isPrime = new boolean[(1 << n1) * n2 + 1]; } diff --git a/migrator/test/staticTS/SimpleLanguage/invalid/BitopsNSieveBits.sts b/migrator/test/staticTS/SimpleLanguage/BitopsNSieveBits.sts similarity index 98% rename from migrator/test/staticTS/SimpleLanguage/invalid/BitopsNSieveBits.sts rename to migrator/test/staticTS/SimpleLanguage/BitopsNSieveBits.sts index 03b7b7f42b37fba50296c4ca08fc403067a4189f..048b1ba2daf667901f9d16ca4b26f64714ab2b83 100644 --- a/migrator/test/staticTS/SimpleLanguage/invalid/BitopsNSieveBits.sts +++ b/migrator/test/staticTS/SimpleLanguage/BitopsNSieveBits.sts @@ -34,7 +34,6 @@ export class BitopsNSieveBits { } private static sieve(n1: int, n2: int): int[] { - // Not parsed new int[...] let isPrime: int[] = new int[(n2 << n1) + 31 >> 5]; primes(isPrime, n1, n2); return isPrime; diff --git a/migrator/test/staticTS/SimpleLanguage/invalid/MathCordic.sts b/migrator/test/staticTS/SimpleLanguage/MathCordic.sts similarity index 96% rename from migrator/test/staticTS/SimpleLanguage/invalid/MathCordic.sts rename to migrator/test/staticTS/SimpleLanguage/MathCordic.sts index 73d72b473cc2bcd6b557b720b0676ad2a84efbdd..6e2afecfd97fc7f5591e4e85d594af5c72c641fd 100644 --- a/migrator/test/staticTS/SimpleLanguage/invalid/MathCordic.sts +++ b/migrator/test/staticTS/SimpleLanguage/MathCordic.sts @@ -20,12 +20,11 @@ export class MathCordic { static const TARGET_ANGLE: double = 28.027; static const expected: double = 10362.570468755888; - // Not parsed new double[] - static const ANGLES: double[] = new double[] { + static const ANGLES: double[] = [ fnFixed(45.0), fnFixed(26.565), fnFixed(14.0362), fnFixed(7.12502), fnFixed(3.57633), fnFixed(1.78991), fnFixed(0.895174), fnFixed(0.447614), fnFixed(0.223811), fnFixed(0.111906), fnFixed(0.055953), fnFixed(0.027977) - }; + ]; private static fnFixed(x: double): double { return x * 65536.0; diff --git a/migrator/test/staticTS/SimpleLanguage/invalid/MathSpectralNorm.sts b/migrator/test/staticTS/SimpleLanguage/MathSpectralNorm.sts similarity index 96% rename from migrator/test/staticTS/SimpleLanguage/invalid/MathSpectralNorm.sts rename to migrator/test/staticTS/SimpleLanguage/MathSpectralNorm.sts index e789fa4eed17bcdeaecc9129bd58b62edf357d10..ec71353551272510ed952a8931fc3403edf2da96 100644 --- a/migrator/test/staticTS/SimpleLanguage/invalid/MathSpectralNorm.sts +++ b/migrator/test/staticTS/SimpleLanguage/MathSpectralNorm.sts @@ -47,11 +47,8 @@ export class MathSpectralNorm { private static spectralnorm(n: int): void { let i: int; - // Not parsed new double[n] let u: double[] = new double[n]; - // Not parsed new double[n] let w: double[] = new double[n]; - // Not parsed new double[n] let v: double[] = new double[n]; let vbv: double = 0; let vv: double = 0; diff --git a/migrator/test/staticTS/SimpleLanguage/invalid/Morph3d.sts b/migrator/test/staticTS/SimpleLanguage/Morph3d.sts similarity index 98% rename from migrator/test/staticTS/SimpleLanguage/invalid/Morph3d.sts rename to migrator/test/staticTS/SimpleLanguage/Morph3d.sts index 033eefcf68870f6a076bdb1876e4bcd5707394ef..160a375d95f506cb3d6521c070ee26da6fd01651 100644 --- a/migrator/test/staticTS/SimpleLanguage/invalid/Morph3d.sts +++ b/migrator/test/staticTS/SimpleLanguage/Morph3d.sts @@ -20,7 +20,6 @@ export class Morph3d { static a: double[]; public setup(): void { - // Not parsed new double[...] a = new double[param * param * 3]; for (let i: int = 0; i < param * param * 3; i++) { a[i] = 0; diff --git a/migrator/test/staticTS/SimpleLanguage/invalid/StringBase64.sts b/migrator/test/staticTS/SimpleLanguage/StringBase64.sts similarity index 96% rename from migrator/test/staticTS/SimpleLanguage/invalid/StringBase64.sts rename to migrator/test/staticTS/SimpleLanguage/StringBase64.sts index 4ff8dd15493ce17629fc6bc4a32b08f749249633..ec0f594d94fb13d39156282747c900e49cb22757 100644 --- a/migrator/test/staticTS/SimpleLanguage/invalid/StringBase64.sts +++ b/migrator/test/staticTS/SimpleLanguage/StringBase64.sts @@ -17,10 +17,9 @@ import utils.Consumer; export class StringBase64 { private static const TO_BASE64_TABLE: String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - + "abcdefghijklmnopqrstuvwxyz0123456789+/"; + + "abcdefghijklmnopqrstuvwxyz0123456789+/"; private static const BASE64PAD: char = '='; - // Not parsed new int[] - private static const TO_BINARY_TABLE: int[] = new int[]{ + private static const TO_BINARY_TABLE: int[] = [ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, @@ -29,7 +28,7 @@ export class StringBase64 { 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1 - }; + ]; private static toBase64(data: String): String { let result: StringBuilder = new StringBuilder(); diff --git a/migrator/test/staticTS/SimpleLanguage/invalid/StringFasta.sts b/migrator/test/staticTS/SimpleLanguage/StringFasta.sts similarity index 99% rename from migrator/test/staticTS/SimpleLanguage/invalid/StringFasta.sts rename to migrator/test/staticTS/SimpleLanguage/StringFasta.sts index b0d977315c85bb96ab03c821eacb89a75f253f92..9a76094f759da1184af3f680f04dcb2532360c60 100644 --- a/migrator/test/staticTS/SimpleLanguage/invalid/StringFasta.sts +++ b/migrator/test/staticTS/SimpleLanguage/StringFasta.sts @@ -104,7 +104,6 @@ export class StringFasta { let ret: int = 0; while (n > 0) { if (n < line.length) { - // Not parsed new char[n] line = new char[n]; } for (let i: int = 0; i < line.length; i++) { diff --git a/migrator/test/staticTS/example.spec.yaml b/migrator/test/staticTS/example.spec.yaml new file mode 100644 index 0000000000000000000000000000000000000000..02eb793e727100c22f5b16dd4e7234060cdbd8d0 --- /dev/null +++ b/migrator/test/staticTS/example.spec.yaml @@ -0,0 +1,15 @@ +--- +- name: 1.INTRODUCTION +- name: 2.LEXICAL ELEMENTS + children: + - name: 1.COMMENTS + desc: asdas + - name: 2.TOKENS + desc: asdasd123 + children: + - name: 1.WHITESPACES + desc: asdas12321 + - name: 2.LINE SEPARATORS + desc: asdasd + - name: 3.IDENTIFIERS + desc: sdfsdfs diff --git a/migrator/test/staticTS/formatChecker/README.md b/migrator/test/staticTS/formatChecker/README.md new file mode 100644 index 0000000000000000000000000000000000000000..436a53fcb39bd01101e49cb87bf8791348fcea05 --- /dev/null +++ b/migrator/test/staticTS/formatChecker/README.md @@ -0,0 +1,46 @@ +# STS CTS Format Checker + +> Stabilized format for writing tests and a proof of concept test generator uses that format + + +Tests in STS CTS should be generated to increase developer productivity. +Tests can be generated using the idea of templates and parameters: test developers define programs with placeholder spot (a.k.a. templates) and values which can be substituted in those spots (parameters). + +The test generator must define a certain format for writing templates and parameters. +In `Format Checker` we try to stabilize this format by implementing a Proof of Concept tool that eats test files in the specified format and generates ready-to-execute tests. + +## Getting Started + +1. Install all dependencies: `source formatChecker/setup.sh`; or activate venv if you have already executed the setup script: `source formatChecker/.venv/bin/activate` + +2. Generate CTS: `python3 formatChecker/generate.py CTS ./formatChecker/output` + +3. Build migration tool: at project root run `ant build` + +4. Run tests: `python3 formatChecker/run_tests.py ./formatChecker/output ../../out/migrator-0.1.jar` + +5. Get coverage: `python3 formatChecker/coverage.py ./formatChecker/output [--specpath=./example.spec.yaml]` + +## File Structure + +TBD + +### File Naming Convention + +TBD + +## Format + +TBD + +### Test meta information + +TBD + +### Test file (template) format + +TBD + +### Parameter list file format + +TBD \ No newline at end of file diff --git a/migrator/test/staticTS/formatChecker/coverage.py b/migrator/test/staticTS/formatChecker/coverage.py new file mode 100644 index 0000000000000000000000000000000000000000..5950e1707c2f790f481935faccc410dbf5a6f9d3 --- /dev/null +++ b/migrator/test/staticTS/formatChecker/coverage.py @@ -0,0 +1,171 @@ +# +# Copyright (c) 2022-2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +from math import fabs +from pathlib import Path +import argparse +from typing import Tuple + +from utils.constants import TEMPLATE_EXTENSION +from utils.test_case import is_negative, strip_template +from utils.file_structure import TestDirectory, walk_test_subdirs, build_directory_tree, print_tree, denormalize_section_name +from utils.spec import build_spec_tree + +def count_tests(dir: TestDirectory): + pos_tests = 0 + neg_tests = 0 + templates = set() + + for testfile in dir.iter_files(allowed_ext=[TEMPLATE_EXTENSION]): + if is_negative(testfile): + neg_tests += 1 + else: + pos_tests += 1 + template_name, _ = strip_template(testfile) + templates.add(template_name) + return pos_tests, neg_tests, len(templates) + + +def print_table_of_contents(testpath: Path): + total_templates = 0 + total_positive_tests = 0 + total_negative_tests = 0 + + print("Table of contents:\n") + for dir in walk_test_subdirs(testpath): + full_index = dir.full_index() + depth = len(full_index) + assert depth >= 1 + # Count + pos_tests, neg_tests, n_templates = count_tests(dir) + # Save + total_positive_tests += pos_tests + total_negative_tests += neg_tests + total_templates += n_templates + # Print + left_space = " " * 2 * depth + section_index = ".".join([str(i) for i in full_index]) + section_name = denormalize_section_name(dir.name) + right_space = 90 - len(left_space) - len(section_index) - len(section_name) + if not dir.is_empty(): + print(left_space, section_index, section_name, "." * right_space, f"templates: {n_templates}; tests: {pos_tests} pos, {neg_tests} neg.\n") + + print("\n=====") + print(f"TOTAL TESTS {total_positive_tests + total_negative_tests} | TOTAL TEMPLATES {total_templates} | TOTAL POSITIVE TESTS {total_positive_tests} | TOTAL NEGATIVE TESTS {total_negative_tests}") + + +def find_diffs(test: TestDirectory, ethalon: TestDirectory, strict: bool = False, silent: bool = False): + diff_detected = False + + for esd in ethalon.subdirs: + tsd = test.find_subdir_by_name(esd.name) + + esd_index = esd.full_index() + esd_section_index = ".".join([str(i) for i in esd_index][1:]) + esd_section_name = denormalize_section_name(esd.name) + + if tsd is None: + diff_detected = True + if not strict: + tsd = test.find_subdir_by_id(esd.id) + if not tsd is None and not find_diffs(tsd, esd, strict=True, silent=True): + tsd_section_name = denormalize_section_name(tsd.name) + if not silent: + print(f"[Missmath]: Subsection's name missmath [{esd_section_index}]: '{esd_section_name}' (spec) != '{tsd_section_name}' (tests).") + else: + if not silent: + print(f"[NotFound]: Subsection [{esd_section_index}.{esd_section_name}] not fould in tests.") + + continue + + if tsd.id != esd.id: + diff_detected = True + + tsd_index = tsd.full_index() + tsd_section_index = ".".join([str(i) for i in tsd_index][1:]) + tsd_section_name = denormalize_section_name(tsd.name) + + if not strict: + if not find_diffs(tsd, esd, strict=True, silent=True): + if not silent: + print(f"[Missmath]: Index missmath for [{esd_section_name}]: {esd_section_index} (spec) != {tsd_section_index} (tests) but content is equal.") + else: + if not silent: + print(f"[Missmath]: Subsection [{tsd_section_index}.{tsd_section_name}] from tests has a different index and content in compare with [{esd_section_index}.{esd_section_name}] from spec.") + continue + + find_diffs(tsd, esd) + + return diff_detected + + +def calc_tests_and_spec_stat(test: TestDirectory, spec: TestDirectory, tnum: int = 0, snum: int = 0)-> Tuple[int, int]: + for esd in spec.subdirs: + snum += 1 + tsd = test.find_subdir_by_name(esd.name) + + if not tsd is None and tsd.id == esd.id: + tnum += 1 + tnum, snum = calc_tests_and_spec_stat(tsd, esd, tnum, snum) + + return tnum, snum + + +def coverage(testpath: Path, specpath: Path): + ethalon_tree = TestDirectory(id=-1, name="root", path="", parent=None) + build_spec_tree(specpath=specpath, root=ethalon_tree) + + test_tree = TestDirectory(id=-1, name="root", path=testpath, parent=None) + build_directory_tree(test_tree) + + #print_tree(ethalon_tree) + print(f"=====\nDIFF tests='{str(testpath)}'; spec='{str(specpath)}'") + find_diffs(test_tree, ethalon_tree) + + testsNum, specNum = calc_tests_and_spec_stat(test_tree, ethalon_tree) + coverage = int(float(testsNum) / float(specNum) * 100) + print(f"=====\nCOVEARGE: {coverage}%") + + + +parser = argparse.ArgumentParser(description='Run CTS tests.') +parser.add_argument('tests_dir', help='Path to directory that contains the tests.') +parser.add_argument('--specpath', help='Path to file with STS specification in YAML format.', required=False) + + +def main(): + args = parser.parse_args() + + testpath = Path(args.tests_dir) + + # Verify that CTS dir exists + if not testpath.is_dir(): + print(f"ERROR: Path '{testpath}' must point to a directory") + exit(1) + + print_table_of_contents(testpath) + + if not args.specpath is None: + specpath = Path(args.specpath) + + if not specpath.is_file(): + print(f"ERROR: Path '{specpath}' must point to a file with STS spec") + exit(1) + + coverage(testpath, specpath) + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/migrator/test/staticTS/formatChecker/generate.py b/migrator/test/staticTS/formatChecker/generate.py new file mode 100644 index 0000000000000000000000000000000000000000..6cdc2271a0485a07e50cc3625e34f13012f9fa81 --- /dev/null +++ b/migrator/test/staticTS/formatChecker/generate.py @@ -0,0 +1,143 @@ +# +# Copyright (c) 2022-2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import argparse +from email import message +import os +import os.path as ospath +from pathlib import Path +from re import T +from unittest import loader +from jinja2 import Environment, FileSystemLoader, select_autoescape, TemplateSyntaxError +from typing import List +from utils.file_structure import walk_test_subdirs +from utils.metainformation import InvalidMetaException, find_all_metas +from utils.fsutils import iter_files, write_file +from utils.constants import SKIP_PREFIX, VARIABLE_START_STRING, YAML_EXTENSIONS, TEMPLATE_EXTENSION, OUT_EXTENSION, LIST_PREFIX +from utils.exceptions import * +from utils.test_parameters import load_params + +# ============================================ +# Working with templates and their results + +env = Environment( + loader=FileSystemLoader("."), + autoescape=select_autoescape(), + variable_start_string=VARIABLE_START_STRING +) + +def render_template(filepath: str, params=dict()) -> str: + """ + Renders a single template and returns result as string + """ + try: + template = env.get_template(filepath) + return template.render(**params) + except TemplateSyntaxError as e: + raise InvalidFileFormatException(message=f"Tempate Syntax Error: ${e.message}", filepath=filepath) + except Exception as e: + raise UnknownTemplateException(filepath=filepath, exception=e) + + +def split_into_tests(text: str, filepath: str) -> List[str]: + """ + Splits rendered template into multiple tests. + 'filepath' is needed for exceptions + """ + result = [] + + try: + start_indices = [metainfile[0] for metainfile in find_all_metas(text)] + except InvalidMetaException as e: + raise InvalidFileFormatException(filepath=filepath, message=f"Error raised while splitting a rendered template: {e.message}") + + for i in range(1, len(start_indices)): + left = start_indices[i - 1] + right = start_indices[i] + result.append(text[left:right]) + result.append(text[start_indices[-1]:]) + + return result + + +# ============================================ +# Recursively walk the FS, save rendered templates + +def render_and_write_templates(dirpath, outpath): + """ + Loads parameters and renders all templates in `dirpath`. + Saves the results in `outpath` + """ + os.makedirs(outpath, exist_ok=True) + + params = load_params(dirpath) + for name, path in iter_files(dirpath, allowed_ext=[TEMPLATE_EXTENSION]): + name_without_ext, _ = ospath.splitext(name) + if name_without_ext.startswith(SKIP_PREFIX): + continue + tests = split_into_tests(render_template(path, params), path) + assert len(tests) > 0, "Internal error: there should be tetst" + if len(tests) == 1: + # if there is only one test we do not add any suffixes + write_file(path=ospath.join(outpath, name), text=tests[0]) + else: + # if there are multiple tests we add any suffixes: name_0.sts, name_1.sts and etc + for i, test in enumerate(tests): + output_filepath = ospath.join(outpath, f"{name_without_ext}_{i}{OUT_EXTENSION}") + write_file(path=output_filepath, text=test) + +def process_tests(root: Path, outpath: Path): + """ + Renders all templates and saves them. + """ + for dir in walk_test_subdirs(root): + dir_outpath = outpath / dir.path.relative_to(root) + render_and_write_templates(str(dir.path), str(dir_outpath)) + + +# ============================================ +# Entry + + +parser = argparse.ArgumentParser(description='Generate CTS tests from a set of templates.') +parser.add_argument('tests_dir', help='Path to directory that contains tests templates and parameters') +parser.add_argument('output_dir', help='Path to output directory. Output directory and all subdirectories are created automatically') + + +def main(): + args = parser.parse_args() + root = Path(args.tests_dir) + outpath = Path(args.output_dir) + + if not root.is_dir(): + print(f"ERROR: {str(root.absolute())} must be a directory") + exit(1) + + try: + process_tests(root, outpath) + except InvalidFileFormatException as e: + print("Error:\n", e.message) + exit(1) + except InvalidFileStructureException as e: + print("Error:\n", e.message) + exit(1) + except UnknownTemplateException as e: + print(f"{e.filepath}: exception while processing template:") + print("\t", repr(e.exception)) + exit(1) + print("Finished") + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/migrator/test/staticTS/formatChecker/requirements.txt b/migrator/test/staticTS/formatChecker/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..87d456b431446ee704657381e7c30497d7c87147 --- /dev/null +++ b/migrator/test/staticTS/formatChecker/requirements.txt @@ -0,0 +1,3 @@ +Jinja2==3.1.2 +MarkupSafe==2.1.1 +PyYAML==6.0 \ No newline at end of file diff --git a/migrator/test/staticTS/formatChecker/run_tests.py b/migrator/test/staticTS/formatChecker/run_tests.py new file mode 100644 index 0000000000000000000000000000000000000000..de8286f20a225c201088f1a770f664f558409625 --- /dev/null +++ b/migrator/test/staticTS/formatChecker/run_tests.py @@ -0,0 +1,167 @@ +# +# Copyright (c) 2022-2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +from dataclasses import dataclass +from pathlib import Path +from utils.file_structure import walk_test_subdirs +from utils.metainformation import InvalidMetaException, find_all_metas +from utils.exceptions import InvalidFileFormatException, InvalidFileStructureException +from utils.constants import JAR_EXTENSION, TEMPLATE_EXTENSION, NEGATIVE_PREFIX +import subprocess +import argparse +import os.path as ospath +from typing import List + + +# ======================================================= +# Test diagnostics + + +def load_test_meta(testpath: Path) -> dict: + testpath = str(testpath) + # TODO: move to fsutils + with open(testpath, "r") as f: + test = f.read() + + try: + metas = find_all_metas(test) + except InvalidMetaException as e: + raise InvalidFileFormatException(filepath=testpath, message=f"ERROR: {str(e)}") + + if len(metas) == 0: + raise InvalidFileFormatException(filepath=testpath, message="No meta found in file") + elif len(metas) > 1: + raise InvalidFileFormatException(filepath=testpath, message="Multiple meta found in file") + else: + _, _, meta = metas[0] + return meta + + +def print_test_failure(filepath: Path): + print("\nFAIL:", filepath) + try: + meta = load_test_meta(filepath) + for key in meta.keys(): + print(f"\t{key}: {meta[key]}") + except InvalidFileFormatException as e: + print(f"\tERROR: Could not load test's meta: {str(e)}") + + +# ======================================================= +# Run tests + + +@dataclass +class RunStats: + """ + Test execution statistics + """ + failed: List[Path] + passed: List[Path] + + def __init__(self): + self.failed = [] + self.passed = [] + + def record_failure(self, path: Path): + self.failed.append(path) + + def record_success(self, path: Path): + self.passed.append(path) + +def test_should_pass(filepath: Path) -> bool: + return not filepath.name.startswith(NEGATIVE_PREFIX) + +def run_test(filepath: Path, runnerpath: Path) -> bool: + """ + Runs the tests and returns True if it passed. + Takes into account the test's type (positive or negative) + """ + # TODO: Make a separate entity describes process of running the test. + # TODO: Each instance or children (depends on design) have to the method 'run' with (status, message, payload) as result + code = subprocess.run( + ["java", "-jar", str(runnerpath), "-T", str(filepath)], + stderr=subprocess.DEVNULL, + stdout=subprocess.DEVNULL + ).returncode + + passed = (code == 0) + + return passed == test_should_pass(filepath) + + +def run_tests(root: Path, runnerpath: Path) -> bool: + """ + Runs all tests in a test-suite + """ + stats = RunStats() + + for dir in list(walk_test_subdirs(root)): + for filepath in dir.iter_files(): + if ospath.isdir(filepath): + continue + if run_test(filepath, runnerpath) == True: + stats.record_success(filepath) + else: + stats.record_failure(filepath) + print_test_failure(filepath) + + return stats + + +# ======================================================= +# Entry + + +parser = argparse.ArgumentParser(description='Run CTS tests.') +parser.add_argument('tests_dir', help='Path to directory that contains the tests') +parser.add_argument('runner_tool_path', help='Path to runner tool. Available runners: 1) migration tool, specify path to jar') + + +def main(): + args = parser.parse_args() + + testpath = Path(args.tests_dir) + runnerpath = Path(args.runner_tool_path) + + # Verify that CTS dir exists + if not testpath.is_dir(): + print(f"ERROR: Path '{testpath}' must be a directory") + exit(1) + + # Verify runner tool exists + path = Path.cwd() / runnerpath + if not path.is_file() or path.suffix != JAR_EXTENSION: + print(f"ERROR: Path '{runnerpath}' must point to a runner, e.g. migration tool") + exit(1) + + try: + stats = run_tests(testpath, runnerpath) + except (InvalidFileFormatException, InvalidFileStructureException) as e: + print("ERROR:\n", e.message) + exit(1) + + print("\n=====") + print(f"TESTS {len(stats.failed) + len(stats.passed)} | SUCCESS {len(stats.passed)} | FAILED {len(stats.failed)}\n") + + if len(stats.failed) > 0: + print("FAIL!") + exit(1) + else: + print("SUCCESS!") + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/migrator/test/staticTS/formatChecker/setup.sh b/migrator/test/staticTS/formatChecker/setup.sh new file mode 100755 index 0000000000000000000000000000000000000000..7e87c4cbe010677c852697c5f7c9d0a4f091dcf7 --- /dev/null +++ b/migrator/test/staticTS/formatChecker/setup.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +# +# Copyright (c) 2022-2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +SCRIPT=`readlink -e $BASH_SOURCE` +SCRIPT_DIR=`dirname $SCRIPT` + +# This script installs all dependencies for formatChecker +# by creating a virtualenv + +# Checking Python version +function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; } + +MIN_PYTHON_VERSION="3.8.0" +CURRENT_PYTHON_VERSION=`python3 -c "import platform; print(platform. python_version())"` + +if [ $(version $CURRENT_PYTHON_VERSION) -lt $(version $MIN_PYTHON_VERSION) ]; then + echo "Python version must be greater than $MIN_PYTHON_VERSION" + exit +fi + +# Cheking venv existance +sudo apt install python3-venv -yyy + +pushd $SCRIPT_DIR/../formatChecker + +python3 -m venv .venv +source .venv/bin/activate + +python3 -m ensurepip --upgrade +python3 -m pip install -r requirements.txt + +popd \ No newline at end of file diff --git a/migrator/test/staticTS/formatChecker/utils/constants.py b/migrator/test/staticTS/formatChecker/utils/constants.py new file mode 100644 index 0000000000000000000000000000000000000000..7d52e295a935e13f3d43ce87ace42fcec344019d --- /dev/null +++ b/migrator/test/staticTS/formatChecker/utils/constants.py @@ -0,0 +1,25 @@ +import re + +# Meta +META_START_STRING = "/*---" +META_START_PATTERN = re.compile("\/\*---") +META_END_STRING = "---*/" +META_END_PATTERN = re.compile("---\*\/") + +# Extensions +YAML_EXTENSIONS = [".yaml", ".yml"] +TEMPLATE_EXTENSION = ".sts" +OUT_EXTENSION = ".sts" +JAR_EXTENSION = ".jar" + +# Prefixes +LIST_PREFIX = "list." +NEGATIVE_PREFIX = "n." +SKIP_PREFIX = "tbd." + +# Jinja +VARIABLE_START_STRING = "{{." + +# Spec +SPEC_SECTION_TITLE_FIELD_NAME = "name" +SPEC_SUBSECTIONS_FIELD_NAME = "children" \ No newline at end of file diff --git a/migrator/test/staticTS/formatChecker/utils/exceptions.py b/migrator/test/staticTS/formatChecker/utils/exceptions.py new file mode 100644 index 0000000000000000000000000000000000000000..a15a25f7d3eadc393b7634376046e3511df0f359 --- /dev/null +++ b/migrator/test/staticTS/formatChecker/utils/exceptions.py @@ -0,0 +1,18 @@ +class InvalidFileFormatException(Exception): + def __init__(self, filepath: str, message: str) -> None: + super().__init__(f"{filepath}: {message}") + self.message = f"{filepath}: {message}" + + +class InvalidFileStructureException(Exception): + def __init__(self, filepath: str, message: str) -> None: + msg = f"{filepath}: {message}" + super().__init__(msg) + self.message = msg + + +class UnknownTemplateException(Exception): + def __init__(self, filepath: str, exception: Exception) -> None: + super().__init__(f"{filepath}: {str(exception)}") + self.filepath = filepath + self.exception = exception \ No newline at end of file diff --git a/migrator/test/staticTS/formatChecker/utils/file_structure.py b/migrator/test/staticTS/formatChecker/utils/file_structure.py new file mode 100644 index 0000000000000000000000000000000000000000..5c7198f4922bb1b9e6751a97da1c30e0b475b315 --- /dev/null +++ b/migrator/test/staticTS/formatChecker/utils/file_structure.py @@ -0,0 +1,147 @@ +# This file defines the CTS file structure +# The entrypoint is the function 'walk_test_subdirs' + +from dataclasses import dataclass +from pathlib import Path +from typing import Iterable, Tuple, List, Union +import os +import re +import os.path as ospath + +from utils.exceptions import InvalidFileStructureException + + +@dataclass() +class TestDirectory: + id: int + path: Path + name: str + + parent: Union['TestDirectory', None] + subdirs: 'List[TestDirectory]' + + + def __init__(self, path: Path, id: int = 0, name: str = "", parent: Union['TestDirectory', None] = None, subdirs: 'List[TestDirectory]' = []) -> None: + self.path = path + + if id == 0 or name == "": + self.id, self.name = parse_section_dir_name(path) + else: + self.id = id + self.name = name + + self.parent = parent + self.subdirs = list(subdirs) + + + def full_index(self) -> List[int]: + cur = self + result = [] + while (cur is not None): + result.append(cur.id) + cur = cur.parent + return list(reversed(result)) + + def iter_files(self, allowed_ext: List[str] = []) -> Iterable[Path]: + for filename in os.listdir(str(self.path)): + filepath: Path = self.path / filename + if len(allowed_ext) > 0 and filepath.suffix not in allowed_ext: + continue + yield filepath + + def add_subdir(self, td: 'TestDirectory'): + td.parent = self + self.subdirs.append(td) + + def find_subdir_by_name(self, name: str) -> Union['TestDirectory', None]: + # TODO: decrease complexity + for sd in self.subdirs: + if sd.name == name: + return sd + return None + + def find_subdir_by_id(self, id: int) -> Union['TestDirectory', None]: + # TODO: decrease complexity + for sd in self.subdirs: + if sd.id == id: + return sd + return None + + def is_empty(self): + return len(os.listdir(str(self.path))) == 0 + + +def walk_test_subdirs(path: Path, parent=None) -> Iterable[TestDirectory]: + """ + Walks the file system from the CTS root, yielding TestDirectories, in correct order: + For example, if only directories 1, 1/1, 1/1/1, 1/1/2, 1/2 exist, they will be yielded in that order. + """ + subdirs = [] + for name in os.listdir(str(path)): + if (path / name).is_dir(): + subdirs.append(TestDirectory(parent=parent, path=(path / name))) + subdirs = sorted(subdirs, key=lambda dir: dir.id) + + for subdir in subdirs: + yield subdir + # walk recursively + for subsubdir in walk_test_subdirs(subdir.path, subdir): + yield subsubdir + + +def build_directory_tree(td: TestDirectory): + subdirs = [] + for name in os.listdir(str(td.path)): + if (td.path / name).is_dir(): + subdirs.append(TestDirectory(parent=td, path=(td.path / name))) + subdirs = sorted(subdirs, key=lambda dir: dir.id) + + for sd in subdirs: + td.add_subdir(sd) + build_directory_tree(sd) + + + +def print_tree(td: TestDirectory): + for sd in td.subdirs: + + left_space = " " * 2 * len(sd.full_index()) + section_index = str(sd.id) + section_name = sd.name.replace("_", " ").title() + right_space = 90 - len(left_space) - len(section_index) - len(section_name) + + print(left_space, section_index, section_name, "." * right_space, "\n") + print_tree(sd) + + +def normalize_section_name(name: str) -> str: + parts = name.split(".") + if len(parts) != 2: + raise InvalidFileStructureException(filepath=name, message="Invalid section name format") + first, second = parts + if not first.isdigit(): + raise InvalidFileStructureException(filepath=name, message="Invalid section name format") + second = second.replace(" ", "_").replace("-", "_").lower() + return first + "." + "".join([c for c in second if c.isalpha() or c == "_"]) + + +def denormalize_section_name(name: str) -> str: + return name.replace("_", " ").title() + + +def parse_section_dir_name(path: Path) -> Tuple[int, str]: + parts = path.name.split(".") + if len(parts) == 1: + if not path.name.isdigit(): + raise InvalidFileStructureException(filepath=str(path), message="Invalid directory name format") + return int(path.name), "" + if len(parts) != 2: + raise InvalidFileStructureException(filepath=str(path), message="Invalid directory name format") + first, second = parts + if not first.isdigit(): + raise InvalidFileStructureException(filepath=str(path), message="Invalid directory name format") + if not re.match("^[a-z_]*$", second): + raise InvalidFileStructureException(filepath=str(path), message="Section name must be lowercase and contain spaces") + return int(first), second + + diff --git a/migrator/test/staticTS/formatChecker/utils/fsutils.py b/migrator/test/staticTS/formatChecker/utils/fsutils.py new file mode 100644 index 0000000000000000000000000000000000000000..aee0aa7ccf345fa261c806d61f50b299491ad7ee --- /dev/null +++ b/migrator/test/staticTS/formatChecker/utils/fsutils.py @@ -0,0 +1,29 @@ +# Util file system functions + +import os +import os.path as ospath +from typing import List + + +def iterdir(dirpath: str): + return((name, ospath.join(dirpath, name)) for name in os.listdir(dirpath)) + + +def iter_files(dirpath: str, allowed_ext: List[str]): + for name, path in iterdir(dirpath): + if not ospath.isfile(path): + continue + _, ext = ospath.splitext(path) + if ext in allowed_ext: + yield name, path + + +def write_file(path, text): + with open(path, "w+", encoding="utf8") as f: + f.write(text) + +def read_file(path) -> str: + text = "" + with open(path, "r", encoding='utf8') as f: + text = f.read() + return text \ No newline at end of file diff --git a/migrator/test/staticTS/formatChecker/utils/metainformation.py b/migrator/test/staticTS/formatChecker/utils/metainformation.py new file mode 100644 index 0000000000000000000000000000000000000000..c186e376e9a3f9b07bfa47c9e5ebf2c601237898 --- /dev/null +++ b/migrator/test/staticTS/formatChecker/utils/metainformation.py @@ -0,0 +1,69 @@ +# This file defines the CTS test metadata format +# The entrypoint is the 'find_all_metas' function + +from typing import Tuple, List +import yaml +import re + +from utils.constants import META_END_PATTERN, META_END_STRING, META_START_PATTERN, META_START_STRING + + +ParsedMeta = dict +MetaInText = Tuple[int, int, ParsedMeta] + + +class InvalidMetaException(Exception): + def __init__(self, msg: str) -> None: + super().__init__() + self.message = msg + + +def find_all_metas(text: str) -> List[MetaInText]: + """ + Given a text of the whole test, this function: + 1) Find all metas in this text + 2) Parses each meta and verifies it's correctness + Returns a list of tuples (start: int, end: int, meta: ParsedMeta), + where 'start' and 'end' are indices in 'text' such that text[start:end] == "/*---" + strMeta + "---*/" + and 'meta' is the parsed meta + + Raised: InvalidMetaException + """ + result = [] + + start_indices = [m.start() for m in re.finditer(META_START_PATTERN, text)] + end_indices = [m.end() for m in re.finditer(META_END_PATTERN, text)] + + + if len(start_indices) != len(end_indices) or len(start_indices) == 0: + raise InvalidMetaException("Invalid meta or meta doesn't exist") + + meta_bounds = list(zip(start_indices, end_indices)) + + # verify meta bounds + for i in range(1, len(meta_bounds)): + prev_start, prev_end = meta_bounds[i - 1] + start, end = meta_bounds[i] + if not (prev_start < prev_end < start < end): + raise InvalidMetaException("Invalid meta") + + for start, end in meta_bounds: + meta = __parse_meta(text[start:end]) + result.append((start, end, meta)) + + return result + + +def __parse_meta(meta: str) -> dict: + """ + Given a meta, a string that starts with '/*---', ends with '---*/' and contains a valid YAML in between, + this function parses that meta and validating it. + """ + assert len(meta) > len(META_START_STRING) + len(META_END_STRING) + assert meta.startswith(META_START_STRING) and meta.endswith(META_END_STRING) + + yaml_string = meta[len(META_START_STRING):-len(META_END_STRING)] + try: + return yaml.load(yaml_string, Loader=yaml.Loader) + except Exception as e: + raise InvalidMetaException(str(e)) diff --git a/migrator/test/staticTS/formatChecker/utils/spec.py b/migrator/test/staticTS/formatChecker/utils/spec.py new file mode 100644 index 0000000000000000000000000000000000000000..7bfbf3ecf4be6b4041fdc07e6bb3a1293462d5af --- /dev/null +++ b/migrator/test/staticTS/formatChecker/utils/spec.py @@ -0,0 +1,46 @@ +import yaml +from utils.file_structure import TestDirectory, normalize_section_name +from utils.exceptions import InvalidFileFormatException +from utils.constants import SPEC_SECTION_TITLE_FIELD_NAME, SPEC_SUBSECTIONS_FIELD_NAME +from utils.fsutils import read_file +from pathlib import Path + +Spec = dict + +def build_spec_tree(specpath: str, root: TestDirectory): + spec = __parse_spec(specpath) + walk_spec(spec, root, specpath=specpath) + + +def walk_spec(spec: list, parent: TestDirectory, specpath: str): + if type(spec) != list: + raise InvalidFileFormatException(message="Spec sections list must be a YAML list", filepath=specpath) + + for s in spec: + if type(s) != dict: + raise InvalidFileFormatException(message="Spec section must be a YAML dict", filepath=specpath) + + s = dict(s) + if not SPEC_SECTION_TITLE_FIELD_NAME in s: + raise InvalidFileFormatException(message=f"Spec section must contain the '{SPEC_SECTION_TITLE_FIELD_NAME}' field", filepath=specpath) + + # Normalize name + name = normalize_section_name(str(s[SPEC_SECTION_TITLE_FIELD_NAME])) + + td = TestDirectory(path=(parent.path / Path(name)), parent=parent) + parent.add_subdir(td) + + # Has subsections? + if SPEC_SUBSECTIONS_FIELD_NAME in s: + walk_spec(s[SPEC_SUBSECTIONS_FIELD_NAME], parent=td, specpath=specpath) + + +def __parse_spec(path: str) -> Spec: + text = read_file(path) + + try: + spec = yaml.load(text, Loader=yaml.FullLoader) + except Exception as e: + raise InvalidFileFormatException(message=f"Could not load YAML: {str(e)}", filepath=path) + + return spec \ No newline at end of file diff --git a/migrator/test/staticTS/formatChecker/utils/test_case.py b/migrator/test/staticTS/formatChecker/utils/test_case.py new file mode 100644 index 0000000000000000000000000000000000000000..c2e02b19a87d363330e652327fe2399363f8efe9 --- /dev/null +++ b/migrator/test/staticTS/formatChecker/utils/test_case.py @@ -0,0 +1,27 @@ + +from pathlib import Path +from re import template +from typing import Tuple + +from utils.constants import NEGATIVE_PREFIX, SKIP_PREFIX + + +def is_negative(path: Path) -> bool: + return path.name.startswith(NEGATIVE_PREFIX) + + +def should_be_skipped(path: Path) -> bool: + return path.name.startswith(SKIP_PREFIX) + + +def strip_template(path: Path) -> Tuple[str, int]: + stem = path.stem + i = path.stem.rfind("_") + if i == -1: + return stem, 0 + template_name = stem[:i] + test_index = stem[i + 1:] + if not test_index.isdigit(): + return stem, 0 + else: + return template_name, int(test_index) \ No newline at end of file diff --git a/migrator/test/staticTS/formatChecker/utils/test_parameters.py b/migrator/test/staticTS/formatChecker/utils/test_parameters.py new file mode 100644 index 0000000000000000000000000000000000000000..0d2d01ddff0a0166e8b81f17a59ebd3025f6011b --- /dev/null +++ b/migrator/test/staticTS/formatChecker/utils/test_parameters.py @@ -0,0 +1,44 @@ +# This file provides functions thar are responsible for loading test parameters +# that are used in templates (yaml lists). + +import yaml +import os.path as ospath + +from utils.exceptions import InvalidFileFormatException +from utils.fsutils import iter_files, read_file +from utils.constants import YAML_EXTENSIONS, LIST_PREFIX + + +Params = dict + + +def load_params(dirpath: str) -> Params: + """ + Loads all parameters for a directory + """ + result = dict() + + for filename, filepath in iter_files(dirpath, allowed_ext=YAML_EXTENSIONS): + name_without_ext, _ = ospath.splitext(filename) + if not name_without_ext.startswith(LIST_PREFIX): + raise InvalidFileFormatException(message="Lists of parameters must start with 'list.'", filepath=filepath) + listname = name_without_ext[len(LIST_PREFIX):] + result[listname] = __parse_yaml_list(filepath) + return result + + +def __parse_yaml_list(path: str) -> Params: + """ + Parses a single YAML list of parameters + Verifies that it is a list + """ + text = read_file(path) + + try: + params = yaml.load(text, Loader=yaml.FullLoader) + except Exception as e: + raise InvalidFileFormatException(message=f"Could not load YAML: {str(e)}", filepath=path) + + if type(params) != list: + raise InvalidFileFormatException(message="Parameters list must be YAML array", filepath=path) + return params \ No newline at end of file