1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

js,checker: allow casting JS primitives to V primitives and vice-versa (#12420)

This commit is contained in:
playX
2021-11-10 12:37:16 +03:00
committed by GitHub
parent 6c244d3065
commit 194b3647e2
3 changed files with 56 additions and 1 deletions

View File

@@ -0,0 +1,12 @@
fn JS.Math.pow(JS.Number, JS.Number) JS.Number
fn test_js_prim_cast() {
x := JS.Number(f64(42.42))
assert f64(x) == 42.42
y := JS.BigInt(u64(18446744073709551615))
assert u64(y) == u64(18446744073709551615)
z := JS.String('hello, world!')
assert string(z) == 'hello, world!'
w := int(JS.Math.pow(JS.Number(int(2)), JS.Number(int(3))))
assert w == 8
}