Skip to content

Commit 23a5476

Browse files
authored
Merge pull request #1917 from RickBarretto/test-type-to-issue-1354
[Types\to] add unit-tests
2 parents 505d108 + 5712625 commit 23a5476

File tree

3 files changed

+1664
-0
lines changed

3 files changed

+1664
-0
lines changed

src/helpers/conversion.nim

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ proc convertedValueToType*(x, y: Value, tp: ValueKind, aFormat:Value = nil): Val
6161
case y.kind:
6262
of Null:
6363
case tp:
64+
# TODO(Converters) should support :null -> :floating
6465
of Logical: return VFALSE
6566
of Integer: return I0
6667
of String: return newString("null")

tests/unitt/lib/types/to.helper.art

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
for: $[targetType :type sections :block][
2+
section: $[sourceType :type cases :block][
3+
test ~"|sourceType| => |targetType|:"
4+
flatten.once map @cases 'p [
5+
source: first p
6+
expected: last p
7+
assertion: [equal?]
8+
| append @[expected]
9+
| append [to]
10+
| append targetType
11+
| append @[source]
12+
13+
[assert] ++ @[assertion]
14+
]
15+
]
16+
17+
do sections
18+
]
19+
20+
pair: $[source target][
21+
@[source target]
22+
]
23+
24+
alias.infix {->>} 'pair

0 commit comments

Comments
 (0)