summary refs log tree commit diff stats
path: root/tests/vm
Commit message (Collapse)AuthorAgeFilesLines
* fix #9872: setLen now works properly at CT [backport]Timothee Cour2018-12-081-0/+30
|
* cleanup tests; don't use non-working 'msg' spec fieldAraq2018-11-238-8/+8
|
* more eyewashArne Döring2018-11-231-0/+7
|
* updated tests to be executedArne Döring2018-11-233-7/+12
|
* make run the default action of a test in testerArne Döring2018-11-232-0/+0
|
* Fixes #9671 (#9750)Randy Smith2018-11-191-1/+0
|
* Of operator in vm fixes [backport] (#9717)cooldome2018-11-151-0/+51
| | | | | | * fixes #9701 * fixes #9702 * optimize of statement to bool
* #9348 Merge some small test files (#9561)Ian2018-10-303-27/+30
| | | | * Consolidated types issue tests * Consolidated vm issue tests
* Remove install.txt and readme.txt (#9521)Utwo2018-10-281-2/+2
| | | | | | | | * Remove install.txt and readme.txt * Refactor tests that use readme.txt * Tests open own source code
* Merge pull request #9496 from cooldome/vm_float_castsArne Döring2018-10-281-0/+47
|\ | | | | VM: add int <-> float casts of the same size
| * Add testAndrii Riabushenko2018-10-241-0/+47
| |
* | Improve dumpLisp macro (#9515)Kaushal Modi2018-10-271-7/+7
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Improve dumpLisp macro - Remove commas from the lisp representation of the AST. - Make the dumpLisp output "pretty" and indented. - Improve docs of `dumpTree` and `dumpLisp` macros. With: dumpLisp: echo "Hello, World!" Output before this commit: StmtList(Command(Ident("echo"), StrLit("Hello, World!"))) Output after this commit: (StmtList (Command (Ident "echo") (StrLit "Hello, World!"))) * Re-use the traverse proc inside treeRepr for lispRepr too - Add module-local `treeTraverse` proc. - Also fix treeRepr/dumpTree not printing nnkCommentStmt node contents. * More doc string updates * Allow unindented lispRepr output for tests * Update a test affected by the lispRepr change * Fix dumpTree * Add note about lispRepr and dumpLisp to changelog [ci skip]
* Merge tests into a larger file (part 5 of ∞) (#9368)Miran2018-10-162-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * merge magics * merge metatype tests * merge method tests * merge objects tests * change `import future` to `import sugar` Nim in Action tests are left with `import future`, to ensure compatibility. * merge overload tests * merge proc tests * merge procvar tests * merge range tests * merge seq tests * merge sets tests * remove wrong assert from `tsets3` * fix `jsTests` * better fix
* Field checks for everybody (#8957)LemonBoy2018-10-091-0/+3
| | | | | | | | | | | | | | | | | | | | | * Field checks for JS backend * Clean nkCall nodes with no arguments Generating a nkEmpty in place of no arguments makes no sense form the AST point of view and also trips up the VM codegen. * Field checks for VM backend * Test case for #6612 This patchset fixes #6612 * Add test case for LHS double evaluation * Prevent LHS double-eval for JS backend * Prevent double evaluation in VM backend
* Fix for VM codegen with static[T] typesLemonBoy2018-09-231-0/+10
| | | | Fixes #9043
* Merge pull request #8996 from LemonBoy/fix-2574Andreas Rumpf2018-09-181-0/+14
|\ | | | | The VM cannot call methods
| * The VM cannot call methodsLemonBoy2018-09-171-0/+14
| | | | | | | | Fixes #2574
* | Fix error during field access in VMLemonBoy2018-09-171-0/+17
|/ | | | | | | Tuple constructors can't have nkExprColonExpr but may contain NimNodes of that kind. Fixes #4952
* fixes #8740Araq2018-09-031-0/+15
|
* make tests green againAraq2018-08-131-2/+2
|
* make more tests greenAndreas Rumpf2018-08-133-16/+16
|
* Fix ref bug in vmgen (#8424)Oscar Nihlgård2018-07-301-1/+6
|
* Fix vm regression (#8163)Oscar Nihlgård2018-06-301-0/+13
|
* Fixes #6689 (#8135)Oscar Nihlgård2018-06-301-1/+16
|
* VM regression fixes (#8146)Oscar Nihlgård2018-06-291-1/+31
|
* Merge pull request #8108 from LemonBoy/fix-5958Andreas Rumpf2018-06-262-13/+11
|\ | | | | Make `static` blocks introduce their own scope
| * Adjust some tests to make them passLemonBoy2018-06-252-13/+11
| | | | | | | | | | | | The non-scoped behaviour of static blocks was exploited by those tests, replace all the variables declared whithin one with compileTime marked ones.
* | Improve vm support for ref typesOscar Nihlgård2018-06-262-1/+53
|/
* Fix for newStringOfCap in VM (#7901)Oscar Nihlgård2018-06-041-0/+8
|
* VM fix for refsOscar Nihlgård2018-05-081-0/+12
|
* Added a few useful os calls to VM (#7440)genotrance2018-04-121-3/+21
|
* Get symbol kind (#7491)Arne Döring2018-04-111-6/+6
|
* Fixes #7473 (#7475)Arne Döring2018-04-041-6/+6
| | | | | * removed code duplication * changelog entry, adopt tests for changes
* add tests for integer casting in VM.Parashurama2017-12-301-0/+120
|
* Improved collection-to-string behavior (#6825)Fabian Keller2017-12-142-2/+2
|
* make tests green againAndreas Rumpf2017-11-191-6/+6
|
* make tests green againAraq2017-11-011-5/+5
|
* the parser finally parses 'echo {1,2}' as it shouldAndreas Rumpf2017-09-301-1/+1
|
* make tests green againAndreas Rumpf2017-09-261-9/+9
|
* Closes #6083, closes #6086, closes #6379 (#6392)Daniil Yarancev2017-09-161-8/+58
|
* Fix operations on string as openarray in VM. (#6257)Parashurama2017-09-151-0/+34
| | | | | | | | | | * fix openarray.len for string as openArray in VM. * fix openarray[idx] for string as openArray in VM. * fix openarray[idx]=val for string as openArray in VM. * add tests for passing string as openArray in VM. * fix issue with NimNode.len NimNode.len was also returning len for string literals. also fix logic bug in if/elif chain.
* Fix seq.setLen initialisation in VM (#6224)Parashurama2017-09-021-0/+58
|
* add testcase for mitems returning tuple on VM.Parashurama2017-08-191-0/+14
|
* Vm fix zero extend proc ze/ze64 && toU32/toU16/toU8 (#5988)Parashurama2017-08-031-0/+44
| | | | | | * fixes ze/ze64 procs in VM. * fixes toU8/toU16/toU32. * add tests for ze/ze64 toU32/toU16/toU8 procs
* Remove expr/stmt (#5857)Arne Döring2017-07-2510-59/+57
|
* Creating and setting comment nodes in macros (#5850)Fredrik Høisæther Rasch2017-05-311-0/+8
| | | | | | | * strVal assingnable comment statement ast nodes * Set comment instead of strVal for comment nodes * Added test code for creating and setting comment nodes * Modified the AST spec documentation for documentation comments
* fixes #5269Andreas Rumpf2017-02-051-0/+30
|
* fixes #5327Andreas Rumpf2017-02-032-5/+43
|
* fix seq add for nim node in VM (#5253)Arne Döring2017-01-191-2/+7
| | | fixes #4821
* make quote ast a ref type (#5246)Arne Döring2017-01-191-0/+69
| | | | * make quote ast a ref type * recursive set flag isRef for quoted ast
an class="w"> } reagent base = inst.ingredients.at(0); canonize_type(base); if (!base.type || !base.type->value || get(Type, base.type->value).kind != EXCLUSIVE_CONTAINER) { raise_error << maybe(caller.name) << "first ingredient of 'maybe-convert' should be an exclusive-container, but got " << base.original_string << '\n' << end(); break; } if (!is_literal(inst.ingredients.at(1))) { raise_error << maybe(caller.name) << "second ingredient of 'maybe-convert' should have type 'variant', but got " << inst.ingredients.at(1).original_string << '\n' << end(); break; } if (inst.products.empty()) break; reagent product = inst.products.at(0); if (!canonize_type(product)) break; reagent& offset = inst.ingredients.at(1); populate_value(offset); if (offset.value >= SIZE(get(Type, base.type->value).elements)) { raise_error << maybe(caller.name) << "invalid tag " << offset.value << " in '" << inst.to_string() << '\n' << end(); break; } reagent variant = variant_type(base, offset.value); variant.type = new type_tree(get(Type_ordinal, "address"), variant.type); if (!types_coercible(product, variant)) { raise_error << maybe(caller.name) << "'maybe-convert " << base.original_string << ", " << inst.ingredients.at(1).original_string << "' should write to " << debug_string(variant.type) << " but " << product.name << " has type " << debug_string(product.type) << '\n' << end(); break; } break; } :(before "End Primitive Recipe Implementations") case MAYBE_CONVERT: { reagent base = current_instruction().ingredients.at(0); canonize(base); long long int base_address = base.value; if (base_address == 0) { raise_error << maybe(current_recipe_name()) << "tried to access location 0 in '" << current_instruction().to_string() << "'\n" << end(); break; } long long int tag = current_instruction().ingredients.at(1).value; long long int result; if (tag == static_cast<long long int>(get_or_insert(Memory, base_address))) { result = base_address+1; } else { result = 0; } products.resize(1); products.at(0).push_back(result); break; } :(code) const reagent variant_type(const reagent& canonized_base, long long int tag) { assert(tag >= 0); assert(contains_key(Type, canonized_base.type->value)); assert(!get(Type, canonized_base.type->value).name.empty()); const type_info& info = get(Type, canonized_base.type->value); assert(info.kind == EXCLUSIVE_CONTAINER); reagent element = info.elements.at(tag); // End variant_type Special-cases return element; } :(scenario maybe_convert_product_type_mismatch) % Hide_errors = true; recipe main [ 12:number <- copy 1 13:number <- copy 35 14:number <- copy 36 20:address:number <- maybe-convert 12:number-or-point/unsafe, 1:variant ] +error: main: 'maybe-convert 12:number-or-point/unsafe, 1:variant' should write to <address : <point : <>>> but 20 has type <address : <number : <>>> //:: Allow exclusive containers to be defined in mu code. :(scenario exclusive_container) exclusive-container foo [ x:number y:number ] +parse: --- defining exclusive-container foo +parse: element: x: number -- {"x": "number"} +parse: element: y: number -- {"y": "number"} :(before "End Command Handlers") else if (command == "exclusive-container") { insert_container(command, EXCLUSIVE_CONTAINER, in); } //: arrays are disallowed inside exclusive containers unless their length is //: fixed in advance :(scenario exclusive_container_contains_array) % Hide_errors = true; exclusive-container foo [ x:array:number:3 ] $error: 0 :(scenario exclusive_container_warns_on_dynamic_array_element) % Hide_errors = true; exclusive-container foo [ x:array:number ] +error: container 'foo' cannot determine size of element x //:: To construct exclusive containers out of variant types, use 'merge'. :(scenario lift_to_exclusive_container) exclusive-container foo [ x:number y:number ] recipe main [ 1:number <- copy 34 2:foo <- merge 0/x, 1:number # tag must be a literal when merging exclusive containers 4:foo <- merge 1/y, 1:number ] +mem: storing 0 in location 2 +mem: storing 34 in location 3 +mem: storing 1 in location 4 +mem: storing 34 in location 5 //: type-checking for 'merge' on exclusive containers :(scenario merge_handles_exclusive_container) % Hide_errors = true; exclusive-container foo [ x:number y:bar ] container bar [ z:number ] recipe main [ 1:foo <- merge 0/x, 34 ] +mem: storing 0 in location 1 +mem: storing 34 in location 2 $error: 0 :(scenario merge_requires_literal_tag_for_exclusive_container) % Hide_errors = true; exclusive-container foo [ x:number y:bar ] container bar [ z:number ] recipe main [ local-scope 1:number <- copy 0 2:foo <- merge 1:number, 34 ] +error: main: ingredient 0 of 'merge' should be a literal, for the tag of exclusive-container foo :(before "End valid_merge Cases") case EXCLUSIVE_CONTAINER: { assert(state.data.top().container_element_index == 0); trace(9999, "transform") << "checking exclusive container " << debug_string(container) << " vs ingredient " << ingredient_index << end(); if (!is_literal(ingredients.at(ingredient_index))) { raise_error << maybe(caller.name) << "ingredient " << ingredient_index << " of 'merge' should be a literal, for the tag of exclusive-container " << container_info.name << '\n' << end(); return; } reagent ingredient = ingredients.at(ingredient_index); // unnecessary copy just to keep this function from modifying caller populate_value(ingredient); if (ingredient.value >= SIZE(container_info.elements)) { raise_error << maybe(caller.name) << "invalid tag at " << ingredient_index << " for " << container_info.name << " in '" << inst.to_string() << '\n' << end(); return; } reagent variant = variant_type(container, ingredient.value); trace(9999, "transform") << "tag: " << ingredient.value << end(); // replace union with its variant state.data.pop(); state.data.push(merge_check_point(variant, 0)); ++ingredient_index; break; } :(scenario merge_check_container_containing_exclusive_container) % Hide_errors = true; container foo [ x:number y:bar ] exclusive-container bar [ x:number y:number ] recipe main [ 1:foo <- merge 23, 1/y, 34 ] +mem: storing 23 in location 1 +mem: storing 1 in location 2 +mem: storing 34 in location 3 $error: 0 :(scenario merge_check_container_containing_exclusive_container_2) % Hide_errors = true; container foo [ x:number y:bar ] exclusive-container bar [ x:number y:number ] recipe main [ 1:foo <- merge 23, 1/y, 34, 35 ] +error: main: too many ingredients in '1:foo <- merge 23, 1/y, 34, 35' :(scenario merge_check_exclusive_container_containing_container) % Hide_errors = true; exclusive-container foo [ x:number y:bar ] container bar [ x:number y:number ] recipe main [ 1:foo <- merge 1/y, 23, 34 ] +mem: storing 1 in location 1 +mem: storing 23 in location 2 +mem: storing 34 in location 3 $error: 0 :(scenario merge_check_exclusive_container_containing_container_2) % Hide_errors = true; exclusive-container foo [ x:number y:bar ] container bar [ x:number y:number ] recipe main [ 1:foo <- merge 0/x, 23 ] $error: 0 :(scenario merge_check_exclusive_container_containing_container_3) % Hide_errors = true; exclusive-container foo [ x:number y:bar ] container bar [ x:number y:number ] recipe main [ 1:foo <- merge 1/y, 23 ] +error: main: too few ingredients in '1:foo <- merge 1/y, 23' //: Since the different variants of an exclusive-container might have //: different sizes, relax the size mismatch check for 'merge' instructions. :(before "End size_mismatch(x) Cases") if (current_instruction().operation == MERGE && !current_instruction().products.empty() && current_instruction().products.at(0).type) { reagent x = current_instruction().products.at(0); canonize(x); if (get(Type, x.type->value).kind == EXCLUSIVE_CONTAINER) { return size_of(x) < SIZE(data); } } :(scenario merge_exclusive_container_with_mismatched_sizes) container foo [ x:number y:number ] exclusive-container bar [ x:number y:foo ] recipe main [ 1:number <- copy 34 2:number <- copy 35 3:bar <- merge 0/x, 1:number 6:bar <- merge 1/foo, 1:number, 2:number ] +mem: storing 0 in location 3 +mem: storing 34 in location 4 # bar is always 3 large so location 5 is skipped +mem: storing 1 in location 6 +mem: storing 34 in location 7 +mem: storing 35 in location 8