Skip to content

Commit 748c557

Browse files
committed
feat(tests, vm): add tests for the type checking / arity errors produced by the builtins
1 parent 5c445a8 commit 748c557

File tree

90 files changed

+376
-14
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+376
-14
lines changed

src/arkreactor/Builtins/Mathematics.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,6 @@ namespace Ark::internal::Builtins::Mathematics
126126
*/
127127
Value isnan_(std::vector<Value>& n, VM* vm [[maybe_unused]])
128128
{
129-
if (!types::check(n, ValueType::Any))
130-
throw types::TypeCheckingError(
131-
"math:NaN?",
132-
{ { types::Contract { { types::Typedef("value", ValueType::Any) } } } },
133-
n);
134-
135129
if (n[0].valueType() != ValueType::Number)
136130
return falseSym;
137131

@@ -150,12 +144,6 @@ namespace Ark::internal::Builtins::Mathematics
150144
*/
151145
Value isinf_(std::vector<Value>& n, VM* vm [[maybe_unused]])
152146
{
153-
if (!types::check(n, ValueType::Any))
154-
throw types::TypeCheckingError(
155-
"math:Inf?",
156-
{ { types::Contract { { types::Typedef("value", ValueType::Any) } } } },
157-
n);
158-
159147
if (n[0].valueType() != ValueType::Number)
160148
return falseSym;
161149

src/arkreactor/VM/VM.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1696,7 +1696,7 @@ namespace Ark
16961696
}
16971697
else if (consecutive_similar_traces == 0)
16981698
{
1699-
fmt::println("{0:^{1}}", "...", 21 + func_name.size() + loc_as_text.size());
1699+
fmt::println(os, " ...");
17001700
++consecutive_similar_traces;
17011701
}
17021702

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(math:ln -1)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
math:ln: value -1 must be greater than 0
2+
3+
In file tests/unittests/resources/DiagnosticsSuite/runtime/mathln_out_of_range.ark
4+
1 | (math:ln -1)
5+
| ^~~~~~~~~~~
6+
2 |

tests/unittests/resources/DiagnosticsSuite/runtime/recursion_depth.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ In file tests/unittests/resources/DiagnosticsSuite/runtime/recursion_depth.ark
99
5 | }))
1010

1111
[2047] In function `foo' (tests/unittests/resources/DiagnosticsSuite/runtime/recursion_depth.ark:3)
12+
...
1213
[ 1] In global scope (tests/unittests/resources/DiagnosticsSuite/runtime/recursion_depth.ark:7)
1314

1415
Current scope variables values:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(await 1)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Function await expected 1 argument
2+
-> future (UserType) was of type Number
3+
4+
In file tests/unittests/resources/DiagnosticsSuite/typeChecking/await_num.ark
5+
1 | (await 1)
6+
| ^~~~~~~~
7+
2 |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(io:appendToFile 1 2)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Function io:appendToFile expected 2 arguments
2+
-> filename (String) was of type Number
3+
-> content (any)
4+
5+
In file tests/unittests/resources/DiagnosticsSuite/typeChecking/ioappendtofile_num_num.ark
6+
1 | (io:appendToFile 1 2)
7+
| ^~~~~~~~~~~~~~~~~~~~
8+
2 |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(io:dir? 1)

0 commit comments

Comments
 (0)