Skip to content

Commit 06fb44c

Browse files
committed
feat(tests): adding a name resolution test with multiple imports using the same imported name
1 parent 313a3f2 commit 06fb44c

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

tests/unittests/Suites/NameResolutionSuite.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,4 +181,22 @@ ut::suite<"NameResolution"> name_resolution_suite = [] {
181181
expect(a_ok.valueType() == Ark::ValueType::True) << "(and (= foo \"b:foo\") (= bar \"c:bar\"))\n";
182182
};
183183
};
184+
185+
"[importing two symbols with the same name from two different files]"_test = [] {
186+
Ark::State state({ lib_path });
187+
188+
should("compile the resource without any error") = [&] {
189+
expect(mut(state).doFile(getResourcePath("NameResolutionSuite/symbol_imports_same_name/a.ark")));
190+
};
191+
192+
Ark::VM vm(state);
193+
should("return exit code 0") = [&] {
194+
expect(mut(vm).run() == 0_i);
195+
};
196+
197+
should("resolve symbols from all namespaces without generating bad fully qualified names") = [&] {
198+
const auto a_ok = mut(vm).operator[]("ok");
199+
expect(a_ok.valueType() == Ark::ValueType::True) << "(and (= find \"b.ark\") (= b:find \"b.ark\") (= c:find \"c.ark\"))\n";
200+
};
201+
};
184202
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
(import b :find)
2+
(import c :find)
3+
4+
(let ok (and (= find "b.ark") (= b:find "b.ark") (= c:find "c.ark")))
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(let find "b.ark")
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
(let find "c.ark")
2+
(let test (fun () find))
3+
4+
(let bar "c:bar")

0 commit comments

Comments
 (0)