Skip to content

Commit

Permalink
fix core tests
Browse files Browse the repository at this point in the history
  • Loading branch information
StunxFS committed Jan 2, 2024
1 parent e3a7eb1 commit ef2e8d6
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions lib/core/src/TestRunner.ri
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ $if _TESTS_ {
struct Test {
name: string;
fn: func (mut Test);
fn: func (&mut Test);
mut result: TestResult;
mut early_return: bool;
mut err_pos: string;
Expand All @@ -75,13 +75,13 @@ $if _TESTS_ {
}
struct TestRunner {
mut tests: []mut Test;
tests: []mut Test;
mut ok_tests: uint64;
mut fail_tests: uint64;
mut skip_tests: uint64;
func run(&mut self) {
for i, mut test_ in self.tests {
for i, &mut test_ in self.tests {
console_ewrite(" [{}/{}] {} ", i + 1, self.tests.len, test_.name);
(test_.fn)(test_);
match test_.result {
Expand Down
2 changes: 1 addition & 1 deletion lib/core/tests/string_test.ri
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ test "string.runes_count()" {

test "string.tokenize()" {
mut iterator := " abc def ghi ".tokenize(' ');
mut res := []string(cap: 3);
res := []string(cap: 3);
while w := iterator.next() {
res.push(w);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/core/tests/vector_test.ri
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
test "dynamic arrays: push and pop" {
mut vec := +["A", "B"];
vec := +["A", "B"];
@assert(vec.len == 2);

vec.push("C");
Expand Down
2 changes: 1 addition & 1 deletion rivetc/src/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def check_stmt(self, stmt):
stmt.iterable.pos
)
else:
elem_typ = type.Ptr(elem_typ)
elem_typ = type.Ptr(elem_typ, stmt.value.is_mut)
elif stmt.value.is_mut:
report.error("invalid syntax for `for` statement", stmt.value.pos)
report.help(
Expand Down
2 changes: 1 addition & 1 deletion rivetc/src/codegen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1311,7 +1311,7 @@ def gen_expr(self, expr, custom_tmp = None):
]
)
elif expr.sym.is_method and expr.sym.name == "pop" and left_sym.kind == TypeKind.DynArray:
ret_typ = self.ir_type(expr.sym.ret_typ)
ret_typ = self.ir_type(expr.typ)
value = ir.Inst(ir.InstKind.Cast, [inst, ret_typ.ptr()])
if custom_tmp:
self.cur_func.store(
Expand Down
8 changes: 4 additions & 4 deletions rivetc/src/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def resolve_stmt(self, stmt):
try:
stmt.scope.add(
sym.Obj(
stmt.index.is_mut, stmt.index.name,
False, stmt.index.name,
self.comp.void_t, sym.ObjLevel.Local, stmt.index.pos
)
)
Expand All @@ -205,7 +205,7 @@ def resolve_stmt(self, stmt):
try:
stmt.scope.add(
sym.Obj(
stmt.value.is_mut, stmt.value.name, self.comp.void_t,
False, stmt.value.name, self.comp.void_t,
sym.ObjLevel.Local, stmt.value.pos
)
)
Expand Down Expand Up @@ -280,7 +280,7 @@ def resolve_expr(self, expr):
try:
expr.scope.add(
sym.Obj(
expr.var.is_mut and not expr.var.is_ref,
False,
expr.var.name, self.comp.void_t, sym.ObjLevel.Local,
expr.var.pos
)
Expand Down Expand Up @@ -346,7 +346,7 @@ def resolve_expr(self, expr):
try:
b.scope.add(
sym.Obj(
b.var_is_mut and not b.var_is_ref,
False,
b.var_name, self.comp.void_t,
sym.ObjLevel.Local, b.var_pos
)
Expand Down

0 comments on commit ef2e8d6

Please sign in to comment.