KT-34770 JS. Configurable properties. Test

This commit is contained in:
Victor Turansky
2020-03-26 19:07:36 +03:00
committed by Zalim Bashorov
parent 103fd093e1
commit 79bec82430
3 changed files with 56 additions and 2 deletions
@@ -0,0 +1,40 @@
// EXPECTED_REACHABLE_NODES: 1325
// KJS_WITH_FULL_RUNTIME
package foo
external interface EP {
val simpleProp: Int
val anotherProp: String
val propWithGetter: Boolean
}
class P : EP {
override val simpleProp = 13
override val anotherProp = "42"
override val propWithGetter: Boolean
get() = true
}
fun usages() {
val p = P()
assertEquals(13, p.simpleProp)
assertEquals("42", p.anotherProp)
assertEquals(true, p.propWithGetter)
}
fun box(): String {
usages()
val prototype = P::class.js.asDynamic().prototype
assertTrue(isConfigurable(prototype, "simpleProp"))
assertTrue(isConfigurable(prototype, "anotherProp"))
assertTrue(isConfigurable(prototype, "propWithGetter"))
return "OK"
}
fun isConfigurable(obj: Any, prop: String): Boolean =
js("Object")
.getOwnPropertyDescriptor(obj, prop)
.configurable