JS backend: support secondary constructors in native classes

This commit is contained in:
Zalim Bashorov
2015-06-01 14:52:29 +03:00
parent 08439c541e
commit 33fb3fb6e4
5 changed files with 39 additions and 2 deletions
@@ -0,0 +1,24 @@
package foo
native
class A {
constructor()
constructor(s: String)
constructor(i: Int)
val value: Any?
}
fun test(a: A, expectedValue: Any?, expectedTypeOfValue: String) {
assertTrue(a is A)
assertEquals(expectedValue, a.value)
assertEquals(expectedTypeOfValue, typeof(a.value))
}
fun box(): String {
test(A(), undefined, "undefined")
test(A("foo"), "foo", "string")
test(A(124), 124, "number")
return "OK"
}
@@ -0,0 +1,3 @@
function A(value) {
this.value = value
}