From b09f257c6f4e1748fee14e23d0e73e0f5ec8dfc2 Mon Sep 17 00:00:00 2001 From: zyrouge Date: Fri, 3 Nov 2023 19:48:24 +0530 Subject: [PATCH] refactor: tests --- .../beize_compiler/lib/compiler/compiler.dart | 2 +- .../lib/disassembler/disassembler.dart | 3 +- .../addition_assignment_1.beize | 3 - .../addition_assignment_1_test.dart | 45 ---- .../addition_assignment_1_test.dart | 30 --- .../addition_operator/addition_1_test.dart | 30 +-- .../tests/analysis_options.yaml | 5 + .../assignment_1_test.dart | 28 +-- .../tests/await_operator/await_1_test.dart | 52 +---- .../bitwise_and_assignment_1_test.dart | 33 +-- .../bitwise_and_assignment_2_test.dart | 33 +-- .../bitwise_and_1_test.dart | 30 +-- .../bitwise_and_2_test.dart | 30 +-- .../bitwise_not_1_test.dart | 28 +-- .../bitwise_or_assignment_1_test.dart | 33 +-- .../bitwise_or_assignment_2_test.dart | 33 +-- .../bitwise_or_1_test.dart | 30 +-- .../bitwise_or_2_test.dart | 30 +-- .../bitwise_xor_assignment_1_test.dart | 33 +-- .../bitwise_xor_assignment_2_test.dart | 33 +-- .../bitwise_xor_1_test.dart | 30 +-- .../bitwise_xor_2_test.dart | 30 +-- .../tests/block_statement/block_1_test.dart | 44 +--- .../{boolean_from_1.beize => boolean_1.beize} | 0 .../tests/boolean_native/boolean_1_test.dart | 17 ++ .../{boolean_from_2.beize => boolean_2.beize} | 0 .../tests/boolean_native/boolean_2_test.dart | 17 ++ .../boolean_native/boolean_from_1_test.dart | 43 ---- .../boolean_native/boolean_from_2_test.dart | 43 ---- .../tests/boolean_value/boolean_1_test.dart | 26 +-- .../tests/boolean_value/boolean_2_test.dart | 26 +-- .../tests/boolean_value/boolean_3_test.dart | 27 +-- .../tests/break_statement/break_1_test.dart | 30 +-- .../tests/break_statement/break_2_test.dart | 46 +--- .../tests/call_operator/call_1_test.dart | 19 +- .../computed_member_access_1_test.dart | 34 +-- .../continue_statement/continue_1_test.dart | 65 +----- .../continue_statement/continue_2_test.dart | 66 +----- .../declaration_1_test.dart | 24 +- .../division_assignment_1_test.dart | 33 +-- .../division_operator/division_1_test.dart | 30 +-- .../division_operator/division_2_test.dart | 30 +-- .../division_operator/division_3_test.dart | 33 +-- .../equality_operator/equality_1_test.dart | 40 +--- .../equality_operator/equality_2_test.dart | 40 +--- .../exponent_assignment_1_test.dart | 33 +-- .../exponent_operator/exponent_1_test.dart | 30 +-- .../floor_division_assignment_1_test.dart | 34 +-- .../floor_division_1_test.dart | 28 +-- .../tests/for_statement/for_1_test.dart | 52 +---- .../tests/for_statement/for_2_test.dart | 34 +-- .../tests/for_statement/for_3_test.dart | 52 +---- .../tests/function_value/function_1_test.dart | 39 +--- .../tests/function_value/function_2_test.dart | 40 +--- .../tests/function_value/function_3_test.dart | 31 +-- .../tests/function_value/function_call_1.dart | 17 ++ .../function_value/function_call_1_test.dart | 53 ----- .../tests/function_value/function_call_2.dart | 17 ++ .../function_value/function_call_2_test.dart | 70 ------ packages/beize_compiler/tests/gen_test.dart | 40 +--- .../greater_than_1_test.dart | 30 +-- .../greater_than_2_test.dart | 30 +-- .../greater_than_3_test.dart | 30 +-- .../greater_than_or_equal_1_test.dart | 29 +-- .../greater_than_or_equal_2_test.dart | 29 +-- .../greater_than_or_equal_3_test.dart | 29 +-- .../grouping_operator/grouping_1_test.dart | 33 +-- .../tests/if-else_statement/if-else_1.beize | 5 + .../if-else_statement/if-else_1_test.dart | 17 ++ .../tests/if-else_statement/if-else_2.beize | 5 + .../if-else_statement/if-else_2_test.dart | 17 ++ .../if-elseif-else_1.beize | 7 + .../if-elseif-else_1_test.dart | 17 ++ .../tests/if_statement/if_1_test.dart | 28 +-- .../tests/if_statement/if_2_test.dart | 28 +-- .../tests/if_statement/if_else_1_test.dart | 37 +--- .../tests/if_statement/if_else_2_test.dart | 37 +--- .../if_statement/if_elseif_else_1_test.dart | 53 +---- .../if_statement/if_elseif_else_2_test.dart | 55 +---- .../if_statement/if_elseif_else_3_test.dart | 55 +---- .../tests/import_statement/import_1.beize | 3 - .../tests/import_statement/import_1_test.dart | 53 ----- .../tests/import_statement/import_dummy.beize | 1 - .../inequality_1_test.dart | 41 +--- .../inequality_2_test.dart | 41 +--- .../lesser_than_1_test.dart | 30 +-- .../lesser_than_2_test.dart | 30 +-- .../lesser_than_3_test.dart | 30 +-- .../lesser_than_or_equal_1_test.dart | 29 +-- .../lesser_than_or_equal_2_test.dart | 29 +-- .../lesser_than_or_equal_3_test.dart | 29 +-- .../tests/list_value/list_1_test.dart | 28 +-- .../tests/list_value/list_2_test.dart | 27 +-- .../tests/list_value/list_clear_1_test.dart | 45 +--- .../tests/list_value/list_clone_1_test.dart | 47 +--- .../list_value/list_contains_1_test.dart | 40 +--- .../tests/list_value/list_filter_1_test.dart | 60 +---- .../list_value/list_findIndex_1_test.dart | 49 +---- .../list_value/list_findLastIndex_1_test.dart | 43 +--- .../tests/list_value/list_find_1_test.dart | 44 +--- .../list_value/list_flatDeep_1_test.dart | 53 +---- .../tests/list_value/list_flat_1_test.dart | 53 +---- .../tests/list_value/list_forEach_1_test.dart | 66 +----- .../tests/list_value/list_indexOf_1_test.dart | 40 +--- .../tests/list_value/list_isEmpty_1_test.dart | 34 +-- .../list_value/list_isNotEmpty_1_test.dart | 36 +-- .../tests/list_value/list_join_1_test.dart | 40 +--- .../list_value/list_lastIndexOf_1_test.dart | 42 +--- .../tests/list_value/list_length_1_test.dart | 36 +-- .../tests/list_value/list_map_1_test.dart | 59 +---- .../tests/list_value/list_pop_1_test.dart | 45 +--- .../tests/list_value/list_pushAll_1_test.dart | 47 +--- .../tests/list_value/list_push_1_test.dart | 39 +--- .../tests/list_value/list_remove_1_test.dart | 47 +--- .../list_value/list_reversed_1_test.dart | 47 +--- .../tests/list_value/list_sort_1_test.dart | 59 +---- .../tests/list_value/list_sublist_1_test.dart | 53 +---- .../tests/list_value/list_unique_1_test.dart | 49 +---- .../logical_and_assignment_1_test.dart | 33 +-- .../logical_and_assignment_2_test.dart | 33 +-- .../logical_and_1_test.dart | 30 +-- .../logical_and_2_test.dart | 30 +-- .../logical_and_3_test.dart | 30 +-- .../logical_not_1_test.dart | 27 +-- .../logical_not_2_test.dart | 27 +-- .../logical_not_3_test.dart | 28 +-- .../logical_not_4_test.dart | 28 +-- .../logical_or_assignment_1_test.dart | 35 +-- .../logical_or_assignment_2_test.dart | 35 +-- .../logical_or_1_test.dart | 32 +-- .../logical_or_2_test.dart | 32 +-- .../logical_or_3_test.dart | 32 +-- .../logical_or_4_test.dart | 32 +-- .../tests/match_statement/match_1_test.dart | 47 +--- .../tests/match_statement/match_2_test.dart | 47 +--- .../tests/match_statement/match_3_test.dart | 26 +-- .../tests/match_statement/match_4_test.dart | 17 +- .../member_access_1_test.dart | 32 +-- .../member_access_2_test.dart | 33 +-- .../multiplication_assignment_1_test.dart | 34 +-- .../multiplication_1_test.dart | 28 +-- .../multiplication_2_test.dart | 31 +-- .../tests/null_value/null_1_test.dart | 27 +-- .../nullable_access_1_test.dart | 32 +-- .../nullable_access_2_test.dart | 30 +-- .../nullable_assignment_1_test.dart | 46 +--- .../nullable_assignment_2_test.dart | 47 +--- .../nullable_or_1_test.dart | 33 +-- .../nullable_or_2_test.dart | 34 +-- .../tests/number_value/number_1.beize | 2 + .../tests/number_value/number_1_test.dart | 17 ++ .../tests/number_value/number_2.beize | 2 + .../tests/number_value/number_2_test.dart | 17 ++ .../tests/number_value/number_abs_1_test.dart | 35 +-- .../number_value/number_ceil_1_test.dart | 34 +-- .../number_value/number_isFinite_1_test.dart | 34 +-- .../number_value/number_isFinite_2_test.dart | 37 +--- .../number_isInfinite_1_test.dart | 34 +-- .../number_isInfinite_2_test.dart | 37 +--- .../number_value/number_isNaN_1_test.dart | 34 +-- .../number_value/number_isNaN_2_test.dart | 37 +--- .../number_isNegative_1_test.dart | 35 +-- .../number_value/number_round_1_test.dart | 34 +-- .../number_value/number_sign_1_test.dart | 35 +-- .../number_value/number_sign_2_test.dart | 34 +-- .../number_toPrecisionString_1_test.dart | 34 +-- .../number_toRadixString_1_test.dart | 36 +-- .../number_value/number_truncate_1_test.dart | 34 +-- .../tests/object_value/object_1_test.dart | 28 +-- .../tests/object_value/object_2_test.dart | 27 +-- .../remainder_assignment_1_test.dart | 33 +-- .../remainder_operator/remainder_1_test.dart | 30 +-- .../tests/return_statement/return_1_test.dart | 32 +-- .../tests/return_statement/return_2_test.dart | 34 +-- .../tests/string_native/string_1.beize | 2 + .../tests/string_native/string_1_test.dart | 17 ++ .../string_fromCodeUnit_1_test.dart | 33 +-- .../string_fromCodeUnits_1_test.dart | 43 +--- .../tests/string_native/string_from_1.beize | 2 - .../string_native/string_from_1_test.dart | 46 ---- .../tests/string_value/string_1_test.dart | 24 +- .../tests/string_value/string_2_test.dart | 28 +-- .../string_codeUnitAt_1_test.dart | 36 +-- .../string_value/string_compareTo_1_test.dart | 41 +--- .../string_value/string_contains_1_test.dart | 36 +-- .../string_value/string_endsWith_1_test.dart | 36 +-- .../string_value/string_format_1_test.dart | 37 +--- .../string_value/string_indexOf_1_test.dart | 36 +-- .../string_value/string_isEmpty_1_test.dart | 34 +-- .../string_isNotEmpty_1_test.dart | 34 +-- .../string_value/string_length_1_test.dart | 34 +-- .../string_value/string_padLeft_1_test.dart | 38 +--- .../string_value/string_padRight_1_test.dart | 38 +--- .../string_replaceAllMapped_1_test.dart | 45 +--- .../string_replaceAll_1_test.dart | 38 +--- .../string_replaceFirstMapped_1_test.dart | 45 +--- .../string_replaceFirst_1_test.dart | 38 +--- .../string_value/string_split_1_test.dart | 46 +--- .../string_startsWith_1_test.dart | 36 +-- .../string_value/string_substring_1_test.dart | 38 +--- .../string_toCodeUnits_1_test.dart | 38 +--- .../string_toLowerCase_1_test.dart | 31 +-- .../string_toUpperCase_1_test.dart | 31 +-- .../string_value/string_trimLeft_1_test.dart | 34 +-- .../string_value/string_trimRight_1_test.dart | 34 +-- .../string_value/string_trim_1_test.dart | 34 +-- .../subtraction_assignment_1_test.dart | 33 +-- .../subtraction_1_test.dart | 30 +-- .../ternary_operator/ternary_1_test.dart | 36 +-- .../ternary_operator/ternary_2_test.dart | 36 +-- .../tests/this_operator/this_1_test.dart | 44 +--- .../try-catch_1.beize} | 0 .../try-catch_statement/try-catch_1_test.dart | 17 ++ .../try-catch_2.beize} | 0 .../try-catch_statement/try-catch_2_test.dart | 17 ++ .../try_catch_statement/try_catch_1_test.dart | 58 ----- .../try_catch_statement/try_catch_2_test.dart | 61 ----- .../unary_negation_1_test.dart | 26 +-- .../unary_negation_2_test.dart | 27 +-- .../unary_plus_1_test.dart | 27 +-- .../unary_plus_2_test.dart | 28 +-- .../unawaited_value/unawaited_1_test.dart | 43 +--- .../unawaited_value/unawaited_2_test.dart | 34 +-- packages/beize_compiler/tests/utils.dart | 208 ------------------ .../tests/when_statement/when_1_test.dart | 45 +--- .../tests/when_statement/when_2_test.dart | 46 +--- .../tests/when_statement/when_3_test.dart | 25 +-- .../tests/while_statement/while_1_test.dart | 48 +--- .../tests/while_statement/while_2_test.dart | 28 +-- .../tests/while_statement/while_3_test.dart | 30 +-- 230 files changed, 1020 insertions(+), 6786 deletions(-) delete mode 100644 packages/beize_compiler/tests/_addition_assignment_operator/addition_assignment_1.beize delete mode 100644 packages/beize_compiler/tests/_addition_assignment_operator/addition_assignment_1_test.dart create mode 100644 packages/beize_compiler/tests/analysis_options.yaml rename packages/beize_compiler/tests/boolean_native/{boolean_from_1.beize => boolean_1.beize} (100%) create mode 100644 packages/beize_compiler/tests/boolean_native/boolean_1_test.dart rename packages/beize_compiler/tests/boolean_native/{boolean_from_2.beize => boolean_2.beize} (100%) create mode 100644 packages/beize_compiler/tests/boolean_native/boolean_2_test.dart delete mode 100644 packages/beize_compiler/tests/boolean_native/boolean_from_1_test.dart delete mode 100644 packages/beize_compiler/tests/boolean_native/boolean_from_2_test.dart create mode 100644 packages/beize_compiler/tests/function_value/function_call_1.dart delete mode 100644 packages/beize_compiler/tests/function_value/function_call_1_test.dart create mode 100644 packages/beize_compiler/tests/function_value/function_call_2.dart delete mode 100644 packages/beize_compiler/tests/function_value/function_call_2_test.dart create mode 100644 packages/beize_compiler/tests/if-else_statement/if-else_1.beize create mode 100644 packages/beize_compiler/tests/if-else_statement/if-else_1_test.dart create mode 100644 packages/beize_compiler/tests/if-else_statement/if-else_2.beize create mode 100644 packages/beize_compiler/tests/if-else_statement/if-else_2_test.dart create mode 100644 packages/beize_compiler/tests/if-elseif-else_statement/if-elseif-else_1.beize create mode 100644 packages/beize_compiler/tests/if-elseif-else_statement/if-elseif-else_1_test.dart delete mode 100644 packages/beize_compiler/tests/import_statement/import_1.beize delete mode 100644 packages/beize_compiler/tests/import_statement/import_1_test.dart delete mode 100644 packages/beize_compiler/tests/import_statement/import_dummy.beize create mode 100644 packages/beize_compiler/tests/number_value/number_1.beize create mode 100644 packages/beize_compiler/tests/number_value/number_1_test.dart create mode 100644 packages/beize_compiler/tests/number_value/number_2.beize create mode 100644 packages/beize_compiler/tests/number_value/number_2_test.dart create mode 100644 packages/beize_compiler/tests/string_native/string_1.beize create mode 100644 packages/beize_compiler/tests/string_native/string_1_test.dart delete mode 100644 packages/beize_compiler/tests/string_native/string_from_1.beize delete mode 100644 packages/beize_compiler/tests/string_native/string_from_1_test.dart rename packages/beize_compiler/tests/{try_catch_statement/try_catch_1.beize => try-catch_statement/try-catch_1.beize} (100%) create mode 100644 packages/beize_compiler/tests/try-catch_statement/try-catch_1_test.dart rename packages/beize_compiler/tests/{try_catch_statement/try_catch_2.beize => try-catch_statement/try-catch_2.beize} (100%) create mode 100644 packages/beize_compiler/tests/try-catch_statement/try-catch_2_test.dart delete mode 100644 packages/beize_compiler/tests/try_catch_statement/try_catch_1_test.dart delete mode 100644 packages/beize_compiler/tests/try_catch_statement/try_catch_2_test.dart diff --git a/packages/beize_compiler/lib/compiler/compiler.dart b/packages/beize_compiler/lib/compiler/compiler.dart index 65ebe17..fee09db 100644 --- a/packages/beize_compiler/lib/compiler/compiler.dart +++ b/packages/beize_compiler/lib/compiler/compiler.dart @@ -57,7 +57,7 @@ class BeizeCompiler { currentFunction = BeizeFunctionConstant( isAsync: isAsync, arguments: [], - chunk: BeizeChunk.empty(moduleIndex), + chunk: BeizeChunk.empty(), ); scopeDepth = 0; loops = []; diff --git a/packages/beize_compiler/lib/disassembler/disassembler.dart b/packages/beize_compiler/lib/disassembler/disassembler.dart index 9e59d8f..708756e 100644 --- a/packages/beize_compiler/lib/disassembler/disassembler.dart +++ b/packages/beize_compiler/lib/disassembler/disassembler.dart @@ -131,7 +131,8 @@ class BeizeDisassembler { final BeizeFunctionConstant function = program.constantAt(functionIndex) as BeizeFunctionConstant; output.write( - '> $moduleName (constant [$nameIndex]) at constant [$functionIndex] ${nameIndex == 0 ? "(entrypoint)" : ""}'); + '> $moduleName (constant [$nameIndex]) at constant [$functionIndex] ${nameIndex == 0 ? "(entrypoint)" : ""}', + ); final BeizeDisassembler disassembler = BeizeDisassembler(program, function.chunk, output); disassembler.dissassemble(); diff --git a/packages/beize_compiler/tests/_addition_assignment_operator/addition_assignment_1.beize b/packages/beize_compiler/tests/_addition_assignment_operator/addition_assignment_1.beize deleted file mode 100644 index 63216d2..0000000 --- a/packages/beize_compiler/tests/_addition_assignment_operator/addition_assignment_1.beize +++ /dev/null @@ -1,3 +0,0 @@ -result := 1; -result += 2; -out("" + result); diff --git a/packages/beize_compiler/tests/_addition_assignment_operator/addition_assignment_1_test.dart b/packages/beize_compiler/tests/_addition_assignment_operator/addition_assignment_1_test.dart deleted file mode 100644 index df42b1f..0000000 --- a/packages/beize_compiler/tests/_addition_assignment_operator/addition_assignment_1_test.dart +++ /dev/null @@ -1,45 +0,0 @@ -import 'package:beize_compiler/beize_compiler.dart'; -import 'package:test/test.dart'; -import '../utils.dart'; - -Future main() async { - const String title = '[Operator] Addition Assignment (1)'; - final BeizeProgramConstant program = await compileTestScript( - 'addition_assignment_operator', 'addition_assignment_1.beize'); - - test('$title - Bytecode', () async { - final BeizeTestProgram expectedProgram = BeizeTestProgram(); - final BeizeTestChunk expectedModule1 = - expectedProgram.addModule(0, 0, 'addition_assignment_1.beize'); - expectedModule1.addOpCode(BeizeOpCodes.opConstant); - expectedModule1.addConstant(1, 1.0); - expectedModule1.addOpCode(BeizeOpCodes.opDeclare); - expectedModule1.addConstant(0, 'result'); - expectedModule1.addOpCode(BeizeOpCodes.opPop); - expectedModule1.addOpCode(BeizeOpCodes.opLookup); - expectedModule1.addConstant(0, 'result'); - expectedModule1.addOpCode(BeizeOpCodes.opConstant); - expectedModule1.addConstant(2, 2.0); - expectedModule1.addOpCode(BeizeOpCodes.opAdd); - expectedModule1.addOpCode(BeizeOpCodes.opAssign); - expectedModule1.addConstant(0, 'result'); - expectedModule1.addOpCode(BeizeOpCodes.opPop); - expectedModule1.addOpCode(BeizeOpCodes.opLookup); - expectedModule1.addConstant(3, 'out'); - expectedModule1.addOpCode(BeizeOpCodes.opConstant); - expectedModule1.addConstant(4, ''); - expectedModule1.addOpCode(BeizeOpCodes.opLookup); - expectedModule1.addConstant(0, 'result'); - expectedModule1.addOpCode(BeizeOpCodes.opAdd); - expectedModule1.addOpCode(BeizeOpCodes.opCall); - expectedModule1.addCode(1); - expectedModule1.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(program), tcptc(expectedProgram)); - }); - - test('$title - Channel', () async { - final List expected = ['3']; - final List actual = await executeTestScript(program); - expect(actual, orderedEquals(expected)); - }); -} diff --git a/packages/beize_compiler/tests/addition_assignment_operator/addition_assignment_1_test.dart b/packages/beize_compiler/tests/addition_assignment_operator/addition_assignment_1_test.dart index bfb24e8..0c89334 100644 --- a/packages/beize_compiler/tests/addition_assignment_operator/addition_assignment_1_test.dart +++ b/packages/beize_compiler/tests/addition_assignment_operator/addition_assignment_1_test.dart @@ -9,36 +9,6 @@ Future main() async { 'addition_assignment_1.beize', ); - test('$title - Bytecode', () async { - final BeizeTestProgram expectedProgram = BeizeTestProgram(); - final BeizeTestChunk expectedModule0 = - expectedProgram.addModule(0, 0, 'addition_assignment_1.beize'); - expectedModule0.addOpCode(BeizeOpCodes.opConstant); - expectedModule0.addConstant(3, 1.0); - expectedModule0.addOpCode(BeizeOpCodes.opDeclare); - expectedModule0.addConstant(2, 'result'); - expectedModule0.addOpCode(BeizeOpCodes.opPop); - expectedModule0.addOpCode(BeizeOpCodes.opLookup); - expectedModule0.addConstant(2, 'result'); - expectedModule0.addOpCode(BeizeOpCodes.opConstant); - expectedModule0.addConstant(4, 2.0); - expectedModule0.addOpCode(BeizeOpCodes.opAdd); - expectedModule0.addOpCode(BeizeOpCodes.opAssign); - expectedModule0.addConstant(2, 'result'); - expectedModule0.addOpCode(BeizeOpCodes.opPop); - expectedModule0.addOpCode(BeizeOpCodes.opLookup); - expectedModule0.addConstant(5, 'out'); - expectedModule0.addOpCode(BeizeOpCodes.opConstant); - expectedModule0.addConstant(6, ''); - expectedModule0.addOpCode(BeizeOpCodes.opLookup); - expectedModule0.addConstant(2, 'result'); - expectedModule0.addOpCode(BeizeOpCodes.opAdd); - expectedModule0.addOpCode(BeizeOpCodes.opCall); - expectedModule0.addCode(1); - expectedModule0.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(program), tcptc(expectedProgram)); - }); - test('$title - Channel', () async { final List expected = ['3']; final List actual = await executeTestScript(program); diff --git a/packages/beize_compiler/tests/addition_operator/addition_1_test.dart b/packages/beize_compiler/tests/addition_operator/addition_1_test.dart index 44c2968..c32ef1a 100644 --- a/packages/beize_compiler/tests/addition_operator/addition_1_test.dart +++ b/packages/beize_compiler/tests/addition_operator/addition_1_test.dart @@ -4,32 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Addition (1)'; - final BeizeProgramConstant program = - await compileTestScript('addition_operator', 'addition_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 2.0); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'addition_operator', + 'addition_1.beize', + ); test('$title - Channel', () async { final List expected = ['3']; diff --git a/packages/beize_compiler/tests/analysis_options.yaml b/packages/beize_compiler/tests/analysis_options.yaml new file mode 100644 index 0000000..cb9f82b --- /dev/null +++ b/packages/beize_compiler/tests/analysis_options.yaml @@ -0,0 +1,5 @@ +include: ../analysis_options.yaml + +linter: + rules: + file_names: false diff --git a/packages/beize_compiler/tests/assignment_operator/assignment_1_test.dart b/packages/beize_compiler/tests/assignment_operator/assignment_1_test.dart index c8a3785..9234001 100644 --- a/packages/beize_compiler/tests/assignment_operator/assignment_1_test.dart +++ b/packages/beize_compiler/tests/assignment_operator/assignment_1_test.dart @@ -4,30 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Assignment (1)'; - final BeizeProgramConstant program = - await compileTestScript('assignment_operator', 'assignment_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opNull); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'i'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opAssign); - expectedChunk.addConstant(0, 'i'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'i'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'assignment_operator', + 'assignment_1.beize', + ); test('$title - Channel', () async { final List expected = ['c-0']; diff --git a/packages/beize_compiler/tests/await_operator/await_1_test.dart b/packages/beize_compiler/tests/await_operator/await_1_test.dart index 0318f62..b0c7bce 100644 --- a/packages/beize_compiler/tests/await_operator/await_1_test.dart +++ b/packages/beize_compiler/tests/await_operator/await_1_test.dart @@ -4,54 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Await (1)'; - final BeizeProgramConstant program = - await compileTestScript('await_operator', 'await_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - final BeizeTestProgram expectedChunk_0 = BeizeTestProgram(); - expectedChunk_0.addOpCode(BeizeOpCodes.opConstant); - expectedChunk_0.addConstant(0, 'c-0'); - expectedChunk_0.addOpCode(BeizeOpCodes.opReturn); - expectedChunk.addConstant(1, expectedChunk_0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'fn'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'fn'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(2, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'typeof'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAwait); - expectedChunk.addOpCode(BeizeOpCodes.opAssign); - expectedChunk.addConstant(2, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'await_operator', + 'await_1.beize', + ); test('$title - Channel', () async { final List expected = ['Unawaited', 'c-0']; diff --git a/packages/beize_compiler/tests/bitwise_and_assignment_operator/bitwise_and_assignment_1_test.dart b/packages/beize_compiler/tests/bitwise_and_assignment_operator/bitwise_and_assignment_1_test.dart index 94fa954..af033b3 100644 --- a/packages/beize_compiler/tests/bitwise_and_assignment_operator/bitwise_and_assignment_1_test.dart +++ b/packages/beize_compiler/tests/bitwise_and_assignment_operator/bitwise_and_assignment_1_test.dart @@ -5,36 +5,9 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Bitwise AND Assignment (1)'; final BeizeProgramConstant program = await compileTestScript( - 'bitwise_and_assignment_operator', 'bitwise_and_assignment_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 0.0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opBitwiseAnd); - expectedChunk.addOpCode(BeizeOpCodes.opAssign); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'bitwise_and_assignment_operator', + 'bitwise_and_assignment_1.beize', + ); test('$title - Channel', () async { final List expected = ['0']; diff --git a/packages/beize_compiler/tests/bitwise_and_assignment_operator/bitwise_and_assignment_2_test.dart b/packages/beize_compiler/tests/bitwise_and_assignment_operator/bitwise_and_assignment_2_test.dart index f2ca3ae..8b44c31 100644 --- a/packages/beize_compiler/tests/bitwise_and_assignment_operator/bitwise_and_assignment_2_test.dart +++ b/packages/beize_compiler/tests/bitwise_and_assignment_operator/bitwise_and_assignment_2_test.dart @@ -5,36 +5,9 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Bitwise AND Assignment (2)'; final BeizeProgramConstant program = await compileTestScript( - 'bitwise_and_assignment_operator', 'bitwise_and_assignment_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opBitwiseAnd); - expectedChunk.addOpCode(BeizeOpCodes.opAssign); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'bitwise_and_assignment_operator', + 'bitwise_and_assignment_2.beize', + ); test('$title - Channel', () async { final List expected = ['1']; diff --git a/packages/beize_compiler/tests/bitwise_and_operator/bitwise_and_1_test.dart b/packages/beize_compiler/tests/bitwise_and_operator/bitwise_and_1_test.dart index 3abc2a8..f9190fc 100644 --- a/packages/beize_compiler/tests/bitwise_and_operator/bitwise_and_1_test.dart +++ b/packages/beize_compiler/tests/bitwise_and_operator/bitwise_and_1_test.dart @@ -4,32 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Bitwise AND (1)'; - final BeizeProgramConstant program = - await compileTestScript('bitwise_and_operator', 'bitwise_and_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opBitwiseAnd); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'bitwise_and_operator', + 'bitwise_and_1.beize', + ); test('$title - Channel', () async { final List expected = ['1']; diff --git a/packages/beize_compiler/tests/bitwise_and_operator/bitwise_and_2_test.dart b/packages/beize_compiler/tests/bitwise_and_operator/bitwise_and_2_test.dart index 40d00c5..2a742a4 100644 --- a/packages/beize_compiler/tests/bitwise_and_operator/bitwise_and_2_test.dart +++ b/packages/beize_compiler/tests/bitwise_and_operator/bitwise_and_2_test.dart @@ -4,32 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Bitwise AND (2)'; - final BeizeProgramConstant program = - await compileTestScript('bitwise_and_operator', 'bitwise_and_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 2.0); - expectedChunk.addOpCode(BeizeOpCodes.opBitwiseAnd); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'bitwise_and_operator', + 'bitwise_and_2.beize', + ); test('$title - Channel', () async { final List expected = ['0']; diff --git a/packages/beize_compiler/tests/bitwise_not_operator/bitwise_not_1_test.dart b/packages/beize_compiler/tests/bitwise_not_operator/bitwise_not_1_test.dart index 71f67ba..de14a9b 100644 --- a/packages/beize_compiler/tests/bitwise_not_operator/bitwise_not_1_test.dart +++ b/packages/beize_compiler/tests/bitwise_not_operator/bitwise_not_1_test.dart @@ -4,30 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Bitwise NOT (1)'; - final BeizeProgramConstant program = - await compileTestScript('bitwise_not_operator', 'bitwise_not_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 0.0); - expectedChunk.addOpCode(BeizeOpCodes.opBitwiseNot); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'bitwise_not_operator', + 'bitwise_not_1.beize', + ); test('$title - Channel', () async { final List expected = ['-1']; diff --git a/packages/beize_compiler/tests/bitwise_or_assignment_operator/bitwise_or_assignment_1_test.dart b/packages/beize_compiler/tests/bitwise_or_assignment_operator/bitwise_or_assignment_1_test.dart index 4ac0d1e..d2e1236 100644 --- a/packages/beize_compiler/tests/bitwise_or_assignment_operator/bitwise_or_assignment_1_test.dart +++ b/packages/beize_compiler/tests/bitwise_or_assignment_operator/bitwise_or_assignment_1_test.dart @@ -5,36 +5,9 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Bitwise OR Assignment (1)'; final BeizeProgramConstant program = await compileTestScript( - 'bitwise_or_assignment_operator', 'bitwise_or_assignment_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 0.0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opBitwiseOr); - expectedChunk.addOpCode(BeizeOpCodes.opAssign); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'bitwise_or_assignment_operator', + 'bitwise_or_assignment_1.beize', + ); test('$title - Channel', () async { final List expected = ['1']; diff --git a/packages/beize_compiler/tests/bitwise_or_assignment_operator/bitwise_or_assignment_2_test.dart b/packages/beize_compiler/tests/bitwise_or_assignment_operator/bitwise_or_assignment_2_test.dart index 0f3dd59..5524c54 100644 --- a/packages/beize_compiler/tests/bitwise_or_assignment_operator/bitwise_or_assignment_2_test.dart +++ b/packages/beize_compiler/tests/bitwise_or_assignment_operator/bitwise_or_assignment_2_test.dart @@ -5,36 +5,9 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Bitwise OR Assignment (2)'; final BeizeProgramConstant program = await compileTestScript( - 'bitwise_or_assignment_operator', 'bitwise_or_assignment_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 0.0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 0.0); - expectedChunk.addOpCode(BeizeOpCodes.opBitwiseOr); - expectedChunk.addOpCode(BeizeOpCodes.opAssign); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'bitwise_or_assignment_operator', + 'bitwise_or_assignment_2.beize', + ); test('$title - Channel', () async { final List expected = ['0']; diff --git a/packages/beize_compiler/tests/bitwise_or_operator/bitwise_or_1_test.dart b/packages/beize_compiler/tests/bitwise_or_operator/bitwise_or_1_test.dart index c334502..1ab96c5 100644 --- a/packages/beize_compiler/tests/bitwise_or_operator/bitwise_or_1_test.dart +++ b/packages/beize_compiler/tests/bitwise_or_operator/bitwise_or_1_test.dart @@ -4,32 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Bitwise OR (1)'; - final BeizeProgramConstant program = - await compileTestScript('bitwise_or_operator', 'bitwise_or_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opBitwiseOr); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'bitwise_or_operator', + 'bitwise_or_1.beize', + ); test('$title - Channel', () async { final List expected = ['1']; diff --git a/packages/beize_compiler/tests/bitwise_or_operator/bitwise_or_2_test.dart b/packages/beize_compiler/tests/bitwise_or_operator/bitwise_or_2_test.dart index b4ac3d1..f3c969b 100644 --- a/packages/beize_compiler/tests/bitwise_or_operator/bitwise_or_2_test.dart +++ b/packages/beize_compiler/tests/bitwise_or_operator/bitwise_or_2_test.dart @@ -4,32 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Bitwise OR (2)'; - final BeizeProgramConstant program = - await compileTestScript('bitwise_or_operator', 'bitwise_or_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 2.0); - expectedChunk.addOpCode(BeizeOpCodes.opBitwiseOr); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'bitwise_or_operator', + 'bitwise_or_2.beize', + ); test('$title - Channel', () async { final List expected = ['3']; diff --git a/packages/beize_compiler/tests/bitwise_xor_assignment_operator/bitwise_xor_assignment_1_test.dart b/packages/beize_compiler/tests/bitwise_xor_assignment_operator/bitwise_xor_assignment_1_test.dart index 70b9ba0..3613986 100644 --- a/packages/beize_compiler/tests/bitwise_xor_assignment_operator/bitwise_xor_assignment_1_test.dart +++ b/packages/beize_compiler/tests/bitwise_xor_assignment_operator/bitwise_xor_assignment_1_test.dart @@ -5,36 +5,9 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Bitwise XOR Assignment (1)'; final BeizeProgramConstant program = await compileTestScript( - 'bitwise_xor_assignment_operator', 'bitwise_xor_assignment_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 0.0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opBitwiseXor); - expectedChunk.addOpCode(BeizeOpCodes.opAssign); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'bitwise_xor_assignment_operator', + 'bitwise_xor_assignment_1.beize', + ); test('$title - Channel', () async { final List expected = ['1']; diff --git a/packages/beize_compiler/tests/bitwise_xor_assignment_operator/bitwise_xor_assignment_2_test.dart b/packages/beize_compiler/tests/bitwise_xor_assignment_operator/bitwise_xor_assignment_2_test.dart index c5ee438..b1354a2 100644 --- a/packages/beize_compiler/tests/bitwise_xor_assignment_operator/bitwise_xor_assignment_2_test.dart +++ b/packages/beize_compiler/tests/bitwise_xor_assignment_operator/bitwise_xor_assignment_2_test.dart @@ -5,36 +5,9 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Bitwise XOR Assignment (2)'; final BeizeProgramConstant program = await compileTestScript( - 'bitwise_xor_assignment_operator', 'bitwise_xor_assignment_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opBitwiseXor); - expectedChunk.addOpCode(BeizeOpCodes.opAssign); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'bitwise_xor_assignment_operator', + 'bitwise_xor_assignment_2.beize', + ); test('$title - Channel', () async { final List expected = ['0']; diff --git a/packages/beize_compiler/tests/bitwise_xor_operator/bitwise_xor_1_test.dart b/packages/beize_compiler/tests/bitwise_xor_operator/bitwise_xor_1_test.dart index 8eff232..fa738e5 100644 --- a/packages/beize_compiler/tests/bitwise_xor_operator/bitwise_xor_1_test.dart +++ b/packages/beize_compiler/tests/bitwise_xor_operator/bitwise_xor_1_test.dart @@ -4,32 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Bitwise XOR (1)'; - final BeizeProgramConstant program = - await compileTestScript('bitwise_xor_operator', 'bitwise_xor_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opBitwiseXor); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'bitwise_xor_operator', + 'bitwise_xor_1.beize', + ); test('$title - Channel', () async { final List expected = ['0']; diff --git a/packages/beize_compiler/tests/bitwise_xor_operator/bitwise_xor_2_test.dart b/packages/beize_compiler/tests/bitwise_xor_operator/bitwise_xor_2_test.dart index e9868cf..831df0d 100644 --- a/packages/beize_compiler/tests/bitwise_xor_operator/bitwise_xor_2_test.dart +++ b/packages/beize_compiler/tests/bitwise_xor_operator/bitwise_xor_2_test.dart @@ -4,32 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Bitwise XOR (2)'; - final BeizeProgramConstant program = - await compileTestScript('bitwise_xor_operator', 'bitwise_xor_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 0.0); - expectedChunk.addOpCode(BeizeOpCodes.opBitwiseXor); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'bitwise_xor_operator', + 'bitwise_xor_2.beize', + ); test('$title - Channel', () async { final List expected = ['1']; diff --git a/packages/beize_compiler/tests/block_statement/block_1_test.dart b/packages/beize_compiler/tests/block_statement/block_1_test.dart index 56ea93f..1651013 100644 --- a/packages/beize_compiler/tests/block_statement/block_1_test.dart +++ b/packages/beize_compiler/tests/block_statement/block_1_test.dart @@ -4,46 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Statement] Block (1)'; - final BeizeProgramConstant program = - await compileTestScript('block_statement', 'block_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'i'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 2.0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'i'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 'c-'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'i'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 'c-'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'i'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'block_statement', + 'block_1.beize', + ); test('$title - Channel', () async { final List expected = ['c-2', 'c-1']; diff --git a/packages/beize_compiler/tests/boolean_native/boolean_from_1.beize b/packages/beize_compiler/tests/boolean_native/boolean_1.beize similarity index 100% rename from packages/beize_compiler/tests/boolean_native/boolean_from_1.beize rename to packages/beize_compiler/tests/boolean_native/boolean_1.beize diff --git a/packages/beize_compiler/tests/boolean_native/boolean_1_test.dart b/packages/beize_compiler/tests/boolean_native/boolean_1_test.dart new file mode 100644 index 0000000..1be2153 --- /dev/null +++ b/packages/beize_compiler/tests/boolean_native/boolean_1_test.dart @@ -0,0 +1,17 @@ +import 'package:beize_compiler/beize_compiler.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; + +Future main() async { + const String title = '[Native] Boolean (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'boolean_native', + 'boolean_1.beize', + ); + + test('$title - Channel', () async { + final List expected = ['true']; + final List actual = await executeTestScript(program); + expect(actual, orderedEquals(expected)); + }); +} diff --git a/packages/beize_compiler/tests/boolean_native/boolean_from_2.beize b/packages/beize_compiler/tests/boolean_native/boolean_2.beize similarity index 100% rename from packages/beize_compiler/tests/boolean_native/boolean_from_2.beize rename to packages/beize_compiler/tests/boolean_native/boolean_2.beize diff --git a/packages/beize_compiler/tests/boolean_native/boolean_2_test.dart b/packages/beize_compiler/tests/boolean_native/boolean_2_test.dart new file mode 100644 index 0000000..4af9cbd --- /dev/null +++ b/packages/beize_compiler/tests/boolean_native/boolean_2_test.dart @@ -0,0 +1,17 @@ +import 'package:beize_compiler/beize_compiler.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; + +Future main() async { + const String title = '[Native] Boolean (2)'; + final BeizeProgramConstant program = await compileTestScript( + 'boolean_native', + 'boolean_2.beize', + ); + + test('$title - Channel', () async { + final List expected = ['false']; + final List actual = await executeTestScript(program); + expect(actual, orderedEquals(expected)); + }); +} diff --git a/packages/beize_compiler/tests/boolean_native/boolean_from_1_test.dart b/packages/beize_compiler/tests/boolean_native/boolean_from_1_test.dart deleted file mode 100644 index 52ebdb2..0000000 --- a/packages/beize_compiler/tests/boolean_native/boolean_from_1_test.dart +++ /dev/null @@ -1,43 +0,0 @@ -import 'package:beize_compiler/beize_compiler.dart'; -import 'package:test/test.dart'; -import '../utils.dart'; - -Future main() async { - const String title = '[Native] Boolean (1)'; - final BeizeProgramConstant program = - await compileTestScript('boolean_native', 'boolean_from_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'Boolean'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'from'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); - - test('$title - Channel', () async { - final List expected = ['true']; - final List actual = await executeTestScript(program); - expect(actual, orderedEquals(expected)); - }); -} diff --git a/packages/beize_compiler/tests/boolean_native/boolean_from_2_test.dart b/packages/beize_compiler/tests/boolean_native/boolean_from_2_test.dart deleted file mode 100644 index 19656ad..0000000 --- a/packages/beize_compiler/tests/boolean_native/boolean_from_2_test.dart +++ /dev/null @@ -1,43 +0,0 @@ -import 'package:beize_compiler/beize_compiler.dart'; -import 'package:test/test.dart'; -import '../utils.dart'; - -Future main() async { - const String title = '[Native] Boolean (2)'; - final BeizeProgramConstant program = - await compileTestScript('boolean_native', 'boolean_from_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'Boolean'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'from'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 0.0); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); - - test('$title - Channel', () async { - final List expected = ['false']; - final List actual = await executeTestScript(program); - expect(actual, orderedEquals(expected)); - }); -} diff --git a/packages/beize_compiler/tests/boolean_value/boolean_1_test.dart b/packages/beize_compiler/tests/boolean_value/boolean_1_test.dart index 0c92c8d..c144888 100644 --- a/packages/beize_compiler/tests/boolean_value/boolean_1_test.dart +++ b/packages/beize_compiler/tests/boolean_value/boolean_1_test.dart @@ -4,28 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Value] Boolean (1)'; - final BeizeProgramConstant program = - await compileTestScript('boolean_value', 'boolean_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opTrue); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'value'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'value'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'boolean_value', + 'boolean_1.beize', + ); test('$title - Channel', () async { final List expected = ['true']; diff --git a/packages/beize_compiler/tests/boolean_value/boolean_2_test.dart b/packages/beize_compiler/tests/boolean_value/boolean_2_test.dart index 6a7f582..4009827 100644 --- a/packages/beize_compiler/tests/boolean_value/boolean_2_test.dart +++ b/packages/beize_compiler/tests/boolean_value/boolean_2_test.dart @@ -4,28 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Value] Boolean (2)'; - final BeizeProgramConstant program = - await compileTestScript('boolean_value', 'boolean_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opFalse); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'value'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'value'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'boolean_value', + 'boolean_2.beize', + ); test('$title - Channel', () async { final List expected = ['false']; diff --git a/packages/beize_compiler/tests/boolean_value/boolean_3_test.dart b/packages/beize_compiler/tests/boolean_value/boolean_3_test.dart index 2c95d87..a4810a0 100644 --- a/packages/beize_compiler/tests/boolean_value/boolean_3_test.dart +++ b/packages/beize_compiler/tests/boolean_value/boolean_3_test.dart @@ -4,29 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Value] Boolean (3)'; - final BeizeProgramConstant program = - await compileTestScript('boolean_value', 'boolean_3.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opFalse); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'value'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'typeof'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'value'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'boolean_value', + 'boolean_3.beize', + ); test('$title - Channel', () async { final List expected = ['Boolean']; diff --git a/packages/beize_compiler/tests/break_statement/break_1_test.dart b/packages/beize_compiler/tests/break_statement/break_1_test.dart index 44ea099..cbdf2c6 100644 --- a/packages/beize_compiler/tests/break_statement/break_1_test.dart +++ b/packages/beize_compiler/tests/break_statement/break_1_test.dart @@ -4,32 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Statement] Break (1)'; - final BeizeProgramConstant program = - await compileTestScript('break_statement', 'break_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opTrue); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(14); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opJump); - expectedChunk.addCode(11); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'break_statement', + 'break_1.beize', + ); test('$title - Channel', () async { final List expected = []; diff --git a/packages/beize_compiler/tests/break_statement/break_2_test.dart b/packages/beize_compiler/tests/break_statement/break_2_test.dart index a3dc553..42a1606 100644 --- a/packages/beize_compiler/tests/break_statement/break_2_test.dart +++ b/packages/beize_compiler/tests/break_statement/break_2_test.dart @@ -4,48 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Statement] Break (2)'; - final BeizeProgramConstant program = - await compileTestScript('break_statement', 'break_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opFalse); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'done'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opTrue); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(26); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'done'); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(5); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opJump); - expectedChunk.addCode(18); - expectedChunk.addOpCode(BeizeOpCodes.opJump); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opTrue); - expectedChunk.addOpCode(BeizeOpCodes.opAssign); - expectedChunk.addConstant(0, 'done'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(4); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'break_statement', + 'break_2.beize', + ); test('$title - Channel', () async { final List expected = ['c-0']; diff --git a/packages/beize_compiler/tests/call_operator/call_1_test.dart b/packages/beize_compiler/tests/call_operator/call_1_test.dart index 675a061..5f636be 100644 --- a/packages/beize_compiler/tests/call_operator/call_1_test.dart +++ b/packages/beize_compiler/tests/call_operator/call_1_test.dart @@ -4,21 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Call (1)'; - final BeizeProgramConstant program = - await compileTestScript('call_operator', 'call_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'call_operator', + 'call_1.beize', + ); test('$title - Channel', () async { final List expected = ['c-0']; diff --git a/packages/beize_compiler/tests/computed_member_access_operator/computed_member_access_1_test.dart b/packages/beize_compiler/tests/computed_member_access_operator/computed_member_access_1_test.dart index 492138e..6b86d66 100644 --- a/packages/beize_compiler/tests/computed_member_access_operator/computed_member_access_1_test.dart +++ b/packages/beize_compiler/tests/computed_member_access_operator/computed_member_access_1_test.dart @@ -5,37 +5,9 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Computed Member Access (1)'; final BeizeProgramConstant program = await compileTestScript( - 'computed_member_access_operator', 'computed_member_access_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'value'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opObject); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'value'); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(3, 'property'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'property'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'computed_member_access_operator', + 'computed_member_access_1.beize', + ); test('$title - Channel', () async { final List expected = ['c-0']; diff --git a/packages/beize_compiler/tests/continue_statement/continue_1_test.dart b/packages/beize_compiler/tests/continue_statement/continue_1_test.dart index f8097a8..53e2f26 100644 --- a/packages/beize_compiler/tests/continue_statement/continue_1_test.dart +++ b/packages/beize_compiler/tests/continue_statement/continue_1_test.dart @@ -4,67 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Statement] Continue (1)'; - final BeizeProgramConstant program = - await compileTestScript('continue_statement', 'continue_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 0.0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'i'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'i'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 3.0); - expectedChunk.addOpCode(BeizeOpCodes.opLess); - expectedChunk.addOpCode(BeizeOpCodes.opJump); - expectedChunk.addCode(10); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'i'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opAssign); - expectedChunk.addConstant(0, 'i'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(5); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(28); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'i'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opEqual); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(5); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(12); - expectedChunk.addOpCode(BeizeOpCodes.opJump); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, 'c-'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'i'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(12); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'continue_statement', + 'continue_1.beize', + ); test('$title - Channel', () async { final List expected = ['c-0', 'c-2']; diff --git a/packages/beize_compiler/tests/continue_statement/continue_2_test.dart b/packages/beize_compiler/tests/continue_statement/continue_2_test.dart index 408b5c2..95c3db0 100644 --- a/packages/beize_compiler/tests/continue_statement/continue_2_test.dart +++ b/packages/beize_compiler/tests/continue_statement/continue_2_test.dart @@ -4,68 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Statement] Continue (2)'; - final BeizeProgramConstant program = - await compileTestScript('continue_statement', 'continue_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 0.0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'i'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'i'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 3.0); - expectedChunk.addOpCode(BeizeOpCodes.opLess); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(41); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'i'); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(3, 'current'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'i'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opAssign); - expectedChunk.addConstant(0, 'i'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'current'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opEqual); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(5); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(5); - expectedChunk.addOpCode(BeizeOpCodes.opJump); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(5, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(6, 'c-'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'current'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(5); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'continue_statement', + 'continue_2.beize', + ); test('$title - Channel', () async { final List expected = ['c-0', 'c-2']; diff --git a/packages/beize_compiler/tests/declaration_operator/declaration_1_test.dart b/packages/beize_compiler/tests/declaration_operator/declaration_1_test.dart index 461cbd1..f19b791 100644 --- a/packages/beize_compiler/tests/declaration_operator/declaration_1_test.dart +++ b/packages/beize_compiler/tests/declaration_operator/declaration_1_test.dart @@ -4,26 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Declaration (1)'; - final BeizeProgramConstant program = - await compileTestScript('declaration_operator', 'declaration_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'declaration_operator', + 'declaration_1.beize', + ); test('$title - Channel', () async { final List expected = ['c-0']; diff --git a/packages/beize_compiler/tests/division_assignment_operator/division_assignment_1_test.dart b/packages/beize_compiler/tests/division_assignment_operator/division_assignment_1_test.dart index d4dc9f2..89e9004 100644 --- a/packages/beize_compiler/tests/division_assignment_operator/division_assignment_1_test.dart +++ b/packages/beize_compiler/tests/division_assignment_operator/division_assignment_1_test.dart @@ -5,36 +5,9 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Division Assignment (1)'; final BeizeProgramConstant program = await compileTestScript( - 'division_assignment_operator', 'division_assignment_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 10.0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 5.0); - expectedChunk.addOpCode(BeizeOpCodes.opDivide); - expectedChunk.addOpCode(BeizeOpCodes.opAssign); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'division_assignment_operator', + 'division_assignment_1.beize', + ); test('$title - Channel', () async { final List expected = ['2']; diff --git a/packages/beize_compiler/tests/division_operator/division_1_test.dart b/packages/beize_compiler/tests/division_operator/division_1_test.dart index 1decfa9..a457b59 100644 --- a/packages/beize_compiler/tests/division_operator/division_1_test.dart +++ b/packages/beize_compiler/tests/division_operator/division_1_test.dart @@ -4,32 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Division (1)'; - final BeizeProgramConstant program = - await compileTestScript('division_operator', 'division_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 10.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 5.0); - expectedChunk.addOpCode(BeizeOpCodes.opDivide); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'division_operator', + 'division_1.beize', + ); test('$title - Channel', () async { final List expected = ['2']; diff --git a/packages/beize_compiler/tests/division_operator/division_2_test.dart b/packages/beize_compiler/tests/division_operator/division_2_test.dart index c9f653d..adfd202 100644 --- a/packages/beize_compiler/tests/division_operator/division_2_test.dart +++ b/packages/beize_compiler/tests/division_operator/division_2_test.dart @@ -4,32 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Division (2)'; - final BeizeProgramConstant program = - await compileTestScript('division_operator', 'division_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 0.0); - expectedChunk.addOpCode(BeizeOpCodes.opDivide); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'division_operator', + 'division_2.beize', + ); test('$title - Channel', () async { final List expected = ['Infinity']; diff --git a/packages/beize_compiler/tests/division_operator/division_3_test.dart b/packages/beize_compiler/tests/division_operator/division_3_test.dart index f0f7647..7cadb1c 100644 --- a/packages/beize_compiler/tests/division_operator/division_3_test.dart +++ b/packages/beize_compiler/tests/division_operator/division_3_test.dart @@ -4,35 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Division (3)'; - final BeizeProgramConstant program = - await compileTestScript('division_operator', 'division_3.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'Number'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'infinity'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 2.0); - expectedChunk.addOpCode(BeizeOpCodes.opDivide); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'division_operator', + 'division_3.beize', + ); test('$title - Channel', () async { final List expected = ['Infinity']; diff --git a/packages/beize_compiler/tests/equality_operator/equality_1_test.dart b/packages/beize_compiler/tests/equality_operator/equality_1_test.dart index 5efff1a..5141690 100644 --- a/packages/beize_compiler/tests/equality_operator/equality_1_test.dart +++ b/packages/beize_compiler/tests/equality_operator/equality_1_test.dart @@ -4,42 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Equality (1)'; - final BeizeProgramConstant program = - await compileTestScript('equality_operator', 'equality_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'value1'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(2, 'value2'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'value1'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'value2'); - expectedChunk.addOpCode(BeizeOpCodes.opEqual); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(3, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'equality_operator', + 'equality_1.beize', + ); test('$title - Channel', () async { final List expected = ['true']; diff --git a/packages/beize_compiler/tests/equality_operator/equality_2_test.dart b/packages/beize_compiler/tests/equality_operator/equality_2_test.dart index 269a76b..877d5cc 100644 --- a/packages/beize_compiler/tests/equality_operator/equality_2_test.dart +++ b/packages/beize_compiler/tests/equality_operator/equality_2_test.dart @@ -4,42 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Equality (2)'; - final BeizeProgramConstant program = - await compileTestScript('equality_operator', 'equality_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'value1'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(2, 'value2'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'value1'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'value2'); - expectedChunk.addOpCode(BeizeOpCodes.opEqual); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(4, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(5, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(6, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'equality_operator', + 'equality_2.beize', + ); test('$title - Channel', () async { final List expected = ['false']; diff --git a/packages/beize_compiler/tests/exponent_assignment_operator/exponent_assignment_1_test.dart b/packages/beize_compiler/tests/exponent_assignment_operator/exponent_assignment_1_test.dart index 22c8898..257ddd0 100644 --- a/packages/beize_compiler/tests/exponent_assignment_operator/exponent_assignment_1_test.dart +++ b/packages/beize_compiler/tests/exponent_assignment_operator/exponent_assignment_1_test.dart @@ -5,36 +5,9 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Exponent Assignment (1)'; final BeizeProgramConstant program = await compileTestScript( - 'exponent_assignment_operator', 'exponent_assignment_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 5.0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 2.0); - expectedChunk.addOpCode(BeizeOpCodes.opExponent); - expectedChunk.addOpCode(BeizeOpCodes.opAssign); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'exponent_assignment_operator', + 'exponent_assignment_1.beize', + ); test('$title - Channel', () async { final List expected = ['25']; diff --git a/packages/beize_compiler/tests/exponent_operator/exponent_1_test.dart b/packages/beize_compiler/tests/exponent_operator/exponent_1_test.dart index 9aaacda..cc846a9 100644 --- a/packages/beize_compiler/tests/exponent_operator/exponent_1_test.dart +++ b/packages/beize_compiler/tests/exponent_operator/exponent_1_test.dart @@ -4,32 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Exponent (1)'; - final BeizeProgramConstant program = - await compileTestScript('exponent_operator', 'exponent_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 5.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 2.0); - expectedChunk.addOpCode(BeizeOpCodes.opExponent); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'exponent_operator', + 'exponent_1.beize', + ); test('$title - Channel', () async { final List expected = ['25']; diff --git a/packages/beize_compiler/tests/floor_division_assignment_operator/floor_division_assignment_1_test.dart b/packages/beize_compiler/tests/floor_division_assignment_operator/floor_division_assignment_1_test.dart index 87ee0b9..523877d 100644 --- a/packages/beize_compiler/tests/floor_division_assignment_operator/floor_division_assignment_1_test.dart +++ b/packages/beize_compiler/tests/floor_division_assignment_operator/floor_division_assignment_1_test.dart @@ -5,37 +5,9 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Floor Division Assignment (1)'; final BeizeProgramConstant program = await compileTestScript( - 'floor_division_assignment_operator', - 'floor_division_assignment_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 10.0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 3.0); - expectedChunk.addOpCode(BeizeOpCodes.opFloor); - expectedChunk.addOpCode(BeizeOpCodes.opAssign); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'floor_division_assignment_operator', + 'floor_division_assignment_1.beize', + ); test('$title - Channel', () async { final List expected = ['3']; diff --git a/packages/beize_compiler/tests/floor_division_operator/floor_division_1_test.dart b/packages/beize_compiler/tests/floor_division_operator/floor_division_1_test.dart index 0699368..be93f6c 100644 --- a/packages/beize_compiler/tests/floor_division_operator/floor_division_1_test.dart +++ b/packages/beize_compiler/tests/floor_division_operator/floor_division_1_test.dart @@ -5,31 +5,9 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Floor Division (1)'; final BeizeProgramConstant program = await compileTestScript( - 'floor_division_operator', 'floor_division_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 10.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 3.0); - expectedChunk.addOpCode(BeizeOpCodes.opFloor); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'floor_division_operator', + 'floor_division_1.beize', + ); test('$title - Channel', () async { final List expected = ['3']; diff --git a/packages/beize_compiler/tests/for_statement/for_1_test.dart b/packages/beize_compiler/tests/for_statement/for_1_test.dart index 8491909..a9ca837 100644 --- a/packages/beize_compiler/tests/for_statement/for_1_test.dart +++ b/packages/beize_compiler/tests/for_statement/for_1_test.dart @@ -4,54 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Statement] For (1)'; - final BeizeProgramConstant program = - await compileTestScript('for_statement', 'for_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 0.0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'i'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'i'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 3.0); - expectedChunk.addOpCode(BeizeOpCodes.opLess); - expectedChunk.addOpCode(BeizeOpCodes.opJump); - expectedChunk.addCode(10); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'i'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opAssign); - expectedChunk.addConstant(0, 'i'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(5); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(15); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, 'c-'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'i'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(12); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'for_statement', + 'for_1.beize', + ); test('$title - Channel', () async { final List expected = ['c-0', 'c-1', 'c-2']; diff --git a/packages/beize_compiler/tests/for_statement/for_2_test.dart b/packages/beize_compiler/tests/for_statement/for_2_test.dart index 76a8e79..62aa25a 100644 --- a/packages/beize_compiler/tests/for_statement/for_2_test.dart +++ b/packages/beize_compiler/tests/for_statement/for_2_test.dart @@ -4,36 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Statement] For (2)'; - final BeizeProgramConstant program = - await compileTestScript('for_statement', 'for_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opTrue); - expectedChunk.addOpCode(BeizeOpCodes.opJump); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(14); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opJump); - expectedChunk.addCode(11); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(3); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'for_statement', + 'for_2.beize', + ); test('$title - Channel', () async { final List expected = []; diff --git a/packages/beize_compiler/tests/for_statement/for_3_test.dart b/packages/beize_compiler/tests/for_statement/for_3_test.dart index 31a8f1d..f5d66d1 100644 --- a/packages/beize_compiler/tests/for_statement/for_3_test.dart +++ b/packages/beize_compiler/tests/for_statement/for_3_test.dart @@ -4,54 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Statement] For (3)'; - final BeizeProgramConstant program = - await compileTestScript('for_statement', 'for_3.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 0.0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'i'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'i'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 5.0); - expectedChunk.addOpCode(BeizeOpCodes.opLess); - expectedChunk.addOpCode(BeizeOpCodes.opJump); - expectedChunk.addCode(10); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'i'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 2.0); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opAssign); - expectedChunk.addConstant(0, 'i'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(5); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(15); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, 'c-'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'i'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(12); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'for_statement', + 'for_3.beize', + ); test('$title - Channel', () async { final List expected = ['c-0', 'c-2', 'c-4']; diff --git a/packages/beize_compiler/tests/function_value/function_1_test.dart b/packages/beize_compiler/tests/function_value/function_1_test.dart index d1e63b4..075cacb 100644 --- a/packages/beize_compiler/tests/function_value/function_1_test.dart +++ b/packages/beize_compiler/tests/function_value/function_1_test.dart @@ -4,41 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Value] Function (1)'; - final BeizeProgramConstant program = - await compileTestScript('function_value', 'function_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - final BeizeTestProgram expectedChunk_0 = BeizeTestProgram(); - expectedChunk_0.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk_0.addOpCode(BeizeOpCodes.opLookup); - expectedChunk_0.addConstant(0, 'out'); - expectedChunk_0.addOpCode(BeizeOpCodes.opConstant); - expectedChunk_0.addConstant(1, 'c-0'); - expectedChunk_0.addOpCode(BeizeOpCodes.opCall); - expectedChunk_0.addCode(1); - expectedChunk_0.addOpCode(BeizeOpCodes.opPop); - expectedChunk_0.addOpCode(BeizeOpCodes.opConstant); - expectedChunk_0.addConstant(2, 'c-1'); - expectedChunk_0.addOpCode(BeizeOpCodes.opReturn); - expectedChunk_0.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addConstant(1, expectedChunk_0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'value'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'value'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'function_value', + 'function_1.beize', + ); test('$title - Channel', () async { final List expected = ['c-0', 'c-1']; diff --git a/packages/beize_compiler/tests/function_value/function_2_test.dart b/packages/beize_compiler/tests/function_value/function_2_test.dart index 309b23c..ae87e37 100644 --- a/packages/beize_compiler/tests/function_value/function_2_test.dart +++ b/packages/beize_compiler/tests/function_value/function_2_test.dart @@ -4,42 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Value] Function (2)'; - final BeizeProgramConstant program = - await compileTestScript('function_value', 'function_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - final BeizeTestProgram expectedChunk_0 = BeizeTestProgram(); - expectedChunk_0.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk_0.addOpCode(BeizeOpCodes.opLookup); - expectedChunk_0.addConstant(0, 'out'); - expectedChunk_0.addOpCode(BeizeOpCodes.opConstant); - expectedChunk_0.addConstant(1, 'c-0'); - expectedChunk_0.addOpCode(BeizeOpCodes.opCall); - expectedChunk_0.addCode(1); - expectedChunk_0.addOpCode(BeizeOpCodes.opPop); - expectedChunk_0.addOpCode(BeizeOpCodes.opConstant); - expectedChunk_0.addConstant(2, 'c-1'); - expectedChunk_0.addOpCode(BeizeOpCodes.opReturn); - expectedChunk_0.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addConstant(1, expectedChunk_0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'value'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'value'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opAwait); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'function_value', + 'function_2.beize', + ); test('$title - Channel', () async { final List expected = ['c-0', 'c-1']; diff --git a/packages/beize_compiler/tests/function_value/function_3_test.dart b/packages/beize_compiler/tests/function_value/function_3_test.dart index b62d927..f23f289 100644 --- a/packages/beize_compiler/tests/function_value/function_3_test.dart +++ b/packages/beize_compiler/tests/function_value/function_3_test.dart @@ -4,33 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Value] Function (3)'; - final BeizeProgramConstant program = - await compileTestScript('function_value', 'function_3.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - final BeizeTestProgram expectedChunk_0 = BeizeTestProgram(); - expectedChunk_0.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk_0.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addConstant(1, expectedChunk_0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'value'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'typeof'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'value'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'function_value', + 'function_3.beize', + ); test('$title - Channel', () async { final List expected = ['Function']; diff --git a/packages/beize_compiler/tests/function_value/function_call_1.dart b/packages/beize_compiler/tests/function_value/function_call_1.dart new file mode 100644 index 0000000..699edb5 --- /dev/null +++ b/packages/beize_compiler/tests/function_value/function_call_1.dart @@ -0,0 +1,17 @@ +import 'package:beize_compiler/beize_compiler.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; + +Future main() async { + const String title = '[Value] Function Call (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'function_value', + 'function_3.beize', + ); + + test('$title - Channel', () async { + final List expected = ['c-0', 'c-1']; + final List actual = await executeTestScript(program); + expect(actual, orderedEquals(expected)); + }); +} diff --git a/packages/beize_compiler/tests/function_value/function_call_1_test.dart b/packages/beize_compiler/tests/function_value/function_call_1_test.dart deleted file mode 100644 index 0b07e91..0000000 --- a/packages/beize_compiler/tests/function_value/function_call_1_test.dart +++ /dev/null @@ -1,53 +0,0 @@ -import 'package:beize_compiler/beize_compiler.dart'; -import 'package:test/test.dart'; -import '../utils.dart'; - -Future main() async { - const String title = '[Value] Function (1)'; - final BeizeProgramConstant program = - await compileTestScript('function_value', 'function_call_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - final BeizeTestProgram expectedChunk_0 = BeizeTestProgram(); - expectedChunk_0.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk_0.addOpCode(BeizeOpCodes.opLookup); - expectedChunk_0.addConstant(0, 'out'); - expectedChunk_0.addOpCode(BeizeOpCodes.opConstant); - expectedChunk_0.addConstant(1, 'c-0'); - expectedChunk_0.addOpCode(BeizeOpCodes.opCall); - expectedChunk_0.addCode(1); - expectedChunk_0.addOpCode(BeizeOpCodes.opPop); - expectedChunk_0.addOpCode(BeizeOpCodes.opConstant); - expectedChunk_0.addConstant(2, 'c-1'); - expectedChunk_0.addOpCode(BeizeOpCodes.opReturn); - expectedChunk_0.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addConstant(1, expectedChunk_0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'value'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'value'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'call'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); - - test('$title - Channel', () async { - final List expected = ['c-0', 'c-1']; - final List actual = await executeTestScript(program); - expect(actual, orderedEquals(expected)); - }); -} diff --git a/packages/beize_compiler/tests/function_value/function_call_2.dart b/packages/beize_compiler/tests/function_value/function_call_2.dart new file mode 100644 index 0000000..902ef9d --- /dev/null +++ b/packages/beize_compiler/tests/function_value/function_call_2.dart @@ -0,0 +1,17 @@ +import 'package:beize_compiler/beize_compiler.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; + +Future main() async { + const String title = '[Value] Function Call (2)'; + final BeizeProgramConstant program = await compileTestScript( + 'function_value', + 'function_3.beize', + ); + + test('$title - Channel', () async { + final List expected = ['Unawaited', 'c-0', 'c-1']; + final List actual = await executeTestScript(program); + expect(actual, orderedEquals(expected)); + }); +} diff --git a/packages/beize_compiler/tests/function_value/function_call_2_test.dart b/packages/beize_compiler/tests/function_value/function_call_2_test.dart deleted file mode 100644 index f6f4f9b..0000000 --- a/packages/beize_compiler/tests/function_value/function_call_2_test.dart +++ /dev/null @@ -1,70 +0,0 @@ -import 'package:beize_compiler/beize_compiler.dart'; -import 'package:test/test.dart'; -import '../utils.dart'; - -Future main() async { - const String title = '[Value] Function (2)'; - final BeizeProgramConstant program = - await compileTestScript('function_value', 'function_call_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - final BeizeTestProgram expectedChunk_0 = BeizeTestProgram(); - expectedChunk_0.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk_0.addOpCode(BeizeOpCodes.opLookup); - expectedChunk_0.addConstant(0, 'out'); - expectedChunk_0.addOpCode(BeizeOpCodes.opConstant); - expectedChunk_0.addConstant(1, 'c-0'); - expectedChunk_0.addOpCode(BeizeOpCodes.opCall); - expectedChunk_0.addCode(1); - expectedChunk_0.addOpCode(BeizeOpCodes.opPop); - expectedChunk_0.addOpCode(BeizeOpCodes.opConstant); - expectedChunk_0.addConstant(2, 'c-1'); - expectedChunk_0.addOpCode(BeizeOpCodes.opReturn); - expectedChunk_0.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addConstant(1, expectedChunk_0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'value'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'value'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'call'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(2, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(5, 'typeof'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAwait); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); - - test('$title - Channel', () async { - final List expected = ['Unawaited', 'c-0', 'c-1']; - final List actual = await executeTestScript(program); - expect(actual, orderedEquals(expected)); - }); -} diff --git a/packages/beize_compiler/tests/gen_test.dart b/packages/beize_compiler/tests/gen_test.dart index 790a3a3..74de485 100644 --- a/packages/beize_compiler/tests/gen_test.dart +++ b/packages/beize_compiler/tests/gen_test.dart @@ -1,22 +1,17 @@ // ignore_for_file: unreachable_from_main, avoid_print +import 'dart:convert'; import 'dart:io'; -import 'package:beize_compiler/beize_compiler.dart'; import 'package:path/path.dart' as p; -import 'utils.dart'; -Future main() async { +Future main(final List args) async { final TestOptions options = TestOptions( - category: 'Operator', - title: 'Addition Assignment', + category: args[0], + title: args[1], titleExtra: '', - index: 1, - output: ['3'], - script: ''' -result := 1; -result += 2; -out("" + result); -''', + index: int.parse(args[2]), + output: (json.decode(args[3]) as List).cast(), + script: args[4], ); await options.parentDir.ensure(); print('Parent Dir: ${options.parentDirPath}'); @@ -30,8 +25,7 @@ out("" + result); } await options.beizeFile.writeAsString(options.script); print('Beize File: ${options.beizeFilePath}'); - await options.dartTestFile - .writeAsString(await generateTestDart(options: options)); + await options.dartTestFile.writeAsString(generateTestDart(options: options)); print('Dart File: ${options.dartTestFilePath}'); print(''); @@ -88,16 +82,10 @@ class TestOptions { static final String rootDir = p.absolute('tests'); } -Future generateTestDart({ +String generateTestDart({ required final TestOptions options, -}) async { - final BeizeProgramConstant program = await BeizeCompiler.compileProject( - root: options.parentDirPath, - entrypoint: options.beizeFileName, - options: BeizeCompilerOptions(), - ); - final String expectedProgramCode = buildExpectedProgramCode(program); - return ''' +}) => + ''' import 'package:beize_compiler/beize_compiler.dart'; import 'package:test/test.dart'; import '../utils.dart'; @@ -109,11 +97,6 @@ Future main() async { '${options.beizeFileName}', ); - test('\$title - Bytecode', () async { - $expectedProgramCode - expect(tcpc(program), tcptc(expectedProgram)); - }); - test('\$title - Channel', () async { final List expected = [${options.output.map((final String x) => "'$x'").join(', ')}]; final List actual = await executeTestScript(program); @@ -121,7 +104,6 @@ Future main() async { }); } '''; -} extension on Directory { Future ensure() async { diff --git a/packages/beize_compiler/tests/greater_than_operator/greater_than_1_test.dart b/packages/beize_compiler/tests/greater_than_operator/greater_than_1_test.dart index aafc342..af92586 100644 --- a/packages/beize_compiler/tests/greater_than_operator/greater_than_1_test.dart +++ b/packages/beize_compiler/tests/greater_than_operator/greater_than_1_test.dart @@ -4,32 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Greater Than (1)'; - final BeizeProgramConstant program = - await compileTestScript('greater_than_operator', 'greater_than_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 10.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 5.0); - expectedChunk.addOpCode(BeizeOpCodes.opGreater); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'greater_than_operator', + 'greater_than_1.beize', + ); test('$title - Channel', () async { final List expected = ['true']; diff --git a/packages/beize_compiler/tests/greater_than_operator/greater_than_2_test.dart b/packages/beize_compiler/tests/greater_than_operator/greater_than_2_test.dart index 74079c5..a3ead4d 100644 --- a/packages/beize_compiler/tests/greater_than_operator/greater_than_2_test.dart +++ b/packages/beize_compiler/tests/greater_than_operator/greater_than_2_test.dart @@ -4,32 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Greater Than (2)'; - final BeizeProgramConstant program = - await compileTestScript('greater_than_operator', 'greater_than_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 5.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 5.0); - expectedChunk.addOpCode(BeizeOpCodes.opGreater); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'greater_than_operator', + 'greater_than_2.beize', + ); test('$title - Channel', () async { final List expected = ['false']; diff --git a/packages/beize_compiler/tests/greater_than_operator/greater_than_3_test.dart b/packages/beize_compiler/tests/greater_than_operator/greater_than_3_test.dart index 89067df..67fb0ea 100644 --- a/packages/beize_compiler/tests/greater_than_operator/greater_than_3_test.dart +++ b/packages/beize_compiler/tests/greater_than_operator/greater_than_3_test.dart @@ -4,32 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Greater Than (3)'; - final BeizeProgramConstant program = - await compileTestScript('greater_than_operator', 'greater_than_3.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 5.0); - expectedChunk.addOpCode(BeizeOpCodes.opGreater); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'greater_than_operator', + 'greater_than_3.beize', + ); test('$title - Channel', () async { final List expected = ['false']; diff --git a/packages/beize_compiler/tests/greater_than_or_equal_operator/greater_than_or_equal_1_test.dart b/packages/beize_compiler/tests/greater_than_or_equal_operator/greater_than_or_equal_1_test.dart index cda73e3..979642e 100644 --- a/packages/beize_compiler/tests/greater_than_or_equal_operator/greater_than_or_equal_1_test.dart +++ b/packages/beize_compiler/tests/greater_than_or_equal_operator/greater_than_or_equal_1_test.dart @@ -5,32 +5,9 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Greater Than Or Equal (1)'; final BeizeProgramConstant program = await compileTestScript( - 'greater_than_or_equal_operator', 'greater_than_or_equal_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 10.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 5.0); - expectedChunk.addOpCode(BeizeOpCodes.opLess); - expectedChunk.addOpCode(BeizeOpCodes.opNot); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'greater_than_or_equal_operator', + 'greater_than_or_equal_1.beize', + ); test('$title - Channel', () async { final List expected = ['true']; diff --git a/packages/beize_compiler/tests/greater_than_or_equal_operator/greater_than_or_equal_2_test.dart b/packages/beize_compiler/tests/greater_than_or_equal_operator/greater_than_or_equal_2_test.dart index ea806be..8e38e1a 100644 --- a/packages/beize_compiler/tests/greater_than_or_equal_operator/greater_than_or_equal_2_test.dart +++ b/packages/beize_compiler/tests/greater_than_or_equal_operator/greater_than_or_equal_2_test.dart @@ -5,32 +5,9 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Greater Than Or Equal (2)'; final BeizeProgramConstant program = await compileTestScript( - 'greater_than_or_equal_operator', 'greater_than_or_equal_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 5.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 5.0); - expectedChunk.addOpCode(BeizeOpCodes.opLess); - expectedChunk.addOpCode(BeizeOpCodes.opNot); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'greater_than_or_equal_operator', + 'greater_than_or_equal_2.beize', + ); test('$title - Channel', () async { final List expected = ['true']; diff --git a/packages/beize_compiler/tests/greater_than_or_equal_operator/greater_than_or_equal_3_test.dart b/packages/beize_compiler/tests/greater_than_or_equal_operator/greater_than_or_equal_3_test.dart index 2d47313..5b836c9 100644 --- a/packages/beize_compiler/tests/greater_than_or_equal_operator/greater_than_or_equal_3_test.dart +++ b/packages/beize_compiler/tests/greater_than_or_equal_operator/greater_than_or_equal_3_test.dart @@ -5,32 +5,9 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Greater Than Or Equal (3)'; final BeizeProgramConstant program = await compileTestScript( - 'greater_than_or_equal_operator', 'greater_than_or_equal_3.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 5.0); - expectedChunk.addOpCode(BeizeOpCodes.opLess); - expectedChunk.addOpCode(BeizeOpCodes.opNot); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'greater_than_or_equal_operator', + 'greater_than_or_equal_3.beize', + ); test('$title - Channel', () async { final List expected = ['false']; diff --git a/packages/beize_compiler/tests/grouping_operator/grouping_1_test.dart b/packages/beize_compiler/tests/grouping_operator/grouping_1_test.dart index e9c4889..0f6290b 100644 --- a/packages/beize_compiler/tests/grouping_operator/grouping_1_test.dart +++ b/packages/beize_compiler/tests/grouping_operator/grouping_1_test.dart @@ -4,35 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Grouping (1)'; - final BeizeProgramConstant program = - await compileTestScript('grouping_operator', 'grouping_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 2.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 5.0); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 4.0); - expectedChunk.addOpCode(BeizeOpCodes.opMultiply); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'grouping_operator', + 'grouping_1.beize', + ); test('$title - Channel', () async { final List expected = ['28']; diff --git a/packages/beize_compiler/tests/if-else_statement/if-else_1.beize b/packages/beize_compiler/tests/if-else_statement/if-else_1.beize new file mode 100644 index 0000000..2fa4ff8 --- /dev/null +++ b/packages/beize_compiler/tests/if-else_statement/if-else_1.beize @@ -0,0 +1,5 @@ +if (true) { + out("c-1"); +} else { + out("c-2"); +} diff --git a/packages/beize_compiler/tests/if-else_statement/if-else_1_test.dart b/packages/beize_compiler/tests/if-else_statement/if-else_1_test.dart new file mode 100644 index 0000000..6ad989c --- /dev/null +++ b/packages/beize_compiler/tests/if-else_statement/if-else_1_test.dart @@ -0,0 +1,17 @@ +import 'package:beize_compiler/beize_compiler.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; + +Future main() async { + const String title = '[Statement] If-Else (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'if-else_statement', + 'if-else_1.beize', + ); + + test('$title - Channel', () async { + final List expected = ['c-1']; + final List actual = await executeTestScript(program); + expect(actual, orderedEquals(expected)); + }); +} diff --git a/packages/beize_compiler/tests/if-else_statement/if-else_2.beize b/packages/beize_compiler/tests/if-else_statement/if-else_2.beize new file mode 100644 index 0000000..e823d1b --- /dev/null +++ b/packages/beize_compiler/tests/if-else_statement/if-else_2.beize @@ -0,0 +1,5 @@ +if (false) { + out("c-1"); +} else { + out("c-2"); +} diff --git a/packages/beize_compiler/tests/if-else_statement/if-else_2_test.dart b/packages/beize_compiler/tests/if-else_statement/if-else_2_test.dart new file mode 100644 index 0000000..3482b4c --- /dev/null +++ b/packages/beize_compiler/tests/if-else_statement/if-else_2_test.dart @@ -0,0 +1,17 @@ +import 'package:beize_compiler/beize_compiler.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; + +Future main() async { + const String title = '[Statement] If-Else (2)'; + final BeizeProgramConstant program = await compileTestScript( + 'if-else_statement', + 'if-else_2.beize', + ); + + test('$title - Channel', () async { + final List expected = ['c-2']; + final List actual = await executeTestScript(program); + expect(actual, orderedEquals(expected)); + }); +} diff --git a/packages/beize_compiler/tests/if-elseif-else_statement/if-elseif-else_1.beize b/packages/beize_compiler/tests/if-elseif-else_statement/if-elseif-else_1.beize new file mode 100644 index 0000000..c8a9c08 --- /dev/null +++ b/packages/beize_compiler/tests/if-elseif-else_statement/if-elseif-else_1.beize @@ -0,0 +1,7 @@ +if (true) { + out("c-1"); +} else if (false) { + out("c-2"); +} else { + out("c-3"); +} diff --git a/packages/beize_compiler/tests/if-elseif-else_statement/if-elseif-else_1_test.dart b/packages/beize_compiler/tests/if-elseif-else_statement/if-elseif-else_1_test.dart new file mode 100644 index 0000000..afac052 --- /dev/null +++ b/packages/beize_compiler/tests/if-elseif-else_statement/if-elseif-else_1_test.dart @@ -0,0 +1,17 @@ +import 'package:beize_compiler/beize_compiler.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; + +Future main() async { + const String title = '[Statement] If-ElseIf-Else (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'if-elseif-else_statement', + 'if-elseif-else_1.beize', + ); + + test('$title - Channel', () async { + final List expected = ['c-1']; + final List actual = await executeTestScript(program); + expect(actual, orderedEquals(expected)); + }); +} diff --git a/packages/beize_compiler/tests/if_statement/if_1_test.dart b/packages/beize_compiler/tests/if_statement/if_1_test.dart index 51928c0..2e21263 100644 --- a/packages/beize_compiler/tests/if_statement/if_1_test.dart +++ b/packages/beize_compiler/tests/if_statement/if_1_test.dart @@ -4,30 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Statement] If (1)'; - final BeizeProgramConstant program = - await compileTestScript('if_statement', 'if_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opTrue); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(12); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addOpCode(BeizeOpCodes.opJump); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'if_statement', + 'if_1.beize', + ); test('$title - Channel', () async { final List expected = ['c-1']; diff --git a/packages/beize_compiler/tests/if_statement/if_2_test.dart b/packages/beize_compiler/tests/if_statement/if_2_test.dart index 5b869f4..60ac365 100644 --- a/packages/beize_compiler/tests/if_statement/if_2_test.dart +++ b/packages/beize_compiler/tests/if_statement/if_2_test.dart @@ -4,30 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Statement] If (2)'; - final BeizeProgramConstant program = - await compileTestScript('if_statement', 'if_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opFalse); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(12); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addOpCode(BeizeOpCodes.opJump); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'if_statement', + 'if_2.beize', + ); test('$title - Channel', () async { final List expected = []; diff --git a/packages/beize_compiler/tests/if_statement/if_else_1_test.dart b/packages/beize_compiler/tests/if_statement/if_else_1_test.dart index 8d2d0fe..d01504f 100644 --- a/packages/beize_compiler/tests/if_statement/if_else_1_test.dart +++ b/packages/beize_compiler/tests/if_statement/if_else_1_test.dart @@ -4,39 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Statement] If-Else (1)'; - final BeizeProgramConstant program = - await compileTestScript('if_statement', 'if_else_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opTrue); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(12); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addOpCode(BeizeOpCodes.opJump); - expectedChunk.addCode(10); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-2'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'if_statement', + 'if_else_1.beize', + ); test('$title - Channel', () async { final List expected = ['c-1']; diff --git a/packages/beize_compiler/tests/if_statement/if_else_2_test.dart b/packages/beize_compiler/tests/if_statement/if_else_2_test.dart index 0458528..096030b 100644 --- a/packages/beize_compiler/tests/if_statement/if_else_2_test.dart +++ b/packages/beize_compiler/tests/if_statement/if_else_2_test.dart @@ -4,39 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Statement] If-Else (2)'; - final BeizeProgramConstant program = - await compileTestScript('if_statement', 'if_else_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opFalse); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(12); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addOpCode(BeizeOpCodes.opJump); - expectedChunk.addCode(10); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-2'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'if_statement', + 'if_else_2.beize', + ); test('$title - Channel', () async { final List expected = ['c-2']; diff --git a/packages/beize_compiler/tests/if_statement/if_elseif_else_1_test.dart b/packages/beize_compiler/tests/if_statement/if_elseif_else_1_test.dart index 55f4150..7d08dde 100644 --- a/packages/beize_compiler/tests/if_statement/if_elseif_else_1_test.dart +++ b/packages/beize_compiler/tests/if_statement/if_elseif_else_1_test.dart @@ -4,55 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Statement] If-ElseIf-Else (1)'; - final BeizeProgramConstant program = - await compileTestScript('if_statement', 'if_elseif_else_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opTrue); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(12); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addOpCode(BeizeOpCodes.opJump); - expectedChunk.addCode(26); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opFalse); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(12); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-2'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addOpCode(BeizeOpCodes.opJump); - expectedChunk.addCode(10); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'c-3'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'if_statement', + 'if_elseif_else_1.beize', + ); test('$title - Channel', () async { final List expected = ['c-1']; diff --git a/packages/beize_compiler/tests/if_statement/if_elseif_else_2_test.dart b/packages/beize_compiler/tests/if_statement/if_elseif_else_2_test.dart index 390e12f..2267528 100644 --- a/packages/beize_compiler/tests/if_statement/if_elseif_else_2_test.dart +++ b/packages/beize_compiler/tests/if_statement/if_elseif_else_2_test.dart @@ -3,56 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Statement] If-ElseIf-Else (1)'; - final BeizeProgramConstant program = - await compileTestScript('if_statement', 'if_elseif_else_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opFalse); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(12); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addOpCode(BeizeOpCodes.opJump); - expectedChunk.addCode(26); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opTrue); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(12); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-2'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addOpCode(BeizeOpCodes.opJump); - expectedChunk.addCode(10); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'c-3'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Statement] If-ElseIf-Else (2)'; + final BeizeProgramConstant program = await compileTestScript( + 'if_statement', + 'if_elseif_else_2.beize', + ); test('$title - Channel', () async { final List expected = ['c-2']; diff --git a/packages/beize_compiler/tests/if_statement/if_elseif_else_3_test.dart b/packages/beize_compiler/tests/if_statement/if_elseif_else_3_test.dart index e0fb891..5e3e2b0 100644 --- a/packages/beize_compiler/tests/if_statement/if_elseif_else_3_test.dart +++ b/packages/beize_compiler/tests/if_statement/if_elseif_else_3_test.dart @@ -3,56 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Statement] If-ElseIf-Else (1)'; - final BeizeProgramConstant program = - await compileTestScript('if_statement', 'if_elseif_else_3.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opFalse); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(12); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addOpCode(BeizeOpCodes.opJump); - expectedChunk.addCode(26); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opFalse); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(12); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-2'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addOpCode(BeizeOpCodes.opJump); - expectedChunk.addCode(10); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'c-3'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Statement] If-ElseIf-Else (2)'; + final BeizeProgramConstant program = await compileTestScript( + 'if_statement', + 'if_elseif_else_3.beize', + ); test('$title - Channel', () async { final List expected = ['c-3']; diff --git a/packages/beize_compiler/tests/import_statement/import_1.beize b/packages/beize_compiler/tests/import_statement/import_1.beize deleted file mode 100644 index 87ad235..0000000 --- a/packages/beize_compiler/tests/import_statement/import_1.beize +++ /dev/null @@ -1,3 +0,0 @@ -import "./import_dummy.beize" as dummy; - -dummy.callOut("c-0"); diff --git a/packages/beize_compiler/tests/import_statement/import_1_test.dart b/packages/beize_compiler/tests/import_statement/import_1_test.dart deleted file mode 100644 index 64ba195..0000000 --- a/packages/beize_compiler/tests/import_statement/import_1_test.dart +++ /dev/null @@ -1,53 +0,0 @@ -import 'package:beize_compiler/beize_compiler.dart'; -import 'package:test/test.dart'; -import '../utils.dart'; - -Future main() async { - const String title = '[Statement] Import (1)'; - final BeizeProgramConstant program = - await compileTestScript('import_statement', 'import_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opImport); - expectedChunk.addCode(1); - expectedChunk.addConstant(0, 'dummy'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'dummy'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'callOut'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); - - test('$title - Bytecode (Dummy File)', () async { - final BeizeChunk chunk = program.moduleAt(1).chunk; - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - final BeizeTestProgram expectedChunk_0 = BeizeTestProgram(); - expectedChunk_0.addOpCode(BeizeOpCodes.opLookup); - expectedChunk_0.addConstant(0, 'out'); - expectedChunk_0.addOpCode(BeizeOpCodes.opLookup); - expectedChunk_0.addConstant(1, 'value'); - expectedChunk_0.addOpCode(BeizeOpCodes.opCall); - expectedChunk_0.addCode(1); - expectedChunk_0.addOpCode(BeizeOpCodes.opReturn); - expectedChunk.addConstant(1, expectedChunk_0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'callOut'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); - - test('$title - Channel', () async { - final List expected = ['c-0']; - final List actual = await executeTestScript(program); - expect(actual, orderedEquals(expected)); - }); -} diff --git a/packages/beize_compiler/tests/import_statement/import_dummy.beize b/packages/beize_compiler/tests/import_statement/import_dummy.beize deleted file mode 100644 index 7d2434b..0000000 --- a/packages/beize_compiler/tests/import_statement/import_dummy.beize +++ /dev/null @@ -1 +0,0 @@ -callOut := -> value : out(value); diff --git a/packages/beize_compiler/tests/inequality_operator/inequality_1_test.dart b/packages/beize_compiler/tests/inequality_operator/inequality_1_test.dart index ffc0548..ba9c004 100644 --- a/packages/beize_compiler/tests/inequality_operator/inequality_1_test.dart +++ b/packages/beize_compiler/tests/inequality_operator/inequality_1_test.dart @@ -4,43 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Inequality (1)'; - final BeizeProgramConstant program = - await compileTestScript('inequality_operator', 'inequality_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'value1'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(2, 'value2'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'value1'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'value2'); - expectedChunk.addOpCode(BeizeOpCodes.opEqual); - expectedChunk.addOpCode(BeizeOpCodes.opNot); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(4, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(5, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(6, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'inequality_operator', + 'inequality_1.beize', + ); test('$title - Channel', () async { final List expected = ['true']; diff --git a/packages/beize_compiler/tests/inequality_operator/inequality_2_test.dart b/packages/beize_compiler/tests/inequality_operator/inequality_2_test.dart index 2dbab72..deadc34 100644 --- a/packages/beize_compiler/tests/inequality_operator/inequality_2_test.dart +++ b/packages/beize_compiler/tests/inequality_operator/inequality_2_test.dart @@ -4,43 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Inequality (2)'; - final BeizeProgramConstant program = - await compileTestScript('inequality_operator', 'inequality_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'value1'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(2, 'value2'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'value1'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'value2'); - expectedChunk.addOpCode(BeizeOpCodes.opEqual); - expectedChunk.addOpCode(BeizeOpCodes.opNot); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(3, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'inequality_operator', + 'inequality_2.beize', + ); test('$title - Channel', () async { final List expected = ['false']; diff --git a/packages/beize_compiler/tests/lesser_than_operator/lesser_than_1_test.dart b/packages/beize_compiler/tests/lesser_than_operator/lesser_than_1_test.dart index 181b1e7..c8c5b6f 100644 --- a/packages/beize_compiler/tests/lesser_than_operator/lesser_than_1_test.dart +++ b/packages/beize_compiler/tests/lesser_than_operator/lesser_than_1_test.dart @@ -4,32 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Lesser Than (1)'; - final BeizeProgramConstant program = - await compileTestScript('lesser_than_operator', 'lesser_than_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 5.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 10.0); - expectedChunk.addOpCode(BeizeOpCodes.opLess); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'lesser_than_operator', + 'lesser_than_1.beize', + ); test('$title - Channel', () async { final List expected = ['true']; diff --git a/packages/beize_compiler/tests/lesser_than_operator/lesser_than_2_test.dart b/packages/beize_compiler/tests/lesser_than_operator/lesser_than_2_test.dart index 781fa19..878c87e 100644 --- a/packages/beize_compiler/tests/lesser_than_operator/lesser_than_2_test.dart +++ b/packages/beize_compiler/tests/lesser_than_operator/lesser_than_2_test.dart @@ -4,32 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Lesser Than (2)'; - final BeizeProgramConstant program = - await compileTestScript('lesser_than_operator', 'lesser_than_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 5.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 5.0); - expectedChunk.addOpCode(BeizeOpCodes.opLess); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'lesser_than_operator', + 'lesser_than_2.beize', + ); test('$title - Channel', () async { final List expected = ['false']; diff --git a/packages/beize_compiler/tests/lesser_than_operator/lesser_than_3_test.dart b/packages/beize_compiler/tests/lesser_than_operator/lesser_than_3_test.dart index ea45e96..0d51f1a 100644 --- a/packages/beize_compiler/tests/lesser_than_operator/lesser_than_3_test.dart +++ b/packages/beize_compiler/tests/lesser_than_operator/lesser_than_3_test.dart @@ -4,32 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Lesser Than (3)'; - final BeizeProgramConstant program = - await compileTestScript('lesser_than_operator', 'lesser_than_3.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 10.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 5.0); - expectedChunk.addOpCode(BeizeOpCodes.opLess); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'lesser_than_operator', + 'lesser_than_3.beize', + ); test('$title - Channel', () async { final List expected = ['false']; diff --git a/packages/beize_compiler/tests/lesser_than_or_equal_operator/lesser_than_or_equal_1_test.dart b/packages/beize_compiler/tests/lesser_than_or_equal_operator/lesser_than_or_equal_1_test.dart index 3015952..b37b10a 100644 --- a/packages/beize_compiler/tests/lesser_than_or_equal_operator/lesser_than_or_equal_1_test.dart +++ b/packages/beize_compiler/tests/lesser_than_or_equal_operator/lesser_than_or_equal_1_test.dart @@ -5,32 +5,9 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Lesser Than Or Equal (1)'; final BeizeProgramConstant program = await compileTestScript( - 'lesser_than_or_equal_operator', 'lesser_than_or_equal_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 5.0); - expectedChunk.addOpCode(BeizeOpCodes.opGreater); - expectedChunk.addOpCode(BeizeOpCodes.opNot); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'lesser_than_or_equal_operator', + 'lesser_than_or_equal_1.beize', + ); test('$title - Channel', () async { final List expected = ['true']; diff --git a/packages/beize_compiler/tests/lesser_than_or_equal_operator/lesser_than_or_equal_2_test.dart b/packages/beize_compiler/tests/lesser_than_or_equal_operator/lesser_than_or_equal_2_test.dart index 1d0bcf5..5c7ece0 100644 --- a/packages/beize_compiler/tests/lesser_than_or_equal_operator/lesser_than_or_equal_2_test.dart +++ b/packages/beize_compiler/tests/lesser_than_or_equal_operator/lesser_than_or_equal_2_test.dart @@ -5,32 +5,9 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Lesser Than Or Equal (2)'; final BeizeProgramConstant program = await compileTestScript( - 'lesser_than_or_equal_operator', 'lesser_than_or_equal_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 5.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 5.0); - expectedChunk.addOpCode(BeizeOpCodes.opGreater); - expectedChunk.addOpCode(BeizeOpCodes.opNot); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'lesser_than_or_equal_operator', + 'lesser_than_or_equal_2.beize', + ); test('$title - Channel', () async { final List expected = ['true']; diff --git a/packages/beize_compiler/tests/lesser_than_or_equal_operator/lesser_than_or_equal_3_test.dart b/packages/beize_compiler/tests/lesser_than_or_equal_operator/lesser_than_or_equal_3_test.dart index 9662bdc..177ac21 100644 --- a/packages/beize_compiler/tests/lesser_than_or_equal_operator/lesser_than_or_equal_3_test.dart +++ b/packages/beize_compiler/tests/lesser_than_or_equal_operator/lesser_than_or_equal_3_test.dart @@ -5,32 +5,9 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Lesser Than Or Equal (3)'; final BeizeProgramConstant program = await compileTestScript( - 'lesser_than_or_equal_operator', 'lesser_than_or_equal_3.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 10.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 5.0); - expectedChunk.addOpCode(BeizeOpCodes.opGreater); - expectedChunk.addOpCode(BeizeOpCodes.opNot); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'lesser_than_or_equal_operator', + 'lesser_than_or_equal_3.beize', + ); test('$title - Channel', () async { final List expected = ['false']; diff --git a/packages/beize_compiler/tests/list_value/list_1_test.dart b/packages/beize_compiler/tests/list_value/list_1_test.dart index d7566f4..16ce981 100644 --- a/packages/beize_compiler/tests/list_value/list_1_test.dart +++ b/packages/beize_compiler/tests/list_value/list_1_test.dart @@ -4,30 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Value] List (1)'; - final BeizeProgramConstant program = - await compileTestScript('list_value', 'list_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'typeof'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'list_value', + 'list_1.beize', + ); test('$title - Channel', () async { final List expected = ['List']; diff --git a/packages/beize_compiler/tests/list_value/list_2_test.dart b/packages/beize_compiler/tests/list_value/list_2_test.dart index f37844a..d5bba33 100644 --- a/packages/beize_compiler/tests/list_value/list_2_test.dart +++ b/packages/beize_compiler/tests/list_value/list_2_test.dart @@ -4,29 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Value] List (2)'; - final BeizeProgramConstant program = - await compileTestScript('list_value', 'list_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'list_value', + 'list_2.beize', + ); test('$title - Channel', () async { final List expected = ['[]']; diff --git a/packages/beize_compiler/tests/list_value/list_clear_1_test.dart b/packages/beize_compiler/tests/list_value/list_clear_1_test.dart index 5a70d2c..9184545 100644 --- a/packages/beize_compiler/tests/list_value/list_clear_1_test.dart +++ b/packages/beize_compiler/tests/list_value/list_clear_1_test.dart @@ -3,46 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] List (1)'; - final BeizeProgramConstant program = - await compileTestScript('list_value', 'list_clear_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'clear'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, 'join'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(6, ', '); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] List.Clear (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'list_value', + 'list_clear_1.beize', + ); test('$title - Channel', () async { final List expected = ['']; diff --git a/packages/beize_compiler/tests/list_value/list_clone_1_test.dart b/packages/beize_compiler/tests/list_value/list_clone_1_test.dart index b143cb1..35f4f35 100644 --- a/packages/beize_compiler/tests/list_value/list_clone_1_test.dart +++ b/packages/beize_compiler/tests/list_value/list_clone_1_test.dart @@ -3,48 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] List (1)'; - final BeizeProgramConstant program = - await compileTestScript('list_value', 'list_clone_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 'clone'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(3, 'cloned'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(5, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'cloned'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(6, 'join'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(7, ', '); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] List.Clone (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'list_value', + 'list_clone_1.beize', + ); test('$title - Channel', () async { final List expected = ['c-0, c-1']; diff --git a/packages/beize_compiler/tests/list_value/list_contains_1_test.dart b/packages/beize_compiler/tests/list_value/list_contains_1_test.dart index b052275..16aea7d 100644 --- a/packages/beize_compiler/tests/list_value/list_contains_1_test.dart +++ b/packages/beize_compiler/tests/list_value/list_contains_1_test.dart @@ -3,41 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] List (1)'; - final BeizeProgramConstant program = - await compileTestScript('list_value', 'list_contains_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, 'contains'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] List.Contains (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'list_value', + 'list_contains_1.beize', + ); test('$title - Channel', () async { final List expected = ['true']; diff --git a/packages/beize_compiler/tests/list_value/list_filter_1_test.dart b/packages/beize_compiler/tests/list_value/list_filter_1_test.dart index 1525f9c..b72c3cf 100644 --- a/packages/beize_compiler/tests/list_value/list_filter_1_test.dart +++ b/packages/beize_compiler/tests/list_value/list_filter_1_test.dart @@ -3,61 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] List (1)'; - final BeizeProgramConstant program = - await compileTestScript('list_value', 'list_filter_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opNull); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(3); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 'filter'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - final BeizeTestProgram expectedChunk_0 = BeizeTestProgram(); - expectedChunk_0.addOpCode(BeizeOpCodes.opLookup); - expectedChunk_0.addConstant(0, 'x'); - expectedChunk_0.addOpCode(BeizeOpCodes.opNull); - expectedChunk_0.addOpCode(BeizeOpCodes.opEqual); - expectedChunk_0.addOpCode(BeizeOpCodes.opNot); - expectedChunk_0.addOpCode(BeizeOpCodes.opReturn); - expectedChunk.addConstant(5, expectedChunk_0); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(3, 'filtered'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(6, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(7, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'filtered'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(8, 'join'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(9, ', '); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] List.Filter (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'list_value', + 'list_filter_1.beize', + ); test('$title - Channel', () async { final List expected = ['c-0, c-1']; diff --git a/packages/beize_compiler/tests/list_value/list_findIndex_1_test.dart b/packages/beize_compiler/tests/list_value/list_findIndex_1_test.dart index 82b0cb0..8c807c1 100644 --- a/packages/beize_compiler/tests/list_value/list_findIndex_1_test.dart +++ b/packages/beize_compiler/tests/list_value/list_findIndex_1_test.dart @@ -3,50 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] List (1)'; - final BeizeProgramConstant program = - await compileTestScript('list_value', 'list_findIndex_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(3); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, 'findIndex'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - final BeizeTestProgram expectedChunk_0 = BeizeTestProgram(); - expectedChunk_0.addOpCode(BeizeOpCodes.opLookup); - expectedChunk_0.addConstant(0, 'x'); - expectedChunk_0.addOpCode(BeizeOpCodes.opConstant); - expectedChunk_0.addConstant(1, 'c-1'); - expectedChunk_0.addOpCode(BeizeOpCodes.opEqual); - expectedChunk_0.addOpCode(BeizeOpCodes.opReturn); - expectedChunk.addConstant(6, expectedChunk_0); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] List.FindIndex (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'list_value', + 'list_findIndex_1.beize', + ); test('$title - Channel', () async { final List expected = ['1']; diff --git a/packages/beize_compiler/tests/list_value/list_findLastIndex_1_test.dart b/packages/beize_compiler/tests/list_value/list_findLastIndex_1_test.dart index 7f2726d..a0a3ce4 100644 --- a/packages/beize_compiler/tests/list_value/list_findLastIndex_1_test.dart +++ b/packages/beize_compiler/tests/list_value/list_findLastIndex_1_test.dart @@ -3,51 +3,10 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] List (1)'; + const String title = '[Value] List.FindLastIndex (1)'; final BeizeProgramConstant program = await compileTestScript('list_value', 'list_findLastIndex_1.beize'); - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(3); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, 'findLastIndex'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - final BeizeTestProgram expectedChunk_0 = BeizeTestProgram(); - expectedChunk_0.addOpCode(BeizeOpCodes.opLookup); - expectedChunk_0.addConstant(0, 'x'); - expectedChunk_0.addOpCode(BeizeOpCodes.opConstant); - expectedChunk_0.addConstant(1, 'c-1'); - expectedChunk_0.addOpCode(BeizeOpCodes.opEqual); - expectedChunk_0.addOpCode(BeizeOpCodes.opReturn); - expectedChunk.addConstant(6, expectedChunk_0); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); - test('$title - Channel', () async { final List expected = ['2']; final List actual = await executeTestScript(program); diff --git a/packages/beize_compiler/tests/list_value/list_find_1_test.dart b/packages/beize_compiler/tests/list_value/list_find_1_test.dart index 3aec6ae..d912823 100644 --- a/packages/beize_compiler/tests/list_value/list_find_1_test.dart +++ b/packages/beize_compiler/tests/list_value/list_find_1_test.dart @@ -3,45 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] List (1)'; - final BeizeProgramConstant program = - await compileTestScript('list_value', 'list_find_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 'find'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - final BeizeTestProgram expectedChunk_0 = BeizeTestProgram(); - expectedChunk_0.addOpCode(BeizeOpCodes.opLookup); - expectedChunk_0.addConstant(0, 'x'); - expectedChunk_0.addOpCode(BeizeOpCodes.opConstant); - expectedChunk_0.addConstant(1, 'c-1'); - expectedChunk_0.addOpCode(BeizeOpCodes.opEqual); - expectedChunk_0.addOpCode(BeizeOpCodes.opReturn); - expectedChunk.addConstant(5, expectedChunk_0); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] List.Find (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'list_value', + 'list_find_1.beize', + ); test('$title - Channel', () async { final List expected = ['c-1']; diff --git a/packages/beize_compiler/tests/list_value/list_flatDeep_1_test.dart b/packages/beize_compiler/tests/list_value/list_flatDeep_1_test.dart index 6866d29..1504914 100644 --- a/packages/beize_compiler/tests/list_value/list_flatDeep_1_test.dart +++ b/packages/beize_compiler/tests/list_value/list_flatDeep_1_test.dart @@ -3,54 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] List (1)'; - final BeizeProgramConstant program = - await compileTestScript('list_value', 'list_flatDeep_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'c-2'); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(6, 'flatDeep'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(7, 'join'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(8, ', '); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] List.Flatdeep (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'list_value', + 'list_flatDeep_1.beize', + ); test('$title - Channel', () async { final List expected = ['c-0, c-1, c-2']; diff --git a/packages/beize_compiler/tests/list_value/list_flat_1_test.dart b/packages/beize_compiler/tests/list_value/list_flat_1_test.dart index 68ec44b..729a3b4 100644 --- a/packages/beize_compiler/tests/list_value/list_flat_1_test.dart +++ b/packages/beize_compiler/tests/list_value/list_flat_1_test.dart @@ -3,54 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] List (1)'; - final BeizeProgramConstant program = - await compileTestScript('list_value', 'list_flat_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'c-2'); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(6, 'flat'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(7, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(8, 'join'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(9, ', '); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] List.Flat (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'list_value', + 'list_flat_1.beize', + ); test('$title - Channel', () async { final List expected = ['c-0, c-1, c-2']; diff --git a/packages/beize_compiler/tests/list_value/list_forEach_1_test.dart b/packages/beize_compiler/tests/list_value/list_forEach_1_test.dart index e8b379b..bf874db 100644 --- a/packages/beize_compiler/tests/list_value/list_forEach_1_test.dart +++ b/packages/beize_compiler/tests/list_value/list_forEach_1_test.dart @@ -3,67 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] List (1)'; - final BeizeProgramConstant program = - await compileTestScript('list_value', 'list_forEach_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'value'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(3, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'value'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 'forEach'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - final BeizeTestProgram expectedChunk_0 = BeizeTestProgram(); - expectedChunk_0.addOpCode(BeizeOpCodes.opLookup); - expectedChunk_0.addConstant(0, 'result'); - expectedChunk_0.addOpCode(BeizeOpCodes.opConstant); - expectedChunk_0.addConstant(1, 'push'); - expectedChunk_0.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk_0.addOpCode(BeizeOpCodes.opLookup); - expectedChunk_0.addConstant(2, 'x'); - expectedChunk_0.addOpCode(BeizeOpCodes.opCall); - expectedChunk_0.addCode(1); - expectedChunk_0.addOpCode(BeizeOpCodes.opReturn); - expectedChunk.addConstant(5, expectedChunk_0); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(6, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(7, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(8, 'join'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(9, ', '); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] List.ForEach (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'list_value', + 'list_forEach_1.beize', + ); test('$title - Channel', () async { final List expected = ['c-0, c-1']; diff --git a/packages/beize_compiler/tests/list_value/list_indexOf_1_test.dart b/packages/beize_compiler/tests/list_value/list_indexOf_1_test.dart index 2a09db0..ac78474 100644 --- a/packages/beize_compiler/tests/list_value/list_indexOf_1_test.dart +++ b/packages/beize_compiler/tests/list_value/list_indexOf_1_test.dart @@ -3,41 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] List (1)'; - final BeizeProgramConstant program = - await compileTestScript('list_value', 'list_indexOf_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, 'indexOf'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] List.IndexOf (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'list_value', + 'list_indexOf_1.beize', + ); test('$title - Channel', () async { final List expected = ['1']; diff --git a/packages/beize_compiler/tests/list_value/list_isEmpty_1_test.dart b/packages/beize_compiler/tests/list_value/list_isEmpty_1_test.dart index cd6e4cf..8f255aa 100644 --- a/packages/beize_compiler/tests/list_value/list_isEmpty_1_test.dart +++ b/packages/beize_compiler/tests/list_value/list_isEmpty_1_test.dart @@ -3,35 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] List (1)'; - final BeizeProgramConstant program = - await compileTestScript('list_value', 'list_isEmpty_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'isEmpty'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] List.IsEmpty (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'list_value', + 'list_isEmpty_1.beize', + ); test('$title - Channel', () async { final List expected = ['true']; diff --git a/packages/beize_compiler/tests/list_value/list_isNotEmpty_1_test.dart b/packages/beize_compiler/tests/list_value/list_isNotEmpty_1_test.dart index b524ac0..40ba1d9 100644 --- a/packages/beize_compiler/tests/list_value/list_isNotEmpty_1_test.dart +++ b/packages/beize_compiler/tests/list_value/list_isNotEmpty_1_test.dart @@ -3,37 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] List (1)'; - final BeizeProgramConstant program = - await compileTestScript('list_value', 'list_isNotEmpty_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 0.0); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 'isNotEmpty'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] List.IsNotEmpty (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'list_value', + 'list_isNotEmpty_1.beize', + ); test('$title - Channel', () async { final List expected = ['true']; diff --git a/packages/beize_compiler/tests/list_value/list_join_1_test.dart b/packages/beize_compiler/tests/list_value/list_join_1_test.dart index 35fdf9c..c610645 100644 --- a/packages/beize_compiler/tests/list_value/list_join_1_test.dart +++ b/packages/beize_compiler/tests/list_value/list_join_1_test.dart @@ -3,41 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] List (1)'; - final BeizeProgramConstant program = - await compileTestScript('list_value', 'list_join_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, 'join'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(6, ', '); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] List.Join (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'list_value', + 'list_join_1.beize', + ); test('$title - Channel', () async { final List expected = ['c-0, c-1']; diff --git a/packages/beize_compiler/tests/list_value/list_lastIndexOf_1_test.dart b/packages/beize_compiler/tests/list_value/list_lastIndexOf_1_test.dart index a9f1ddc..1503db5 100644 --- a/packages/beize_compiler/tests/list_value/list_lastIndexOf_1_test.dart +++ b/packages/beize_compiler/tests/list_value/list_lastIndexOf_1_test.dart @@ -3,43 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] List (1)'; - final BeizeProgramConstant program = - await compileTestScript('list_value', 'list_lastIndexOf_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(3); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, 'lastIndexOf'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] List.LastIndexOf (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'list_value', + 'list_lastIndexOf_1.beize', + ); test('$title - Channel', () async { final List expected = ['2']; diff --git a/packages/beize_compiler/tests/list_value/list_length_1_test.dart b/packages/beize_compiler/tests/list_value/list_length_1_test.dart index 3ed2cd6..3d77be6 100644 --- a/packages/beize_compiler/tests/list_value/list_length_1_test.dart +++ b/packages/beize_compiler/tests/list_value/list_length_1_test.dart @@ -4,38 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Value] List (1)'; - final BeizeProgramConstant program = - await compileTestScript('list_value', 'list_length_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, 'length'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'list_value', + 'list_length_1.beize', + ); test('$title - Channel', () async { final List expected = ['2']; diff --git a/packages/beize_compiler/tests/list_value/list_map_1_test.dart b/packages/beize_compiler/tests/list_value/list_map_1_test.dart index 261b751..de57ce5 100644 --- a/packages/beize_compiler/tests/list_value/list_map_1_test.dart +++ b/packages/beize_compiler/tests/list_value/list_map_1_test.dart @@ -3,60 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] List (1)'; - final BeizeProgramConstant program = - await compileTestScript('list_value', 'list_map_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 0.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 'map'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - final BeizeTestProgram expectedChunk_0 = BeizeTestProgram(); - expectedChunk_0.addOpCode(BeizeOpCodes.opConstant); - expectedChunk_0.addConstant(0, 'c-'); - expectedChunk_0.addOpCode(BeizeOpCodes.opLookup); - expectedChunk_0.addConstant(1, 'x'); - expectedChunk_0.addOpCode(BeizeOpCodes.opAdd); - expectedChunk_0.addOpCode(BeizeOpCodes.opReturn); - expectedChunk.addConstant(5, expectedChunk_0); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(3, 'mapped'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(6, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(7, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'mapped'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(8, 'join'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(9, ', '); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] List.Map (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'list_value', + 'list_map_1.beize', + ); test('$title - Channel', () async { final List expected = ['c-0, c-1']; diff --git a/packages/beize_compiler/tests/list_value/list_pop_1_test.dart b/packages/beize_compiler/tests/list_value/list_pop_1_test.dart index fdf080a..10d108d 100644 --- a/packages/beize_compiler/tests/list_value/list_pop_1_test.dart +++ b/packages/beize_compiler/tests/list_value/list_pop_1_test.dart @@ -3,46 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] List (1)'; - final BeizeProgramConstant program = - await compileTestScript('list_value', 'list_pop_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'pop'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, 'join'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(6, ', '); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] List.Pop (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'list_value', + 'list_pop_1.beize', + ); test('$title - Channel', () async { final List expected = ['c-0']; diff --git a/packages/beize_compiler/tests/list_value/list_pushAll_1_test.dart b/packages/beize_compiler/tests/list_value/list_pushAll_1_test.dart index cbef178..8f367ce 100644 --- a/packages/beize_compiler/tests/list_value/list_pushAll_1_test.dart +++ b/packages/beize_compiler/tests/list_value/list_pushAll_1_test.dart @@ -3,48 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] List (1)'; - final BeizeProgramConstant program = - await compileTestScript('list_value', 'list_pushAll_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'pushAll'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, 'join'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(6, ', '); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] List.PushAll (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'list_value', + 'list_pushAll_1.beize', + ); test('$title - Channel', () async { final List expected = ['c-0, c-1']; diff --git a/packages/beize_compiler/tests/list_value/list_push_1_test.dart b/packages/beize_compiler/tests/list_value/list_push_1_test.dart index 5c6cb8c..454b41e 100644 --- a/packages/beize_compiler/tests/list_value/list_push_1_test.dart +++ b/packages/beize_compiler/tests/list_value/list_push_1_test.dart @@ -3,47 +3,10 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] List (1)'; + const String title = '[Value] List.Push (1)'; final BeizeProgramConstant program = await compileTestScript('list_value', 'list_push_1.beize'); - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'push'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, 'join'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(6, ', '); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); - test('$title - Channel', () async { final List expected = ['c-0, c-1']; final List actual = await executeTestScript(program); diff --git a/packages/beize_compiler/tests/list_value/list_remove_1_test.dart b/packages/beize_compiler/tests/list_value/list_remove_1_test.dart index 78cd75f..89f411e 100644 --- a/packages/beize_compiler/tests/list_value/list_remove_1_test.dart +++ b/packages/beize_compiler/tests/list_value/list_remove_1_test.dart @@ -3,48 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] List (1)'; - final BeizeProgramConstant program = - await compileTestScript('list_value', 'list_remove_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'remove'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, 'join'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(6, ', '); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] List.Remove (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'list_value', + 'list_remove_1.beize', + ); test('$title - Channel', () async { final List expected = ['c-0']; diff --git a/packages/beize_compiler/tests/list_value/list_reversed_1_test.dart b/packages/beize_compiler/tests/list_value/list_reversed_1_test.dart index 5b41c06..52fa3cc 100644 --- a/packages/beize_compiler/tests/list_value/list_reversed_1_test.dart +++ b/packages/beize_compiler/tests/list_value/list_reversed_1_test.dart @@ -3,48 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] List (1)'; - final BeizeProgramConstant program = - await compileTestScript('list_value', 'list_reversed_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'reversed'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(3, 'reversed'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'reversed'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, 'join'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(6, ', '); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] List.Reversed (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'list_value', + 'list_reversed_1.beize', + ); test('$title - Channel', () async { final List expected = ['c-1, c-0']; diff --git a/packages/beize_compiler/tests/list_value/list_sort_1_test.dart b/packages/beize_compiler/tests/list_value/list_sort_1_test.dart index 4fda1c2..c32115a 100644 --- a/packages/beize_compiler/tests/list_value/list_sort_1_test.dart +++ b/packages/beize_compiler/tests/list_value/list_sort_1_test.dart @@ -3,67 +3,10 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] List (1)'; + const String title = '[Value] List.Sort (1)'; final BeizeProgramConstant program = await compileTestScript('list_value', 'list_sort_1.beize'); - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-2'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(3); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, 'sort'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - final BeizeTestProgram expectedChunk_0 = BeizeTestProgram(); - expectedChunk_0.addOpCode(BeizeOpCodes.opLookup); - expectedChunk_0.addConstant(0, 'a'); - expectedChunk_0.addOpCode(BeizeOpCodes.opConstant); - expectedChunk_0.addConstant(1, 'compareTo'); - expectedChunk_0.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk_0.addOpCode(BeizeOpCodes.opLookup); - expectedChunk_0.addConstant(2, 'b'); - expectedChunk_0.addOpCode(BeizeOpCodes.opCall); - expectedChunk_0.addCode(1); - expectedChunk_0.addOpCode(BeizeOpCodes.opReturn); - expectedChunk.addConstant(6, expectedChunk_0); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(4, 'sorted'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(7, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(8, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'sorted'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(9, 'join'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(10, ', '); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); - test('$title - Channel', () async { final List expected = ['c-0, c-1, c-2']; final List actual = await executeTestScript(program); diff --git a/packages/beize_compiler/tests/list_value/list_sublist_1_test.dart b/packages/beize_compiler/tests/list_value/list_sublist_1_test.dart index 031150d..0a2939b 100644 --- a/packages/beize_compiler/tests/list_value/list_sublist_1_test.dart +++ b/packages/beize_compiler/tests/list_value/list_sublist_1_test.dart @@ -3,54 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] List (1)'; - final BeizeProgramConstant program = - await compileTestScript('list_value', 'list_sublist_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'c-2'); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(3); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 'sublist'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(6, 3.0); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(4, 'sublist'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(7, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'sublist'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(8, 'join'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(9, ', '); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] List.Sublist (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'list_value', + 'list_sublist_1.beize', + ); test('$title - Channel', () async { final List expected = ['c-1, c-2']; diff --git a/packages/beize_compiler/tests/list_value/list_unique_1_test.dart b/packages/beize_compiler/tests/list_value/list_unique_1_test.dart index 516c513..4621799 100644 --- a/packages/beize_compiler/tests/list_value/list_unique_1_test.dart +++ b/packages/beize_compiler/tests/list_value/list_unique_1_test.dart @@ -3,50 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] List (1)'; - final BeizeProgramConstant program = - await compileTestScript('list_value', 'list_unique_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'c-2'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(4); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(6, 'unique'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(7, 'join'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(8, ', '); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] List.Unique (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'list_value', + 'list_unique_1.beize', + ); test('$title - Channel', () async { final List expected = ['c-0, c-1, c-2']; diff --git a/packages/beize_compiler/tests/logical_and_assignment_operator/logical_and_assignment_1_test.dart b/packages/beize_compiler/tests/logical_and_assignment_operator/logical_and_assignment_1_test.dart index 4178604..b756f42 100644 --- a/packages/beize_compiler/tests/logical_and_assignment_operator/logical_and_assignment_1_test.dart +++ b/packages/beize_compiler/tests/logical_and_assignment_operator/logical_and_assignment_1_test.dart @@ -5,36 +5,9 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Logical AND Assignment (1)'; final BeizeProgramConstant program = await compileTestScript( - 'logical_and_assignment_operator', 'logical_and_assignment_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opTrue); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(4); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opTrue); - expectedChunk.addOpCode(BeizeOpCodes.opAssign); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'logical_and_assignment_operator', + 'logical_and_assignment_1.beize', + ); test('$title - Channel', () async { final List expected = ['true']; diff --git a/packages/beize_compiler/tests/logical_and_assignment_operator/logical_and_assignment_2_test.dart b/packages/beize_compiler/tests/logical_and_assignment_operator/logical_and_assignment_2_test.dart index 4e448aa..59b0d53 100644 --- a/packages/beize_compiler/tests/logical_and_assignment_operator/logical_and_assignment_2_test.dart +++ b/packages/beize_compiler/tests/logical_and_assignment_operator/logical_and_assignment_2_test.dart @@ -5,36 +5,9 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Logical AND Assignment (2)'; final BeizeProgramConstant program = await compileTestScript( - 'logical_and_assignment_operator', 'logical_and_assignment_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opTrue); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(4); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opFalse); - expectedChunk.addOpCode(BeizeOpCodes.opAssign); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'logical_and_assignment_operator', + 'logical_and_assignment_2.beize', + ); test('$title - Channel', () async { final List expected = ['false']; diff --git a/packages/beize_compiler/tests/logical_and_operator/logical_and_1_test.dart b/packages/beize_compiler/tests/logical_and_operator/logical_and_1_test.dart index 1ff9e5c..19fdf6b 100644 --- a/packages/beize_compiler/tests/logical_and_operator/logical_and_1_test.dart +++ b/packages/beize_compiler/tests/logical_and_operator/logical_and_1_test.dart @@ -4,32 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Logical AND (1)'; - final BeizeProgramConstant program = - await compileTestScript('logical_and_operator', 'logical_and_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opTrue); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opTrue); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'logical_and_operator', + 'logical_and_1.beize', + ); test('$title - Channel', () async { final List expected = ['true']; diff --git a/packages/beize_compiler/tests/logical_and_operator/logical_and_2_test.dart b/packages/beize_compiler/tests/logical_and_operator/logical_and_2_test.dart index ca7e2c7..730f0ec 100644 --- a/packages/beize_compiler/tests/logical_and_operator/logical_and_2_test.dart +++ b/packages/beize_compiler/tests/logical_and_operator/logical_and_2_test.dart @@ -4,32 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Logical AND (2)'; - final BeizeProgramConstant program = - await compileTestScript('logical_and_operator', 'logical_and_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opTrue); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opFalse); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'logical_and_operator', + 'logical_and_2.beize', + ); test('$title - Channel', () async { final List expected = ['false']; diff --git a/packages/beize_compiler/tests/logical_and_operator/logical_and_3_test.dart b/packages/beize_compiler/tests/logical_and_operator/logical_and_3_test.dart index 9f0f906..762117d 100644 --- a/packages/beize_compiler/tests/logical_and_operator/logical_and_3_test.dart +++ b/packages/beize_compiler/tests/logical_and_operator/logical_and_3_test.dart @@ -4,32 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Logical AND (3)'; - final BeizeProgramConstant program = - await compileTestScript('logical_and_operator', 'logical_and_3.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opFalse); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opFalse); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'logical_and_operator', + 'logical_and_3.beize', + ); test('$title - Channel', () async { final List expected = ['false']; diff --git a/packages/beize_compiler/tests/logical_not_operator/logical_not_1_test.dart b/packages/beize_compiler/tests/logical_not_operator/logical_not_1_test.dart index 64b9477..5d95cd5 100644 --- a/packages/beize_compiler/tests/logical_not_operator/logical_not_1_test.dart +++ b/packages/beize_compiler/tests/logical_not_operator/logical_not_1_test.dart @@ -4,29 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Logical NOT (1)'; - final BeizeProgramConstant program = - await compileTestScript('logical_not_operator', 'logical_not_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opFalse); - expectedChunk.addOpCode(BeizeOpCodes.opNot); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'logical_not_operator', + 'logical_not_1.beize', + ); test('$title - Channel', () async { final List expected = ['true']; diff --git a/packages/beize_compiler/tests/logical_not_operator/logical_not_2_test.dart b/packages/beize_compiler/tests/logical_not_operator/logical_not_2_test.dart index 77c8a63..b9a4f0d 100644 --- a/packages/beize_compiler/tests/logical_not_operator/logical_not_2_test.dart +++ b/packages/beize_compiler/tests/logical_not_operator/logical_not_2_test.dart @@ -4,29 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Logical NOT (2)'; - final BeizeProgramConstant program = - await compileTestScript('logical_not_operator', 'logical_not_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opTrue); - expectedChunk.addOpCode(BeizeOpCodes.opNot); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'logical_not_operator', + 'logical_not_2.beize', + ); test('$title - Channel', () async { final List expected = ['false']; diff --git a/packages/beize_compiler/tests/logical_not_operator/logical_not_3_test.dart b/packages/beize_compiler/tests/logical_not_operator/logical_not_3_test.dart index aa50880..a05055e 100644 --- a/packages/beize_compiler/tests/logical_not_operator/logical_not_3_test.dart +++ b/packages/beize_compiler/tests/logical_not_operator/logical_not_3_test.dart @@ -4,30 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Logical NOT (3)'; - final BeizeProgramConstant program = - await compileTestScript('logical_not_operator', 'logical_not_3.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opTrue); - expectedChunk.addOpCode(BeizeOpCodes.opNot); - expectedChunk.addOpCode(BeizeOpCodes.opNot); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'logical_not_operator', + 'logical_not_3.beize', + ); test('$title - Channel', () async { final List expected = ['true']; diff --git a/packages/beize_compiler/tests/logical_not_operator/logical_not_4_test.dart b/packages/beize_compiler/tests/logical_not_operator/logical_not_4_test.dart index 73440c1..3f41784 100644 --- a/packages/beize_compiler/tests/logical_not_operator/logical_not_4_test.dart +++ b/packages/beize_compiler/tests/logical_not_operator/logical_not_4_test.dart @@ -4,30 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Logical NOT (4)'; - final BeizeProgramConstant program = - await compileTestScript('logical_not_operator', 'logical_not_4.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opFalse); - expectedChunk.addOpCode(BeizeOpCodes.opNot); - expectedChunk.addOpCode(BeizeOpCodes.opNot); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'logical_not_operator', + 'logical_not_4.beize', + ); test('$title - Channel', () async { final List expected = ['false']; diff --git a/packages/beize_compiler/tests/logical_or_assignment_operator/logical_or_assignment_1_test.dart b/packages/beize_compiler/tests/logical_or_assignment_operator/logical_or_assignment_1_test.dart index f407b35..73fce81 100644 --- a/packages/beize_compiler/tests/logical_or_assignment_operator/logical_or_assignment_1_test.dart +++ b/packages/beize_compiler/tests/logical_or_assignment_operator/logical_or_assignment_1_test.dart @@ -5,38 +5,9 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Logical OR Assignment (1)'; final BeizeProgramConstant program = await compileTestScript( - 'logical_or_assignment_operator', 'logical_or_assignment_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opTrue); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opJump); - expectedChunk.addCode(4); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opFalse); - expectedChunk.addOpCode(BeizeOpCodes.opAssign); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'logical_or_assignment_operator', + 'logical_or_assignment_1.beize', + ); test('$title - Channel', () async { final List expected = ['true']; diff --git a/packages/beize_compiler/tests/logical_or_assignment_operator/logical_or_assignment_2_test.dart b/packages/beize_compiler/tests/logical_or_assignment_operator/logical_or_assignment_2_test.dart index d7603c7..b9d3239 100644 --- a/packages/beize_compiler/tests/logical_or_assignment_operator/logical_or_assignment_2_test.dart +++ b/packages/beize_compiler/tests/logical_or_assignment_operator/logical_or_assignment_2_test.dart @@ -5,38 +5,9 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Logical OR Assignment (2)'; final BeizeProgramConstant program = await compileTestScript( - 'logical_or_assignment_operator', 'logical_or_assignment_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opFalse); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opJump); - expectedChunk.addCode(4); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opFalse); - expectedChunk.addOpCode(BeizeOpCodes.opAssign); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'logical_or_assignment_operator', + 'logical_or_assignment_2.beize', + ); test('$title - Channel', () async { final List expected = ['false']; diff --git a/packages/beize_compiler/tests/logical_or_operator/logical_or_1_test.dart b/packages/beize_compiler/tests/logical_or_operator/logical_or_1_test.dart index e626b25..fb7c2cd 100644 --- a/packages/beize_compiler/tests/logical_or_operator/logical_or_1_test.dart +++ b/packages/beize_compiler/tests/logical_or_operator/logical_or_1_test.dart @@ -4,34 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Logical OR (1)'; - final BeizeProgramConstant program = - await compileTestScript('logical_or_operator', 'logical_or_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opTrue); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opJump); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opFalse); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'logical_or_operator', + 'logical_or_1.beize', + ); test('$title - Channel', () async { final List expected = ['true']; diff --git a/packages/beize_compiler/tests/logical_or_operator/logical_or_2_test.dart b/packages/beize_compiler/tests/logical_or_operator/logical_or_2_test.dart index 39070cb..95b310d 100644 --- a/packages/beize_compiler/tests/logical_or_operator/logical_or_2_test.dart +++ b/packages/beize_compiler/tests/logical_or_operator/logical_or_2_test.dart @@ -4,34 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Logical OR (2)'; - final BeizeProgramConstant program = - await compileTestScript('logical_or_operator', 'logical_or_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opTrue); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opJump); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opTrue); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'logical_or_operator', + 'logical_or_2.beize', + ); test('$title - Channel', () async { final List expected = ['true']; diff --git a/packages/beize_compiler/tests/logical_or_operator/logical_or_3_test.dart b/packages/beize_compiler/tests/logical_or_operator/logical_or_3_test.dart index eee9a7c..78c0154 100644 --- a/packages/beize_compiler/tests/logical_or_operator/logical_or_3_test.dart +++ b/packages/beize_compiler/tests/logical_or_operator/logical_or_3_test.dart @@ -4,34 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Logical OR (3)'; - final BeizeProgramConstant program = - await compileTestScript('logical_or_operator', 'logical_or_3.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opFalse); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opJump); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opTrue); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'logical_or_operator', + 'logical_or_3.beize', + ); test('$title - Channel', () async { final List expected = ['true']; diff --git a/packages/beize_compiler/tests/logical_or_operator/logical_or_4_test.dart b/packages/beize_compiler/tests/logical_or_operator/logical_or_4_test.dart index af9cdd8..adfe9c0 100644 --- a/packages/beize_compiler/tests/logical_or_operator/logical_or_4_test.dart +++ b/packages/beize_compiler/tests/logical_or_operator/logical_or_4_test.dart @@ -4,34 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Logical OR (4)'; - final BeizeProgramConstant program = - await compileTestScript('logical_or_operator', 'logical_or_4.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opFalse); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opJump); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opFalse); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'logical_or_operator', + 'logical_or_4.beize', + ); test('$title - Channel', () async { final List expected = ['false']; diff --git a/packages/beize_compiler/tests/match_statement/match_1_test.dart b/packages/beize_compiler/tests/match_statement/match_1_test.dart index 404dacc..70dc3e6 100644 --- a/packages/beize_compiler/tests/match_statement/match_1_test.dart +++ b/packages/beize_compiler/tests/match_statement/match_1_test.dart @@ -4,49 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Statement] Match (1)'; - final BeizeProgramConstant program = - await compileTestScript('match_statement', 'match_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(0, 0.0); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(4); - expectedChunk.addOpCode(BeizeOpCodes.opTop); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(0, 0.0); - expectedChunk.addOpCode(BeizeOpCodes.opEqual); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(12); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(34); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(25); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'c-else'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(34); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'match_statement', + 'match_1.beize', + ); test('$title - Channel', () async { final List expected = ['c-0']; diff --git a/packages/beize_compiler/tests/match_statement/match_2_test.dart b/packages/beize_compiler/tests/match_statement/match_2_test.dart index 130460c..7574731 100644 --- a/packages/beize_compiler/tests/match_statement/match_2_test.dart +++ b/packages/beize_compiler/tests/match_statement/match_2_test.dart @@ -4,49 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Statement] Match (2)'; - final BeizeProgramConstant program = - await compileTestScript('match_statement', 'match_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(0, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(4); - expectedChunk.addOpCode(BeizeOpCodes.opTop); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 0.0); - expectedChunk.addOpCode(BeizeOpCodes.opEqual); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(12); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(34); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(25); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 'c-else'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(34); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'match_statement', + 'match_2.beize', + ); test('$title - Channel', () async { final List expected = ['c-else']; diff --git a/packages/beize_compiler/tests/match_statement/match_3_test.dart b/packages/beize_compiler/tests/match_statement/match_3_test.dart index 3ca53a6..e9111fb 100644 --- a/packages/beize_compiler/tests/match_statement/match_3_test.dart +++ b/packages/beize_compiler/tests/match_statement/match_3_test.dart @@ -4,28 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Statement] Match (3)'; - final BeizeProgramConstant program = - await compileTestScript('match_statement', 'match_3.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(0, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(4); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-else'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(13); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'match_statement', + 'match_3.beize', + ); test('$title - Channel', () async { final List expected = ['c-else']; diff --git a/packages/beize_compiler/tests/match_statement/match_4_test.dart b/packages/beize_compiler/tests/match_statement/match_4_test.dart index 3a90021..9f1148a 100644 --- a/packages/beize_compiler/tests/match_statement/match_4_test.dart +++ b/packages/beize_compiler/tests/match_statement/match_4_test.dart @@ -4,19 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Statement] Match (4)'; - final BeizeProgramConstant program = - await compileTestScript('match_statement', 'match_4.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(0, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(4); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'match_statement', + 'match_4.beize', + ); test('$title - Channel', () async { final List expected = []; diff --git a/packages/beize_compiler/tests/member_access_operator/member_access_1_test.dart b/packages/beize_compiler/tests/member_access_operator/member_access_1_test.dart index 8aa768a..13c90c0 100644 --- a/packages/beize_compiler/tests/member_access_operator/member_access_1_test.dart +++ b/packages/beize_compiler/tests/member_access_operator/member_access_1_test.dart @@ -5,35 +5,9 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Member Access (1)'; final BeizeProgramConstant program = await compileTestScript( - 'member_access_operator', 'member_access_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'value'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opObject); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'value'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'member_access_operator', + 'member_access_1.beize', + ); test('$title - Channel', () async { final List expected = ['c-0']; diff --git a/packages/beize_compiler/tests/member_access_operator/member_access_2_test.dart b/packages/beize_compiler/tests/member_access_operator/member_access_2_test.dart index 75734ef..7878c53 100644 --- a/packages/beize_compiler/tests/member_access_operator/member_access_2_test.dart +++ b/packages/beize_compiler/tests/member_access_operator/member_access_2_test.dart @@ -5,36 +5,9 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Member Access (2)'; final BeizeProgramConstant program = await compileTestScript( - 'member_access_operator', 'member_access_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'value'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opObject); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'typeof'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, 'value1'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'member_access_operator', + 'member_access_2.beize', + ); test('$title - Channel', () async { final List expected = ['Null']; diff --git a/packages/beize_compiler/tests/multiplication_assignment_operator/multiplication_assignment_1_test.dart b/packages/beize_compiler/tests/multiplication_assignment_operator/multiplication_assignment_1_test.dart index ceb4d7a..7763c96 100644 --- a/packages/beize_compiler/tests/multiplication_assignment_operator/multiplication_assignment_1_test.dart +++ b/packages/beize_compiler/tests/multiplication_assignment_operator/multiplication_assignment_1_test.dart @@ -5,37 +5,9 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Multiplication Assignment (1)'; final BeizeProgramConstant program = await compileTestScript( - 'multiplication_assignment_operator', - 'multiplication_assignment_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 5.0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 2.0); - expectedChunk.addOpCode(BeizeOpCodes.opMultiply); - expectedChunk.addOpCode(BeizeOpCodes.opAssign); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'multiplication_assignment_operator', + 'multiplication_assignment_1.beize', + ); test('$title - Channel', () async { final List expected = ['10']; diff --git a/packages/beize_compiler/tests/multiplication_operator/multiplication_1_test.dart b/packages/beize_compiler/tests/multiplication_operator/multiplication_1_test.dart index 7f24b33..c5dae73 100644 --- a/packages/beize_compiler/tests/multiplication_operator/multiplication_1_test.dart +++ b/packages/beize_compiler/tests/multiplication_operator/multiplication_1_test.dart @@ -5,31 +5,9 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Multiplication (1)'; final BeizeProgramConstant program = await compileTestScript( - 'multiplication_operator', 'multiplication_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 5.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 2.0); - expectedChunk.addOpCode(BeizeOpCodes.opMultiply); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'multiplication_operator', + 'multiplication_1.beize', + ); test('$title - Channel', () async { final List expected = ['10']; diff --git a/packages/beize_compiler/tests/multiplication_operator/multiplication_2_test.dart b/packages/beize_compiler/tests/multiplication_operator/multiplication_2_test.dart index 537c50b..e0b48f6 100644 --- a/packages/beize_compiler/tests/multiplication_operator/multiplication_2_test.dart +++ b/packages/beize_compiler/tests/multiplication_operator/multiplication_2_test.dart @@ -5,34 +5,9 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Multiplication (2)'; final BeizeProgramConstant program = await compileTestScript( - 'multiplication_operator', 'multiplication_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'Number'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'infinity'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 2.0); - expectedChunk.addOpCode(BeizeOpCodes.opMultiply); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'multiplication_operator', + 'multiplication_2.beize', + ); test('$title - Channel', () async { final List expected = ['Infinity']; diff --git a/packages/beize_compiler/tests/null_value/null_1_test.dart b/packages/beize_compiler/tests/null_value/null_1_test.dart index fb336a0..ed3a7fc 100644 --- a/packages/beize_compiler/tests/null_value/null_1_test.dart +++ b/packages/beize_compiler/tests/null_value/null_1_test.dart @@ -4,29 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Value] Null (1)'; - final BeizeProgramConstant program = - await compileTestScript('null_value', 'null_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opNull); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'value'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'typeof'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'value'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'null_value', + 'null_1.beize', + ); test('$title - Channel', () async { final List expected = ['Null']; diff --git a/packages/beize_compiler/tests/nullable_access_operator/nullable_access_1_test.dart b/packages/beize_compiler/tests/nullable_access_operator/nullable_access_1_test.dart index 529ceb3..df20783 100644 --- a/packages/beize_compiler/tests/nullable_access_operator/nullable_access_1_test.dart +++ b/packages/beize_compiler/tests/nullable_access_operator/nullable_access_1_test.dart @@ -5,35 +5,9 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Nullable Access (1)'; final BeizeProgramConstant program = await compileTestScript( - 'nullable_access_operator', 'nullable_access_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'value'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opObject); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'value'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'nullable_access_operator', + 'nullable_access_1.beize', + ); test('$title - Channel', () async { final List expected = ['c-0']; diff --git a/packages/beize_compiler/tests/nullable_access_operator/nullable_access_2_test.dart b/packages/beize_compiler/tests/nullable_access_operator/nullable_access_2_test.dart index 5bcfb5e..6a6b601 100644 --- a/packages/beize_compiler/tests/nullable_access_operator/nullable_access_2_test.dart +++ b/packages/beize_compiler/tests/nullable_access_operator/nullable_access_2_test.dart @@ -5,33 +5,9 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Nullable Access (2)'; final BeizeProgramConstant program = await compileTestScript( - 'nullable_access_operator', 'nullable_access_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opNull); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'typeof'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfNull); - expectedChunk.addCode(3); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'value'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'nullable_access_operator', + 'nullable_access_2.beize', + ); test('$title - Channel', () async { final List expected = ['Null']; diff --git a/packages/beize_compiler/tests/nullable_assignment_operator/nullable_assignment_1_test.dart b/packages/beize_compiler/tests/nullable_assignment_operator/nullable_assignment_1_test.dart index 433be46..7e11eee 100644 --- a/packages/beize_compiler/tests/nullable_assignment_operator/nullable_assignment_1_test.dart +++ b/packages/beize_compiler/tests/nullable_assignment_operator/nullable_assignment_1_test.dart @@ -5,49 +5,9 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Nullable Assignment (1)'; final BeizeProgramConstant program = await compileTestScript( - 'nullable_assignment_operator', 'nullable_assignment_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opNull); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfNull); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opJump); - expectedChunk.addCode(5); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opAssign); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'nullable_assignment_operator', + 'nullable_assignment_1.beize', + ); test('$title - Channel', () async { final List expected = ['null', 'c-0']; diff --git a/packages/beize_compiler/tests/nullable_assignment_operator/nullable_assignment_2_test.dart b/packages/beize_compiler/tests/nullable_assignment_operator/nullable_assignment_2_test.dart index 2e86b98..eb03138 100644 --- a/packages/beize_compiler/tests/nullable_assignment_operator/nullable_assignment_2_test.dart +++ b/packages/beize_compiler/tests/nullable_assignment_operator/nullable_assignment_2_test.dart @@ -5,50 +5,9 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Nullable Assignment (2)'; final BeizeProgramConstant program = await compileTestScript( - 'nullable_assignment_operator', 'nullable_assignment_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfNull); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opJump); - expectedChunk.addCode(5); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opAssign); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'nullable_assignment_operator', + 'nullable_assignment_2.beize', + ); test('$title - Channel', () async { final List expected = ['c-0', 'c-0']; diff --git a/packages/beize_compiler/tests/nullable_or_operator/nullable_or_1_test.dart b/packages/beize_compiler/tests/nullable_or_operator/nullable_or_1_test.dart index 8f2fbad..92273a1 100644 --- a/packages/beize_compiler/tests/nullable_or_operator/nullable_or_1_test.dart +++ b/packages/beize_compiler/tests/nullable_or_operator/nullable_or_1_test.dart @@ -4,35 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Nullable OR (1)'; - final BeizeProgramConstant program = - await compileTestScript('nullable_or_operator', 'nullable_or_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opNull); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfNull); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opJump); - expectedChunk.addCode(3); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'nullable_or_operator', + 'nullable_or_1.beize', + ); test('$title - Channel', () async { final List expected = ['c-0']; diff --git a/packages/beize_compiler/tests/nullable_or_operator/nullable_or_2_test.dart b/packages/beize_compiler/tests/nullable_or_operator/nullable_or_2_test.dart index 594a1b8..29f5a81 100644 --- a/packages/beize_compiler/tests/nullable_or_operator/nullable_or_2_test.dart +++ b/packages/beize_compiler/tests/nullable_or_operator/nullable_or_2_test.dart @@ -4,36 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Nullable OR (2)'; - final BeizeProgramConstant program = - await compileTestScript('nullable_or_operator', 'nullable_or_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfNull); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opJump); - expectedChunk.addCode(3); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'nullable_or_operator', + 'nullable_or_2.beize', + ); test('$title - Channel', () async { final List expected = ['c-0']; diff --git a/packages/beize_compiler/tests/number_value/number_1.beize b/packages/beize_compiler/tests/number_value/number_1.beize new file mode 100644 index 0000000..4bad030 --- /dev/null +++ b/packages/beize_compiler/tests/number_value/number_1.beize @@ -0,0 +1,2 @@ +result := (-1).abs(); +out("" + result); diff --git a/packages/beize_compiler/tests/number_value/number_1_test.dart b/packages/beize_compiler/tests/number_value/number_1_test.dart new file mode 100644 index 0000000..f6ff84a --- /dev/null +++ b/packages/beize_compiler/tests/number_value/number_1_test.dart @@ -0,0 +1,17 @@ +import 'package:beize_compiler/beize_compiler.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; + +Future main() async { + const String title = '[Value] Number (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'number_value', + 'number_1.beize', + ); + + test('$title - Channel', () async { + final List expected = ['1']; + final List actual = await executeTestScript(program); + expect(actual, orderedEquals(expected)); + }); +} diff --git a/packages/beize_compiler/tests/number_value/number_2.beize b/packages/beize_compiler/tests/number_value/number_2.beize new file mode 100644 index 0000000..f34518b --- /dev/null +++ b/packages/beize_compiler/tests/number_value/number_2.beize @@ -0,0 +1,2 @@ +result := Number.infinity.isFinite(); +out("" + result); diff --git a/packages/beize_compiler/tests/number_value/number_2_test.dart b/packages/beize_compiler/tests/number_value/number_2_test.dart new file mode 100644 index 0000000..9902151 --- /dev/null +++ b/packages/beize_compiler/tests/number_value/number_2_test.dart @@ -0,0 +1,17 @@ +import 'package:beize_compiler/beize_compiler.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; + +Future main() async { + const String title = '[Value] Number (2)'; + final BeizeProgramConstant program = await compileTestScript( + 'number_value', + 'number_2.beize', + ); + + test('$title - Channel', () async { + final List expected = ['false']; + final List actual = await executeTestScript(program); + expect(actual, orderedEquals(expected)); + }); +} diff --git a/packages/beize_compiler/tests/number_value/number_abs_1_test.dart b/packages/beize_compiler/tests/number_value/number_abs_1_test.dart index e6186c3..92273bb 100644 --- a/packages/beize_compiler/tests/number_value/number_abs_1_test.dart +++ b/packages/beize_compiler/tests/number_value/number_abs_1_test.dart @@ -3,36 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] Number (1)'; - final BeizeProgramConstant program = - await compileTestScript('number_value', 'number_abs_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opNegate); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'abs'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] Number.Abs (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'number_value', + 'number_abs_1.beize', + ); test('$title - Channel', () async { final List expected = ['1']; diff --git a/packages/beize_compiler/tests/number_value/number_ceil_1_test.dart b/packages/beize_compiler/tests/number_value/number_ceil_1_test.dart index becb7c5..97c80de 100644 --- a/packages/beize_compiler/tests/number_value/number_ceil_1_test.dart +++ b/packages/beize_compiler/tests/number_value/number_ceil_1_test.dart @@ -3,35 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] Number (1)'; - final BeizeProgramConstant program = - await compileTestScript('number_value', 'number_ceil_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 1.1); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'ceil'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] Number.Ceil (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'number_value', + 'number_ceil_1.beize', + ); test('$title - Channel', () async { final List expected = ['2']; diff --git a/packages/beize_compiler/tests/number_value/number_isFinite_1_test.dart b/packages/beize_compiler/tests/number_value/number_isFinite_1_test.dart index b240bb3..09ab4b1 100644 --- a/packages/beize_compiler/tests/number_value/number_isFinite_1_test.dart +++ b/packages/beize_compiler/tests/number_value/number_isFinite_1_test.dart @@ -3,35 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] Number (1)'; - final BeizeProgramConstant program = - await compileTestScript('number_value', 'number_isFinite_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'isFinite'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] Number.IsFinite (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'number_value', + 'number_isFinite_1.beize', + ); test('$title - Channel', () async { final List expected = ['true']; diff --git a/packages/beize_compiler/tests/number_value/number_isFinite_2_test.dart b/packages/beize_compiler/tests/number_value/number_isFinite_2_test.dart index 0eb3e0c..e7400d6 100644 --- a/packages/beize_compiler/tests/number_value/number_isFinite_2_test.dart +++ b/packages/beize_compiler/tests/number_value/number_isFinite_2_test.dart @@ -3,38 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] Number (2)'; - final BeizeProgramConstant program = - await compileTestScript('number_value', 'number_isFinite_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'Number'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'infinity'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'isFinite'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] Number.IsFinite (2)'; + final BeizeProgramConstant program = await compileTestScript( + 'number_value', + 'number_isFinite_2.beize', + ); test('$title - Channel', () async { final List expected = ['false']; diff --git a/packages/beize_compiler/tests/number_value/number_isInfinite_1_test.dart b/packages/beize_compiler/tests/number_value/number_isInfinite_1_test.dart index e73cd5a..95aefbc 100644 --- a/packages/beize_compiler/tests/number_value/number_isInfinite_1_test.dart +++ b/packages/beize_compiler/tests/number_value/number_isInfinite_1_test.dart @@ -3,35 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] Number (1)'; - final BeizeProgramConstant program = - await compileTestScript('number_value', 'number_isInfinite_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'isInfinite'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] Number.IsInfinite (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'number_value', + 'number_isInfinite_1.beize', + ); test('$title - Channel', () async { final List expected = ['false']; diff --git a/packages/beize_compiler/tests/number_value/number_isInfinite_2_test.dart b/packages/beize_compiler/tests/number_value/number_isInfinite_2_test.dart index a9751ef..4e0043e 100644 --- a/packages/beize_compiler/tests/number_value/number_isInfinite_2_test.dart +++ b/packages/beize_compiler/tests/number_value/number_isInfinite_2_test.dart @@ -3,38 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] Number (2)'; - final BeizeProgramConstant program = - await compileTestScript('number_value', 'number_isInfinite_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'Number'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'infinity'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'isInfinite'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] Number.IsInfinite (2)'; + final BeizeProgramConstant program = await compileTestScript( + 'number_value', + 'number_isInfinite_2.beize', + ); test('$title - Channel', () async { final List expected = ['true']; diff --git a/packages/beize_compiler/tests/number_value/number_isNaN_1_test.dart b/packages/beize_compiler/tests/number_value/number_isNaN_1_test.dart index 00d0d3b..a4d52ab 100644 --- a/packages/beize_compiler/tests/number_value/number_isNaN_1_test.dart +++ b/packages/beize_compiler/tests/number_value/number_isNaN_1_test.dart @@ -3,35 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] Number (1)'; - final BeizeProgramConstant program = - await compileTestScript('number_value', 'number_isNaN_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'isNaN'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] Number.IsNaN (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'number_value', + 'number_isNaN_1.beize', + ); test('$title - Channel', () async { final List expected = ['false']; diff --git a/packages/beize_compiler/tests/number_value/number_isNaN_2_test.dart b/packages/beize_compiler/tests/number_value/number_isNaN_2_test.dart index 815b684..63405a8 100644 --- a/packages/beize_compiler/tests/number_value/number_isNaN_2_test.dart +++ b/packages/beize_compiler/tests/number_value/number_isNaN_2_test.dart @@ -3,38 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] Number (2)'; - final BeizeProgramConstant program = - await compileTestScript('number_value', 'number_isNaN_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'Number'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'NaN'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'isNaN'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] Number.IsNaN (2)'; + final BeizeProgramConstant program = await compileTestScript( + 'number_value', + 'number_isNaN_2.beize', + ); test('$title - Channel', () async { final List expected = ['true']; diff --git a/packages/beize_compiler/tests/number_value/number_isNegative_1_test.dart b/packages/beize_compiler/tests/number_value/number_isNegative_1_test.dart index 1e1c74d..6e55b0f 100644 --- a/packages/beize_compiler/tests/number_value/number_isNegative_1_test.dart +++ b/packages/beize_compiler/tests/number_value/number_isNegative_1_test.dart @@ -3,36 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] Number (1)'; - final BeizeProgramConstant program = - await compileTestScript('number_value', 'number_isNegative_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opNegate); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'isNegative'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] Number.IsNegative (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'number_value', + 'number_isNegative_1.beize', + ); test('$title - Channel', () async { final List expected = ['true']; diff --git a/packages/beize_compiler/tests/number_value/number_round_1_test.dart b/packages/beize_compiler/tests/number_value/number_round_1_test.dart index e842053..091ac7c 100644 --- a/packages/beize_compiler/tests/number_value/number_round_1_test.dart +++ b/packages/beize_compiler/tests/number_value/number_round_1_test.dart @@ -3,35 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] Number (1)'; - final BeizeProgramConstant program = - await compileTestScript('number_value', 'number_round_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 1.1); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'round'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] Number.Round (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'number_value', + 'number_round_1.beize', + ); test('$title - Channel', () async { final List expected = ['1']; diff --git a/packages/beize_compiler/tests/number_value/number_sign_1_test.dart b/packages/beize_compiler/tests/number_value/number_sign_1_test.dart index df977e8..8259350 100644 --- a/packages/beize_compiler/tests/number_value/number_sign_1_test.dart +++ b/packages/beize_compiler/tests/number_value/number_sign_1_test.dart @@ -3,36 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] Number (1)'; - final BeizeProgramConstant program = - await compileTestScript('number_value', 'number_sign_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opNegate); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'sign'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] Number.Sign (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'number_value', + 'number_sign_1.beize', + ); test('$title - Channel', () async { final List expected = ['-1']; diff --git a/packages/beize_compiler/tests/number_value/number_sign_2_test.dart b/packages/beize_compiler/tests/number_value/number_sign_2_test.dart index af27361..ee04f9d 100644 --- a/packages/beize_compiler/tests/number_value/number_sign_2_test.dart +++ b/packages/beize_compiler/tests/number_value/number_sign_2_test.dart @@ -3,35 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] Number (2)'; - final BeizeProgramConstant program = - await compileTestScript('number_value', 'number_sign_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'sign'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] Number.Sign (2)'; + final BeizeProgramConstant program = await compileTestScript( + 'number_value', + 'number_sign_2.beize', + ); test('$title - Channel', () async { final List expected = ['1']; diff --git a/packages/beize_compiler/tests/number_value/number_toPrecisionString_1_test.dart b/packages/beize_compiler/tests/number_value/number_toPrecisionString_1_test.dart index 068ab4b..49ae27f 100644 --- a/packages/beize_compiler/tests/number_value/number_toPrecisionString_1_test.dart +++ b/packages/beize_compiler/tests/number_value/number_toPrecisionString_1_test.dart @@ -3,37 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] Number (1)'; + const String title = '[Value] Number.ToPrecisionString (1)'; final BeizeProgramConstant program = await compileTestScript( - 'number_value', 'number_toPrecisionString_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 5.2512); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'toPrecisionString'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 3.0); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'number_value', + 'number_toPrecisionString_1.beize', + ); test('$title - Channel', () async { final List expected = ['5.25']; diff --git a/packages/beize_compiler/tests/number_value/number_toRadixString_1_test.dart b/packages/beize_compiler/tests/number_value/number_toRadixString_1_test.dart index c535fbd..9c6af6f 100644 --- a/packages/beize_compiler/tests/number_value/number_toRadixString_1_test.dart +++ b/packages/beize_compiler/tests/number_value/number_toRadixString_1_test.dart @@ -3,37 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] Number (1)'; - final BeizeProgramConstant program = - await compileTestScript('number_value', 'number_toRadixString_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 5.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'toRadixString'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 2.0); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] Number.ToRadixString (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'number_value', + 'number_toRadixString_1.beize', + ); test('$title - Channel', () async { final List expected = ['101']; diff --git a/packages/beize_compiler/tests/number_value/number_truncate_1_test.dart b/packages/beize_compiler/tests/number_value/number_truncate_1_test.dart index 479347d..88472f5 100644 --- a/packages/beize_compiler/tests/number_value/number_truncate_1_test.dart +++ b/packages/beize_compiler/tests/number_value/number_truncate_1_test.dart @@ -3,35 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] Number (1)'; - final BeizeProgramConstant program = - await compileTestScript('number_value', 'number_truncate_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 1.1); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'truncate'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] Number.Truncate (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'number_value', + 'number_truncate_1.beize', + ); test('$title - Channel', () async { final List expected = ['1']; diff --git a/packages/beize_compiler/tests/object_value/object_1_test.dart b/packages/beize_compiler/tests/object_value/object_1_test.dart index 265e33c..79db117 100644 --- a/packages/beize_compiler/tests/object_value/object_1_test.dart +++ b/packages/beize_compiler/tests/object_value/object_1_test.dart @@ -4,30 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Value] Object (1)'; - final BeizeProgramConstant program = - await compileTestScript('object_value', 'object_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opObject); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'typeof'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'object_value', + 'object_1.beize', + ); test('$title - Channel', () async { final List expected = ['Object']; diff --git a/packages/beize_compiler/tests/object_value/object_2_test.dart b/packages/beize_compiler/tests/object_value/object_2_test.dart index 6db64d8..39424dc 100644 --- a/packages/beize_compiler/tests/object_value/object_2_test.dart +++ b/packages/beize_compiler/tests/object_value/object_2_test.dart @@ -4,29 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Value] Object (2)'; - final BeizeProgramConstant program = - await compileTestScript('object_value', 'object_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opObject); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'object_value', + 'object_2.beize', + ); test('$title - Channel', () async { final List expected = ['{}']; diff --git a/packages/beize_compiler/tests/remainder_assignment_operator/remainder_assignment_1_test.dart b/packages/beize_compiler/tests/remainder_assignment_operator/remainder_assignment_1_test.dart index 86e4947..897bc0d 100644 --- a/packages/beize_compiler/tests/remainder_assignment_operator/remainder_assignment_1_test.dart +++ b/packages/beize_compiler/tests/remainder_assignment_operator/remainder_assignment_1_test.dart @@ -5,36 +5,9 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Remainder Assignment (1)'; final BeizeProgramConstant program = await compileTestScript( - 'remainder_assignment_operator', 'remainder_assignment_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 10.0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 3.0); - expectedChunk.addOpCode(BeizeOpCodes.opModulo); - expectedChunk.addOpCode(BeizeOpCodes.opAssign); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'remainder_assignment_operator', + 'remainder_assignment_1.beize', + ); test('$title - Channel', () async { final List expected = ['1']; diff --git a/packages/beize_compiler/tests/remainder_operator/remainder_1_test.dart b/packages/beize_compiler/tests/remainder_operator/remainder_1_test.dart index 44d0ce3..fd9f146 100644 --- a/packages/beize_compiler/tests/remainder_operator/remainder_1_test.dart +++ b/packages/beize_compiler/tests/remainder_operator/remainder_1_test.dart @@ -4,32 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Remainder (1)'; - final BeizeProgramConstant program = - await compileTestScript('remainder_operator', 'remainder_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 10.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 3.0); - expectedChunk.addOpCode(BeizeOpCodes.opModulo); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'remainder_operator', + 'remainder_1.beize', + ); test('$title - Channel', () async { final List expected = ['1']; diff --git a/packages/beize_compiler/tests/return_statement/return_1_test.dart b/packages/beize_compiler/tests/return_statement/return_1_test.dart index 934e8f7..41e9d95 100644 --- a/packages/beize_compiler/tests/return_statement/return_1_test.dart +++ b/packages/beize_compiler/tests/return_statement/return_1_test.dart @@ -4,34 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Statement] Return (1)'; - final BeizeProgramConstant program = - await compileTestScript('return_statement', 'return_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - final BeizeTestProgram expectedChunk_0 = BeizeTestProgram(); - expectedChunk_0.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk_0.addOpCode(BeizeOpCodes.opConstant); - expectedChunk_0.addConstant(0, 'c-0'); - expectedChunk_0.addOpCode(BeizeOpCodes.opReturn); - expectedChunk_0.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addConstant(1, expectedChunk_0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'fn'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'fn'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'return_statement', + 'return_1.beize', + ); test('$title - Channel', () async { final List expected = ['c-0']; diff --git a/packages/beize_compiler/tests/return_statement/return_2_test.dart b/packages/beize_compiler/tests/return_statement/return_2_test.dart index 5dc7cef..7d02cd7 100644 --- a/packages/beize_compiler/tests/return_statement/return_2_test.dart +++ b/packages/beize_compiler/tests/return_statement/return_2_test.dart @@ -4,36 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Statement] Return (2)'; - final BeizeProgramConstant program = - await compileTestScript('return_statement', 'return_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - final BeizeTestProgram expectedChunk_0 = BeizeTestProgram(); - expectedChunk_0.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk_0.addOpCode(BeizeOpCodes.opNull); - expectedChunk_0.addOpCode(BeizeOpCodes.opReturn); - expectedChunk_0.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addConstant(1, expectedChunk_0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'fn'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'c-'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'fn'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'return_statement', + 'return_2.beize', + ); test('$title - Channel', () async { final List expected = ['c-null']; diff --git a/packages/beize_compiler/tests/string_native/string_1.beize b/packages/beize_compiler/tests/string_native/string_1.beize new file mode 100644 index 0000000..0962a27 --- /dev/null +++ b/packages/beize_compiler/tests/string_native/string_1.beize @@ -0,0 +1,2 @@ +result := String.fromCodeUnit(72); +out(result); diff --git a/packages/beize_compiler/tests/string_native/string_1_test.dart b/packages/beize_compiler/tests/string_native/string_1_test.dart new file mode 100644 index 0000000..bc9fba9 --- /dev/null +++ b/packages/beize_compiler/tests/string_native/string_1_test.dart @@ -0,0 +1,17 @@ +import 'package:beize_compiler/beize_compiler.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; + +Future main() async { + const String title = '[Native] String (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'string_native', + 'string_1.beize', + ); + + test('$title - Channel', () async { + final List expected = ['H']; + final List actual = await executeTestScript(program); + expect(actual, orderedEquals(expected)); + }); +} diff --git a/packages/beize_compiler/tests/string_native/string_fromCodeUnit_1_test.dart b/packages/beize_compiler/tests/string_native/string_fromCodeUnit_1_test.dart index 8741c6f..e47c6d0 100644 --- a/packages/beize_compiler/tests/string_native/string_fromCodeUnit_1_test.dart +++ b/packages/beize_compiler/tests/string_native/string_fromCodeUnit_1_test.dart @@ -3,34 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Native] String (1)'; - final BeizeProgramConstant program = - await compileTestScript('string_native', 'string_fromCodeUnit_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'String'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'fromCodeUnit'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 72.0); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Native] String.FromCodeUnit (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'string_native', + 'string_fromCodeUnit_1.beize', + ); test('$title - Channel', () async { final List expected = ['H']; diff --git a/packages/beize_compiler/tests/string_native/string_fromCodeUnits_1_test.dart b/packages/beize_compiler/tests/string_native/string_fromCodeUnits_1_test.dart index 9c2af89..360a42a 100644 --- a/packages/beize_compiler/tests/string_native/string_fromCodeUnits_1_test.dart +++ b/packages/beize_compiler/tests/string_native/string_fromCodeUnits_1_test.dart @@ -3,44 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Native] String (1)'; - final BeizeProgramConstant program = - await compileTestScript('string_native', 'string_fromCodeUnits_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'String'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'fromCodeUnits'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 72.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 101.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, 108.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, 108.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(6, 111.0); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(5); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(7, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Native] String.FromCodeUnits (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'string_native', + 'string_fromCodeUnits_1.beize', + ); test('$title - Channel', () async { final List expected = ['Hello']; diff --git a/packages/beize_compiler/tests/string_native/string_from_1.beize b/packages/beize_compiler/tests/string_native/string_from_1.beize deleted file mode 100644 index 3d093bf..0000000 --- a/packages/beize_compiler/tests/string_native/string_from_1.beize +++ /dev/null @@ -1,2 +0,0 @@ -result := String.from([1, 2, 3]); -out(result); diff --git a/packages/beize_compiler/tests/string_native/string_from_1_test.dart b/packages/beize_compiler/tests/string_native/string_from_1_test.dart deleted file mode 100644 index 1615d07..0000000 --- a/packages/beize_compiler/tests/string_native/string_from_1_test.dart +++ /dev/null @@ -1,46 +0,0 @@ -import 'package:beize_compiler/beize_compiler.dart'; -import 'package:test/test.dart'; -import '../utils.dart'; - -Future main() async { - const String title = '[Native] String (1)'; - final BeizeProgramConstant program = - await compileTestScript('string_native', 'string_from_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'String'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'from'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 2.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, 3.0); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(3); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(6, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); - - test('$title - Channel', () async { - final List expected = ['[1, 2, 3]']; - final List actual = await executeTestScript(program); - expect(actual, orderedEquals(expected)); - }); -} diff --git a/packages/beize_compiler/tests/string_value/string_1_test.dart b/packages/beize_compiler/tests/string_value/string_1_test.dart index aad380c..e2e00c1 100644 --- a/packages/beize_compiler/tests/string_value/string_1_test.dart +++ b/packages/beize_compiler/tests/string_value/string_1_test.dart @@ -4,26 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Value] String (1)'; - final BeizeProgramConstant program = - await compileTestScript('string_value', 'string_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'string_value', + 'string_1.beize', + ); test('$title - Channel', () async { final List expected = ['c-0']; diff --git a/packages/beize_compiler/tests/string_value/string_2_test.dart b/packages/beize_compiler/tests/string_value/string_2_test.dart index 0978566..c918afe 100644 --- a/packages/beize_compiler/tests/string_value/string_2_test.dart +++ b/packages/beize_compiler/tests/string_value/string_2_test.dart @@ -4,30 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Value] String (2)'; - final BeizeProgramConstant program = - await compileTestScript('string_value', 'string_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, ''); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'typeof'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'string_value', + 'string_2.beize', + ); test('$title - Channel', () async { final List expected = ['String']; diff --git a/packages/beize_compiler/tests/string_value/string_codeUnitAt_1_test.dart b/packages/beize_compiler/tests/string_value/string_codeUnitAt_1_test.dart index ad8b3e2..7fa4aba 100644 --- a/packages/beize_compiler/tests/string_value/string_codeUnitAt_1_test.dart +++ b/packages/beize_compiler/tests/string_value/string_codeUnitAt_1_test.dart @@ -3,37 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] String (1)'; - final BeizeProgramConstant program = - await compileTestScript('string_value', 'string_codeUnitAt_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'Hello!'); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 'codeUnitAt'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] String.CodeUnitAt (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'string_value', + 'string_codeUnitAt_1.beize', + ); test('$title - Channel', () async { final List expected = ['101']; diff --git a/packages/beize_compiler/tests/string_value/string_compareTo_1_test.dart b/packages/beize_compiler/tests/string_value/string_compareTo_1_test.dart index b2fcaac..11d901f 100644 --- a/packages/beize_compiler/tests/string_value/string_compareTo_1_test.dart +++ b/packages/beize_compiler/tests/string_value/string_compareTo_1_test.dart @@ -3,42 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] String (1)'; - final BeizeProgramConstant program = - await compileTestScript('string_value', 'string_compareTo_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'Hello'); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'str1'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'World'); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(2, 'str2'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'str1'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(6, 'compareTo'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'str2'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] String.CompareTo (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'string_value', + 'string_compareTo_1.beize', + ); test('$title - Channel', () async { final List expected = ['-1']; diff --git a/packages/beize_compiler/tests/string_value/string_contains_1_test.dart b/packages/beize_compiler/tests/string_value/string_contains_1_test.dart index 13d8d9f..5034786 100644 --- a/packages/beize_compiler/tests/string_value/string_contains_1_test.dart +++ b/packages/beize_compiler/tests/string_value/string_contains_1_test.dart @@ -3,37 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] String (1)'; - final BeizeProgramConstant program = - await compileTestScript('string_value', 'string_contains_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'Hello'); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 'contains'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, 'Hell'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] String.Contains (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'string_value', + 'string_contains_1.beize', + ); test('$title - Channel', () async { final List expected = ['true']; diff --git a/packages/beize_compiler/tests/string_value/string_endsWith_1_test.dart b/packages/beize_compiler/tests/string_value/string_endsWith_1_test.dart index 2c6fe97..e857fa4 100644 --- a/packages/beize_compiler/tests/string_value/string_endsWith_1_test.dart +++ b/packages/beize_compiler/tests/string_value/string_endsWith_1_test.dart @@ -3,37 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] String (1)'; - final BeizeProgramConstant program = - await compileTestScript('string_value', 'string_endsWith_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'Hello'); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 'endsWith'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, 'llo'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] String.EndsWith (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'string_value', + 'string_endsWith_1.beize', + ); test('$title - Channel', () async { final List expected = ['true']; diff --git a/packages/beize_compiler/tests/string_value/string_format_1_test.dart b/packages/beize_compiler/tests/string_value/string_format_1_test.dart index 9a4597c..3bae114 100644 --- a/packages/beize_compiler/tests/string_value/string_format_1_test.dart +++ b/packages/beize_compiler/tests/string_value/string_format_1_test.dart @@ -3,38 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] String (1)'; - final BeizeProgramConstant program = - await compileTestScript('string_value', 'string_format_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, '{} {}'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'format'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'Hello'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 'World!'); - expectedChunk.addOpCode(BeizeOpCodes.opList); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(5, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] String.Format (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'string_value', + 'string_format_1.beize', + ); test('$title - Channel', () async { final List expected = ['Hello World!']; diff --git a/packages/beize_compiler/tests/string_value/string_indexOf_1_test.dart b/packages/beize_compiler/tests/string_value/string_indexOf_1_test.dart index 7c8cb17..2c4b89a 100644 --- a/packages/beize_compiler/tests/string_value/string_indexOf_1_test.dart +++ b/packages/beize_compiler/tests/string_value/string_indexOf_1_test.dart @@ -3,37 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] String (1)'; - final BeizeProgramConstant program = - await compileTestScript('string_value', 'string_indexOf_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'Hello'); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 'indexOf'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, 'e'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] String.IndexOf (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'string_value', + 'string_indexOf_1.beize', + ); test('$title - Channel', () async { final List expected = ['1']; diff --git a/packages/beize_compiler/tests/string_value/string_isEmpty_1_test.dart b/packages/beize_compiler/tests/string_value/string_isEmpty_1_test.dart index 39804a5..9915e63 100644 --- a/packages/beize_compiler/tests/string_value/string_isEmpty_1_test.dart +++ b/packages/beize_compiler/tests/string_value/string_isEmpty_1_test.dart @@ -3,35 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] String (1)'; - final BeizeProgramConstant program = - await compileTestScript('string_value', 'string_isEmpty_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, ''); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'isEmpty'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] String.IsEmpty (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'string_value', + 'string_isEmpty_1.beize', + ); test('$title - Channel', () async { final List expected = ['true']; diff --git a/packages/beize_compiler/tests/string_value/string_isNotEmpty_1_test.dart b/packages/beize_compiler/tests/string_value/string_isNotEmpty_1_test.dart index 6d4a18a..199640e 100644 --- a/packages/beize_compiler/tests/string_value/string_isNotEmpty_1_test.dart +++ b/packages/beize_compiler/tests/string_value/string_isNotEmpty_1_test.dart @@ -3,35 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] String (1)'; - final BeizeProgramConstant program = - await compileTestScript('string_value', 'string_isNotEmpty_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 'isNotEmpty'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] String.IsNotEmpty (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'string_value', + 'string_isNotEmpty_1.beize', + ); test('$title - Channel', () async { final List expected = ['true']; diff --git a/packages/beize_compiler/tests/string_value/string_length_1_test.dart b/packages/beize_compiler/tests/string_value/string_length_1_test.dart index b00b0ae..7a272d4 100644 --- a/packages/beize_compiler/tests/string_value/string_length_1_test.dart +++ b/packages/beize_compiler/tests/string_value/string_length_1_test.dart @@ -3,35 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] String (1)'; - final BeizeProgramConstant program = - await compileTestScript('string_value', 'string_length_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 'length'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] String.Length (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'string_value', + 'string_length_1.beize', + ); test('$title - Channel', () async { final List expected = ['3']; diff --git a/packages/beize_compiler/tests/string_value/string_padLeft_1_test.dart b/packages/beize_compiler/tests/string_value/string_padLeft_1_test.dart index f23281c..e7d474f 100644 --- a/packages/beize_compiler/tests/string_value/string_padLeft_1_test.dart +++ b/packages/beize_compiler/tests/string_value/string_padLeft_1_test.dart @@ -3,39 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] String (1)'; - final BeizeProgramConstant program = - await compileTestScript('string_value', 'string_padLeft_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, '1'); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 'padLeft'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, 2.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(6, '0'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] String.PadLeft (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'string_value', + 'string_padLeft_1.beize', + ); test('$title - Channel', () async { final List expected = ['01']; diff --git a/packages/beize_compiler/tests/string_value/string_padRight_1_test.dart b/packages/beize_compiler/tests/string_value/string_padRight_1_test.dart index c4c446e..7519414 100644 --- a/packages/beize_compiler/tests/string_value/string_padRight_1_test.dart +++ b/packages/beize_compiler/tests/string_value/string_padRight_1_test.dart @@ -3,39 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] String (1)'; - final BeizeProgramConstant program = - await compileTestScript('string_value', 'string_padRight_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, '1'); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 'padRight'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, 2.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(6, '0'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] String.PadRight (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'string_value', + 'string_padRight_1.beize', + ); test('$title - Channel', () async { final List expected = ['10']; diff --git a/packages/beize_compiler/tests/string_value/string_replaceAllMapped_1_test.dart b/packages/beize_compiler/tests/string_value/string_replaceAllMapped_1_test.dart index 62d6b1a..3a7af94 100644 --- a/packages/beize_compiler/tests/string_value/string_replaceAllMapped_1_test.dart +++ b/packages/beize_compiler/tests/string_value/string_replaceAllMapped_1_test.dart @@ -3,48 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] String (1)'; + const String title = '[Value] String.replaceAllMapped (1)'; final BeizeProgramConstant program = await compileTestScript( - 'string_value', 'string_replaceAllMapped_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'Hello'); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 'replaceAllMapped'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, 'l'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - final BeizeTestProgram expectedChunk_0 = BeizeTestProgram(); - expectedChunk_0.addOpCode(BeizeOpCodes.opLookup); - expectedChunk_0.addConstant(0, 'x'); - expectedChunk_0.addOpCode(BeizeOpCodes.opConstant); - expectedChunk_0.addConstant(1, 'toUpperCase'); - expectedChunk_0.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk_0.addOpCode(BeizeOpCodes.opCall); - expectedChunk_0.addCode(0); - expectedChunk_0.addOpCode(BeizeOpCodes.opReturn); - expectedChunk.addConstant(6, expectedChunk_0); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'string_value', + 'string_replaceAllMapped_1.beize', + ); test('$title - Channel', () async { final List expected = ['HeLLo']; diff --git a/packages/beize_compiler/tests/string_value/string_replaceAll_1_test.dart b/packages/beize_compiler/tests/string_value/string_replaceAll_1_test.dart index 2129784..550ece0 100644 --- a/packages/beize_compiler/tests/string_value/string_replaceAll_1_test.dart +++ b/packages/beize_compiler/tests/string_value/string_replaceAll_1_test.dart @@ -3,39 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] String (1)'; - final BeizeProgramConstant program = - await compileTestScript('string_value', 'string_replaceAll_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'Hello'); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 'replaceAll'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, 'l'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(6, 'e'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] String.ReplaceAll (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'string_value', + 'string_replaceAll_1.beize', + ); test('$title - Channel', () async { final List expected = ['Heeeo']; diff --git a/packages/beize_compiler/tests/string_value/string_replaceFirstMapped_1_test.dart b/packages/beize_compiler/tests/string_value/string_replaceFirstMapped_1_test.dart index a07092f..0ce179f 100644 --- a/packages/beize_compiler/tests/string_value/string_replaceFirstMapped_1_test.dart +++ b/packages/beize_compiler/tests/string_value/string_replaceFirstMapped_1_test.dart @@ -3,48 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] String (1)'; + const String title = '[Value] String.ReplaceFirstMapped (1)'; final BeizeProgramConstant program = await compileTestScript( - 'string_value', 'string_replaceFirstMapped_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'Hello'); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 'replaceFirstMapped'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, 'l'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - final BeizeTestProgram expectedChunk_0 = BeizeTestProgram(); - expectedChunk_0.addOpCode(BeizeOpCodes.opLookup); - expectedChunk_0.addConstant(0, 'x'); - expectedChunk_0.addOpCode(BeizeOpCodes.opConstant); - expectedChunk_0.addConstant(1, 'toUpperCase'); - expectedChunk_0.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk_0.addOpCode(BeizeOpCodes.opCall); - expectedChunk_0.addCode(0); - expectedChunk_0.addOpCode(BeizeOpCodes.opReturn); - expectedChunk.addConstant(6, expectedChunk_0); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'string_value', + 'string_replaceFirstMapped_1.beize', + ); test('$title - Channel', () async { final List expected = ['HeLlo']; diff --git a/packages/beize_compiler/tests/string_value/string_replaceFirst_1_test.dart b/packages/beize_compiler/tests/string_value/string_replaceFirst_1_test.dart index a9a4a9f..235a62b 100644 --- a/packages/beize_compiler/tests/string_value/string_replaceFirst_1_test.dart +++ b/packages/beize_compiler/tests/string_value/string_replaceFirst_1_test.dart @@ -3,39 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] String (1)'; - final BeizeProgramConstant program = - await compileTestScript('string_value', 'string_replaceFirst_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'Hello'); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 'replaceFirst'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, 'l'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(6, 'e'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] String.ReplaceFirst (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'string_value', + 'string_replaceFirst_1.beize', + ); test('$title - Channel', () async { final List expected = ['Heelo']; diff --git a/packages/beize_compiler/tests/string_value/string_split_1_test.dart b/packages/beize_compiler/tests/string_value/string_split_1_test.dart index 178ce61..799dea0 100644 --- a/packages/beize_compiler/tests/string_value/string_split_1_test.dart +++ b/packages/beize_compiler/tests/string_value/string_split_1_test.dart @@ -3,47 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] String (1)'; - final BeizeProgramConstant program = - await compileTestScript('string_value', 'string_split_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'Hello!'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'split'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'll'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, 0.0); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(6, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] String.Split (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'string_value', + 'string_split_1.beize', + ); test('$title - Channel', () async { final List expected = ['He', 'o!']; diff --git a/packages/beize_compiler/tests/string_value/string_startsWith_1_test.dart b/packages/beize_compiler/tests/string_value/string_startsWith_1_test.dart index bfc0906..5f1de03 100644 --- a/packages/beize_compiler/tests/string_value/string_startsWith_1_test.dart +++ b/packages/beize_compiler/tests/string_value/string_startsWith_1_test.dart @@ -3,37 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] String (1)'; - final BeizeProgramConstant program = - await compileTestScript('string_value', 'string_startsWith_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'Hello'); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 'startsWith'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, 'Hell'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] String.StartsWith (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'string_value', + 'string_startsWith_1.beize', + ); test('$title - Channel', () async { final List expected = ['true']; diff --git a/packages/beize_compiler/tests/string_value/string_substring_1_test.dart b/packages/beize_compiler/tests/string_value/string_substring_1_test.dart index 4920687..299a3a6 100644 --- a/packages/beize_compiler/tests/string_value/string_substring_1_test.dart +++ b/packages/beize_compiler/tests/string_value/string_substring_1_test.dart @@ -3,39 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] String (1)'; - final BeizeProgramConstant program = - await compileTestScript('string_value', 'string_substring_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'Hello World!'); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 'substring'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, 6.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(6, 11.0); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] String.Substring (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'string_value', + 'string_substring_1.beize', + ); test('$title - Channel', () async { final List expected = ['World']; diff --git a/packages/beize_compiler/tests/string_value/string_toCodeUnits_1_test.dart b/packages/beize_compiler/tests/string_value/string_toCodeUnits_1_test.dart index 6985234..8928692 100644 --- a/packages/beize_compiler/tests/string_value/string_toCodeUnits_1_test.dart +++ b/packages/beize_compiler/tests/string_value/string_toCodeUnits_1_test.dart @@ -3,39 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] String (1)'; - final BeizeProgramConstant program = - await compileTestScript('string_value', 'string_toCodeUnits_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'Hello!'); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'toCodeUnits'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 'join'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, ', '); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] String.ToCodeUnits (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'string_value', + 'string_toCodeUnits_1.beize', + ); test('$title - Channel', () async { final List expected = ['72, 101, 108, 108, 111, 33']; diff --git a/packages/beize_compiler/tests/string_value/string_toLowerCase_1_test.dart b/packages/beize_compiler/tests/string_value/string_toLowerCase_1_test.dart index d3bb90a..22997c3 100644 --- a/packages/beize_compiler/tests/string_value/string_toLowerCase_1_test.dart +++ b/packages/beize_compiler/tests/string_value/string_toLowerCase_1_test.dart @@ -3,32 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] String (1)'; - final BeizeProgramConstant program = - await compileTestScript('string_value', 'string_toLowerCase_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'Hello'); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'toLowerCase'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] String.ToLowerCase (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'string_value', + 'string_toLowerCase_1.beize', + ); test('$title - Channel', () async { final List expected = ['hello']; diff --git a/packages/beize_compiler/tests/string_value/string_toUpperCase_1_test.dart b/packages/beize_compiler/tests/string_value/string_toUpperCase_1_test.dart index 8920c1e..c23abc3 100644 --- a/packages/beize_compiler/tests/string_value/string_toUpperCase_1_test.dart +++ b/packages/beize_compiler/tests/string_value/string_toUpperCase_1_test.dart @@ -3,32 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] String (1)'; - final BeizeProgramConstant program = - await compileTestScript('string_value', 'string_toUpperCase_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'Hello'); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'toUpperCase'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] String.ToUpperCase (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'string_value', + 'string_toUpperCase_1.beize', + ); test('$title - Channel', () async { final List expected = ['HELLO']; diff --git a/packages/beize_compiler/tests/string_value/string_trimLeft_1_test.dart b/packages/beize_compiler/tests/string_value/string_trimLeft_1_test.dart index 21fc559..84e3896 100644 --- a/packages/beize_compiler/tests/string_value/string_trimLeft_1_test.dart +++ b/packages/beize_compiler/tests/string_value/string_trimLeft_1_test.dart @@ -3,35 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] String (1)'; - final BeizeProgramConstant program = - await compileTestScript('string_value', 'string_trimLeft_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, ' Hello '); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 'trimLeft'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] String.TrimLeft (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'string_value', + 'string_trimLeft_1.beize', + ); test('$title - Channel', () async { final List expected = ['Hello ']; diff --git a/packages/beize_compiler/tests/string_value/string_trimRight_1_test.dart b/packages/beize_compiler/tests/string_value/string_trimRight_1_test.dart index d95caa4..256f3ad 100644 --- a/packages/beize_compiler/tests/string_value/string_trimRight_1_test.dart +++ b/packages/beize_compiler/tests/string_value/string_trimRight_1_test.dart @@ -3,35 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] String (1)'; - final BeizeProgramConstant program = - await compileTestScript('string_value', 'string_trimRight_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, ' Hello '); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 'trimRight'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] String.TrimRight (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'string_value', + 'string_trimRight_1.beize', + ); test('$title - Channel', () async { final List expected = [' Hello']; diff --git a/packages/beize_compiler/tests/string_value/string_trim_1_test.dart b/packages/beize_compiler/tests/string_value/string_trim_1_test.dart index a134313..5aa5fb0 100644 --- a/packages/beize_compiler/tests/string_value/string_trim_1_test.dart +++ b/packages/beize_compiler/tests/string_value/string_trim_1_test.dart @@ -3,35 +3,11 @@ import 'package:test/test.dart'; import '../utils.dart'; Future main() async { - const String title = '[Value] String (1)'; - final BeizeProgramConstant program = - await compileTestScript('string_value', 'string_trim_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, ' Hello '); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 'trim'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + const String title = '[Value] String.Trim (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'string_value', + 'string_trim_1.beize', + ); test('$title - Channel', () async { final List expected = ['Hello']; diff --git a/packages/beize_compiler/tests/subtraction_assignment_operator/subtraction_assignment_1_test.dart b/packages/beize_compiler/tests/subtraction_assignment_operator/subtraction_assignment_1_test.dart index 1173b6c..8f902e5 100644 --- a/packages/beize_compiler/tests/subtraction_assignment_operator/subtraction_assignment_1_test.dart +++ b/packages/beize_compiler/tests/subtraction_assignment_operator/subtraction_assignment_1_test.dart @@ -5,36 +5,9 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Subtraction Assignment (1)'; final BeizeProgramConstant program = await compileTestScript( - 'subtraction_assignment_operator', 'subtraction_assignment_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 10.0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 7.0); - expectedChunk.addOpCode(BeizeOpCodes.opSubtract); - expectedChunk.addOpCode(BeizeOpCodes.opAssign); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'subtraction_assignment_operator', + 'subtraction_assignment_1.beize', + ); test('$title - Channel', () async { final List expected = ['3']; diff --git a/packages/beize_compiler/tests/subtraction_operator/subtraction_1_test.dart b/packages/beize_compiler/tests/subtraction_operator/subtraction_1_test.dart index dd46552..ddacf70 100644 --- a/packages/beize_compiler/tests/subtraction_operator/subtraction_1_test.dart +++ b/packages/beize_compiler/tests/subtraction_operator/subtraction_1_test.dart @@ -4,32 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Subtraction (1)'; - final BeizeProgramConstant program = - await compileTestScript('subtraction_operator', 'subtraction_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 5.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 3.0); - expectedChunk.addOpCode(BeizeOpCodes.opSubtract); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'subtraction_operator', + 'subtraction_1.beize', + ); test('$title - Channel', () async { final List expected = ['2']; diff --git a/packages/beize_compiler/tests/ternary_operator/ternary_1_test.dart b/packages/beize_compiler/tests/ternary_operator/ternary_1_test.dart index 3387bbb..063dbb3 100644 --- a/packages/beize_compiler/tests/ternary_operator/ternary_1_test.dart +++ b/packages/beize_compiler/tests/ternary_operator/ternary_1_test.dart @@ -4,38 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Ternary (1)'; - final BeizeProgramConstant program = - await compileTestScript('ternary_operator', 'ternary_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opTrue); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(5); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opJump); - expectedChunk.addCode(3); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'ternary_operator', + 'ternary_1.beize', + ); test('$title - Channel', () async { final List expected = ['c-0']; diff --git a/packages/beize_compiler/tests/ternary_operator/ternary_2_test.dart b/packages/beize_compiler/tests/ternary_operator/ternary_2_test.dart index a5249f2..09c65d6 100644 --- a/packages/beize_compiler/tests/ternary_operator/ternary_2_test.dart +++ b/packages/beize_compiler/tests/ternary_operator/ternary_2_test.dart @@ -4,38 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Ternary (2)'; - final BeizeProgramConstant program = - await compileTestScript('ternary_operator', 'ternary_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opFalse); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(5); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opJump); - expectedChunk.addCode(3); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'ternary_operator', + 'ternary_2.beize', + ); test('$title - Channel', () async { final List expected = ['c-1']; diff --git a/packages/beize_compiler/tests/this_operator/this_1_test.dart b/packages/beize_compiler/tests/this_operator/this_1_test.dart index 6617001..11171e1 100644 --- a/packages/beize_compiler/tests/this_operator/this_1_test.dart +++ b/packages/beize_compiler/tests/this_operator/this_1_test.dart @@ -4,46 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] This (1)'; - final BeizeProgramConstant program = - await compileTestScript('this_operator', 'this_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'value'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'getValue'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - final BeizeTestProgram expectedChunk_0 = BeizeTestProgram(); - expectedChunk_0.addOpCode(BeizeOpCodes.opLookup); - expectedChunk_0.addConstant(0, 'this'); - expectedChunk_0.addOpCode(BeizeOpCodes.opConstant); - expectedChunk_0.addConstant(1, 'value'); - expectedChunk_0.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk_0.addOpCode(BeizeOpCodes.opReturn); - expectedChunk.addConstant(4, expectedChunk_0); - expectedChunk.addOpCode(BeizeOpCodes.opObject); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(5, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'getValue'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'this_operator', + 'this_1.beize', + ); test('$title - Channel', () async { final List expected = ['c-0']; diff --git a/packages/beize_compiler/tests/try_catch_statement/try_catch_1.beize b/packages/beize_compiler/tests/try-catch_statement/try-catch_1.beize similarity index 100% rename from packages/beize_compiler/tests/try_catch_statement/try_catch_1.beize rename to packages/beize_compiler/tests/try-catch_statement/try-catch_1.beize diff --git a/packages/beize_compiler/tests/try-catch_statement/try-catch_1_test.dart b/packages/beize_compiler/tests/try-catch_statement/try-catch_1_test.dart new file mode 100644 index 0000000..4644bf5 --- /dev/null +++ b/packages/beize_compiler/tests/try-catch_statement/try-catch_1_test.dart @@ -0,0 +1,17 @@ +import 'package:beize_compiler/beize_compiler.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; + +Future main() async { + const String title = '[Statement] Try-Catch (1)'; + final BeizeProgramConstant program = await compileTestScript( + 'try-catch_statement', + 'try-catch_1.beize', + ); + + test('$title - Channel', () async { + final List expected = ['c-1']; + final List actual = await executeTestScript(program); + expect(actual, orderedEquals(expected)); + }); +} diff --git a/packages/beize_compiler/tests/try_catch_statement/try_catch_2.beize b/packages/beize_compiler/tests/try-catch_statement/try-catch_2.beize similarity index 100% rename from packages/beize_compiler/tests/try_catch_statement/try_catch_2.beize rename to packages/beize_compiler/tests/try-catch_statement/try-catch_2.beize diff --git a/packages/beize_compiler/tests/try-catch_statement/try-catch_2_test.dart b/packages/beize_compiler/tests/try-catch_statement/try-catch_2_test.dart new file mode 100644 index 0000000..79694b7 --- /dev/null +++ b/packages/beize_compiler/tests/try-catch_statement/try-catch_2_test.dart @@ -0,0 +1,17 @@ +import 'package:beize_compiler/beize_compiler.dart'; +import 'package:test/test.dart'; +import '../utils.dart'; + +Future main() async { + const String title = '[Statement] Try-Catch (2)'; + final BeizeProgramConstant program = await compileTestScript( + 'try-catch_statement', + 'try-catch_2.beize', + ); + + test('$title - Channel', () async { + final List expected = ['Test']; + final List actual = await executeTestScript(program); + expect(actual, orderedEquals(expected)); + }); +} diff --git a/packages/beize_compiler/tests/try_catch_statement/try_catch_1_test.dart b/packages/beize_compiler/tests/try_catch_statement/try_catch_1_test.dart deleted file mode 100644 index 910c861..0000000 --- a/packages/beize_compiler/tests/try_catch_statement/try_catch_1_test.dart +++ /dev/null @@ -1,58 +0,0 @@ -import 'package:beize_compiler/beize_compiler.dart'; -import 'package:test/test.dart'; -import '../utils.dart'; - -Future main() async { - const String title = '[Statement] Try-Catch (1)'; - final BeizeProgramConstant program = - await compileTestScript('try_catch_statement', 'try_catch_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opBeginTry); - expectedChunk.addCode(24); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'Exception'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'new'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'Test'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opThrow); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addOpCode(BeizeOpCodes.opEndTry); - expectedChunk.addOpCode(BeizeOpCodes.opJump); - expectedChunk.addCode(13); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(5, '_'); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(6, 'c-1'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); - - test('$title - Channel', () async { - final List expected = ['c-1']; - final List actual = await executeTestScript(program); - expect(actual, orderedEquals(expected)); - }); -} diff --git a/packages/beize_compiler/tests/try_catch_statement/try_catch_2_test.dart b/packages/beize_compiler/tests/try_catch_statement/try_catch_2_test.dart deleted file mode 100644 index dfe3f52..0000000 --- a/packages/beize_compiler/tests/try_catch_statement/try_catch_2_test.dart +++ /dev/null @@ -1,61 +0,0 @@ -import 'package:beize_compiler/beize_compiler.dart'; -import 'package:test/test.dart'; -import '../utils.dart'; - -Future main() async { - const String title = '[Statement] Try-Catch (2)'; - final BeizeProgramConstant program = - await compileTestScript('try_catch_statement', 'try_catch_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opBeginTry); - expectedChunk.addCode(24); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'Exception'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'new'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'Test'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opThrow); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addOpCode(BeizeOpCodes.opEndTry); - expectedChunk.addOpCode(BeizeOpCodes.opJump); - expectedChunk.addCode(16); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(5, 'err'); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(5, 'err'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(6, 'message'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); - - test('$title - Channel', () async { - final List expected = ['Test']; - final List actual = await executeTestScript(program); - expect(actual, orderedEquals(expected)); - }); -} diff --git a/packages/beize_compiler/tests/unary_negation_operator/unary_negation_1_test.dart b/packages/beize_compiler/tests/unary_negation_operator/unary_negation_1_test.dart index 425c865..415d038 100644 --- a/packages/beize_compiler/tests/unary_negation_operator/unary_negation_1_test.dart +++ b/packages/beize_compiler/tests/unary_negation_operator/unary_negation_1_test.dart @@ -5,29 +5,9 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Unary Negation (1)'; final BeizeProgramConstant program = await compileTestScript( - 'unary_negation_operator', 'unary_negation_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opNegate); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'unary_negation_operator', + 'unary_negation_1.beize', + ); test('$title - Channel', () async { final List expected = ['-1']; diff --git a/packages/beize_compiler/tests/unary_negation_operator/unary_negation_2_test.dart b/packages/beize_compiler/tests/unary_negation_operator/unary_negation_2_test.dart index 7a38b81..148e6ca 100644 --- a/packages/beize_compiler/tests/unary_negation_operator/unary_negation_2_test.dart +++ b/packages/beize_compiler/tests/unary_negation_operator/unary_negation_2_test.dart @@ -5,30 +5,9 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Unary Negation (2)'; final BeizeProgramConstant program = await compileTestScript( - 'unary_negation_operator', 'unary_negation_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opNegate); - expectedChunk.addOpCode(BeizeOpCodes.opNegate); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + 'unary_negation_operator', + 'unary_negation_2.beize', + ); test('$title - Channel', () async { final List expected = ['1']; diff --git a/packages/beize_compiler/tests/unary_plus_operator/unary_plus_1_test.dart b/packages/beize_compiler/tests/unary_plus_operator/unary_plus_1_test.dart index eac71ef..f19c3d3 100644 --- a/packages/beize_compiler/tests/unary_plus_operator/unary_plus_1_test.dart +++ b/packages/beize_compiler/tests/unary_plus_operator/unary_plus_1_test.dart @@ -4,29 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Unary Plus (1)'; - final BeizeProgramConstant program = - await compileTestScript('unary_plus_operator', 'unary_plus_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'unary_plus_operator', + 'unary_plus_1.beize', + ); test('$title - Channel', () async { final List expected = ['1']; diff --git a/packages/beize_compiler/tests/unary_plus_operator/unary_plus_2_test.dart b/packages/beize_compiler/tests/unary_plus_operator/unary_plus_2_test.dart index 6b641bc..a851b0e 100644 --- a/packages/beize_compiler/tests/unary_plus_operator/unary_plus_2_test.dart +++ b/packages/beize_compiler/tests/unary_plus_operator/unary_plus_2_test.dart @@ -4,30 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Operator] Unary Plus (2)'; - final BeizeProgramConstant program = - await compileTestScript('unary_plus_operator', 'unary_plus_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opNegate); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'unary_plus_operator', + 'unary_plus_2.beize', + ); test('$title - Channel', () async { final List expected = ['-1']; diff --git a/packages/beize_compiler/tests/unawaited_value/unawaited_1_test.dart b/packages/beize_compiler/tests/unawaited_value/unawaited_1_test.dart index a127ed9..7de9922 100644 --- a/packages/beize_compiler/tests/unawaited_value/unawaited_1_test.dart +++ b/packages/beize_compiler/tests/unawaited_value/unawaited_1_test.dart @@ -4,45 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Value] Unawaited (1)'; - final BeizeProgramConstant program = - await compileTestScript('unawaited_value', 'unawaited_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'Unawaited'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'value'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(5, 'typeof'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAwait); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'unawaited_value', + 'unawaited_1.beize', + ); test('$title - Channel', () async { final List expected = ['Unawaited', 'c-0']; diff --git a/packages/beize_compiler/tests/unawaited_value/unawaited_2_test.dart b/packages/beize_compiler/tests/unawaited_value/unawaited_2_test.dart index eb969a4..6503381 100644 --- a/packages/beize_compiler/tests/unawaited_value/unawaited_2_test.dart +++ b/packages/beize_compiler/tests/unawaited_value/unawaited_2_test.dart @@ -4,36 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Value] Unawaited (2)'; - final BeizeProgramConstant program = - await compileTestScript('unawaited_value', 'unawaited_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(1, 'Unawaited'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 'value'); - expectedChunk.addOpCode(BeizeOpCodes.opGetProperty); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 0.0); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(4, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, ''); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'result'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'unawaited_value', + 'unawaited_2.beize', + ); test('$title - Channel', () async { final List expected = ['']; diff --git a/packages/beize_compiler/tests/utils.dart b/packages/beize_compiler/tests/utils.dart index e609054..9733763 100644 --- a/packages/beize_compiler/tests/utils.dart +++ b/packages/beize_compiler/tests/utils.dart @@ -33,211 +33,3 @@ Future> executeTestScript( await vm.run(); return output; } - -class BeizeTestProgram { - final List modules = []; - final List constants = []; - - BeizeTestChunk addModule( - final int moduleIndex, - final int moduleNameIndex, - final String moduleName, - final int functionIndex, - ) { - int missingCount = moduleIndex - modules.length + 1; - while (missingCount > 0) { - modules.add(0); - missingCount--; - } - modules[moduleIndex] = moduleNameIndex; - final BeizeTestChunk chunk = BeizeTestChunk( - this, - BeizeChunk.empty(moduleIndex), - ); - addConstant(moduleNameIndex, moduleName); - addConstant( - functionIndex, - BeizeFunctionConstant( - isAsync: true, - arguments: [], - chunk: chunk.chunk, - ), - ); - return chunk; - } - - void addConstant(final int code, final BeizeConstant constant) { - int missingCount = code - constants.length + 1; - while (missingCount > 0) { - constants.add(null); - missingCount--; - } - constants[code] = constant; - } -} - -class BeizeTestChunk { - BeizeTestChunk(this.program, this.chunk); - - final BeizeTestProgram program; - final BeizeChunk chunk; - - void addOpCode(final BeizeOpCodes opCode) { - chunk.addOpCode(opCode, 0); - } - - void addCode(final int code) { - chunk.addCode(code, 0); - } - - void addConstant(final int code, final BeizeConstant constant) { - program.addConstant(code, constant); - addCode(code); - } - - List get codes => chunk.codes; -} - -String buildExpectedProgramCode( - final BeizeProgramConstant program, { - final StringBuffer? buffer, -}) { - final StringBuffer output = buffer ?? StringBuffer(); - output.write('final BeizeTestProgram expectedProgram = BeizeTestProgram();'); - for (int i = 0; i < program.modules.length; i++) { - final int moduleNameIndex = program.modules[i]; - final int functionIndex = program.modules[i + 1]; - final String moduleName = program.constantAt(moduleNameIndex) as String; - final BeizeFunctionConstant function = - program.constantAt(functionIndex) as BeizeFunctionConstant; - final String variableName = 'expectedModule$i'; - output.write( - "final BeizeTestChunk $variableName = expectedProgram.addModule($i, $moduleNameIndex, '${escapedString(moduleName, "'")}', $functionIndex);", - ); - buildExpectedChunkCode( - program, - function.chunk, - variableExists: true, - variableName: variableName, - buffer: output, - ); - } - return output.toString().trim(); -} - -String buildExpectedChunkCode( - final BeizeProgramConstant program, - final BeizeChunk chunk, { - final bool variableExists = false, - final String variableName = 'expectedChunk', - final StringBuffer? buffer, -}) { - final StringBuffer output = buffer ?? StringBuffer(); - if (!variableExists) { - output.writeln('final BeizeTestChunk $variableName = BeizeTestChunk();'); - } - int constantVariableCount = 0; - int ip = 0; - while (ip < chunk.codes.length) { - final BeizeOpCodes opCode = chunk.opCodeAt(ip); - int bump = 1; - output.writeln('$variableName.addOpCode(BeizeOpCodes.${opCode.name});'); - switch (opCode) { - case BeizeOpCodes.opConstant: - case BeizeOpCodes.opDeclare: - case BeizeOpCodes.opAssign: - case BeizeOpCodes.opLookup: - final int constantPosition = chunk.codeAt(ip + 1); - final BeizeConstant constant = program.constantAt(constantPosition); - if (constant is BeizeFunctionConstant) { - final String constantVariableName = - '${variableName}_$constantVariableCount'; - buildExpectedChunkCode( - program, - constant.chunk, - variableName: constantVariableName, - buffer: output, - ); - output.writeln( - '$variableName.addConstant($constantPosition, $constantVariableName);', - ); - constantVariableCount++; - } else if (constant is double) { - output.writeln( - '$variableName.addConstant($constantPosition, $constant);', - ); - } else if (constant is String) { - output.writeln( - "$variableName.addConstant($constantPosition, '${escapedString(constant, "'")}');", - ); - } - bump++; - break; - - case BeizeOpCodes.opJump: - case BeizeOpCodes.opJumpIfFalse: - case BeizeOpCodes.opJumpIfNull: - case BeizeOpCodes.opAbsoluteJump: - case BeizeOpCodes.opBeginTry: - case BeizeOpCodes.opCall: - case BeizeOpCodes.opList: - case BeizeOpCodes.opObject: - final int value = chunk.codeAt(ip + 1); - output.writeln('$variableName.addCode($value);'); - bump++; - break; - - case BeizeOpCodes.opImport: - final int moduleIndex = chunk.codeAt(ip + 1); - final int asIndex = chunk.codeAt(ip + 2); - final String name = program.constantAt(asIndex) as String; - output.writeln('$variableName.addCode($moduleIndex);'); - output.writeln("$variableName.addConstant($asIndex, '$name');"); - bump += 2; - break; - - default: - } - ip += bump; - } - return output.toString().trim(); -} - -void printExpectedProgramCode(final BeizeProgramConstant program) { - // ignore: avoid_print - print(buildExpectedProgramCode(program)); -} - -String escapedString(final String value, final String char) => - value.replaceAll(char, '\\$char'); - -typedef BeizeTestComparableProgram = Map; - -// (transpile to) Test-Comparable-Program (from) (Beize)-Chunk -BeizeTestComparableProgram tcpc(final BeizeProgramConstant program) => - transpileTestComparableProgram(program.modules, program.constants); - -// (transpile to) Test-Comparable-Program (from) (Beize)-Test-Chunk -BeizeTestComparableProgram tcptc(final BeizeTestProgram program) => - transpileTestComparableProgram(program.modules, program.constants); - -BeizeTestComparableProgram transpileTestComparableProgram( - final List modules, - final List constants, -) { - final List transpiledConstants = []; - for (final BeizeConstant x in constants) { - if (x is BeizeFunctionConstant) { - transpiledConstants.add({ - 'moduleIndex': x.chunk.moduleIndex, - 'codes': x.chunk.codes, - }); - } else { - transpiledConstants.add(x); - } - } - return { - 'modules': modules, - 'constants': transpiledConstants, - }; -} diff --git a/packages/beize_compiler/tests/when_statement/when_1_test.dart b/packages/beize_compiler/tests/when_statement/when_1_test.dart index 3a2992c..3fc42cd 100644 --- a/packages/beize_compiler/tests/when_statement/when_1_test.dart +++ b/packages/beize_compiler/tests/when_statement/when_1_test.dart @@ -4,47 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Statement] When (1)'; - final BeizeProgramConstant program = - await compileTestScript('when_statement', 'when_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(0, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 0.0); - expectedChunk.addOpCode(BeizeOpCodes.opGreater); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(10); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(33); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(22); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 'c-else'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(33); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'when_statement', + 'when_1.beize', + ); test('$title - Channel', () async { final List expected = ['c-0']; diff --git a/packages/beize_compiler/tests/when_statement/when_2_test.dart b/packages/beize_compiler/tests/when_statement/when_2_test.dart index 745827b..ab4316a 100644 --- a/packages/beize_compiler/tests/when_statement/when_2_test.dart +++ b/packages/beize_compiler/tests/when_statement/when_2_test.dart @@ -4,48 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Statement] When (2)'; - final BeizeProgramConstant program = - await compileTestScript('when_statement', 'when_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(0, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opNegate); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 0.0); - expectedChunk.addOpCode(BeizeOpCodes.opGreater); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(10); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(3, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(34); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(23); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(2, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 'c-else'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(34); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'when_statement', + 'when_2.beize', + ); test('$title - Channel', () async { final List expected = ['c-else']; diff --git a/packages/beize_compiler/tests/when_statement/when_3_test.dart b/packages/beize_compiler/tests/when_statement/when_3_test.dart index 99f4f73..faa12bd 100644 --- a/packages/beize_compiler/tests/when_statement/when_3_test.dart +++ b/packages/beize_compiler/tests/when_statement/when_3_test.dart @@ -4,27 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Statement] When (3)'; - final BeizeProgramConstant program = - await compileTestScript('when_statement', 'when_3.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(2); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-else'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(13); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'when_statement', + 'when_3.beize', + ); test('$title - Channel', () async { final List expected = ['c-else']; diff --git a/packages/beize_compiler/tests/while_statement/while_1_test.dart b/packages/beize_compiler/tests/while_statement/while_1_test.dart index 7dba5be..2860cde 100644 --- a/packages/beize_compiler/tests/while_statement/while_1_test.dart +++ b/packages/beize_compiler/tests/while_statement/while_1_test.dart @@ -4,50 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Statement] While (1)'; - final BeizeProgramConstant program = - await compileTestScript('while_statement', 'while_1.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 0.0); - expectedChunk.addOpCode(BeizeOpCodes.opDeclare); - expectedChunk.addConstant(0, 'i'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'i'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(2, 3.0); - expectedChunk.addOpCode(BeizeOpCodes.opLess); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(23); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(3, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(4, 'c-'); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'i'); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'i'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(5, 1.0); - expectedChunk.addOpCode(BeizeOpCodes.opAdd); - expectedChunk.addOpCode(BeizeOpCodes.opAssign); - expectedChunk.addConstant(0, 'i'); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(5); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'while_statement', + 'while_1.beize', + ); test('$title - Channel', () async { final List expected = ['c-0', 'c-1', 'c-2']; diff --git a/packages/beize_compiler/tests/while_statement/while_2_test.dart b/packages/beize_compiler/tests/while_statement/while_2_test.dart index 1460a96..858e254 100644 --- a/packages/beize_compiler/tests/while_statement/while_2_test.dart +++ b/packages/beize_compiler/tests/while_statement/while_2_test.dart @@ -4,30 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Statement] While (2)'; - final BeizeProgramConstant program = - await compileTestScript('while_statement', 'while_2.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opFalse); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(12); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'while_statement', + 'while_2.beize', + ); test('$title - Channel', () async { final List expected = []; diff --git a/packages/beize_compiler/tests/while_statement/while_3_test.dart b/packages/beize_compiler/tests/while_statement/while_3_test.dart index 6ea1987..81503a7 100644 --- a/packages/beize_compiler/tests/while_statement/while_3_test.dart +++ b/packages/beize_compiler/tests/while_statement/while_3_test.dart @@ -4,32 +4,10 @@ import '../utils.dart'; Future main() async { const String title = '[Statement] While (3)'; - final BeizeProgramConstant program = - await compileTestScript('while_statement', 'while_3.beize'); - - test('$title - Bytecode', () async { - final BeizeChunk chunk = extractChunk(program); - final BeizeTestProgram expectedChunk = BeizeTestProgram(); - expectedChunk.addOpCode(BeizeOpCodes.opTrue); - expectedChunk.addOpCode(BeizeOpCodes.opJumpIfFalse); - expectedChunk.addCode(14); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opBeginScope); - expectedChunk.addOpCode(BeizeOpCodes.opJump); - expectedChunk.addCode(11); - expectedChunk.addOpCode(BeizeOpCodes.opLookup); - expectedChunk.addConstant(0, 'out'); - expectedChunk.addOpCode(BeizeOpCodes.opConstant); - expectedChunk.addConstant(1, 'c-0'); - expectedChunk.addOpCode(BeizeOpCodes.opCall); - expectedChunk.addCode(1); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expectedChunk.addOpCode(BeizeOpCodes.opEndScope); - expectedChunk.addOpCode(BeizeOpCodes.opAbsoluteJump); - expectedChunk.addCode(0); - expectedChunk.addOpCode(BeizeOpCodes.opPop); - expect(tcpc(chunk), tcptc(expectedChunk)); - }); + final BeizeProgramConstant program = await compileTestScript( + 'while_statement', + 'while_3.beize', + ); test('$title - Channel', () async { final List expected = [];