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:
12
vlib/v/tests/cast_test.js.v
Normal file
12
vlib/v/tests/cast_test.js.v
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user