awtk/tests/fscripts/demo_object.fs

28 lines
604 B
Forth
Raw Normal View History

2022-08-23 11:21:48 +08:00
var a = object_create()
2021-01-11 12:12:59 +08:00
assert(!value_is_null(a))
assert(object_set(a, "age", 123))
2021-01-14 11:01:47 +08:00
assert(a.age == 123)
assert(object_set(a, "name", "awtk"))
assert(a.name == "awtk")
2021-01-11 12:12:59 +08:00
assert(object_get(a, "age") == 123)
print(object_get(a, "age"))
assert(object_remove(a, "age"))
assert(!value_is_valid(object_get(a, "age")))
unset(a)
2021-01-14 11:01:47 +08:00
2022-08-23 11:21:48 +08:00
var person = object_create()
2021-01-14 11:01:47 +08:00
assert(!value_is_null(person))
assert(object_set(person, "age", 123))
assert(person.age == 123)
assert(object_set(person, "name", "awtk"))
assert(person.name == "awtk")
2022-08-23 11:21:48 +08:00
var g= object_create()
g.arr = array_create()
object_forward_events(g.arr, g)
2021-01-14 11:01:47 +08:00