diff --git a/unittests/namespaces.chai b/unittests/namespaces.chai new file mode 100644 index 00000000..51bea60f --- /dev/null +++ b/unittests/namespaces.chai @@ -0,0 +1,7 @@ +namespace("math") + +math.square = fun(x) { x * x } +math.sum_squares = fun(x, y) { math.square(x) + math.square(y) } + +assert_equal(16, math.square(4)) +assert_equal(29, math.sum_squares(2, 5)) \ No newline at end of file diff --git a/unittests/namespaces_nested_copy.chai b/unittests/namespaces_nested_copy.chai new file mode 100644 index 00000000..7ec8ff53 --- /dev/null +++ b/unittests/namespaces_nested_copy.chai @@ -0,0 +1,9 @@ +namespace("parent") +namespace("child") + +child.x = 3.0 +parent.child = child +parent.child.x = 5.0 + +assert_equal(3.0, child.x) +assert_equal(5.0, parent.child.x) \ No newline at end of file diff --git a/unittests/namespaces_nested_ref.chai b/unittests/namespaces_nested_ref.chai new file mode 100644 index 00000000..5be991cb --- /dev/null +++ b/unittests/namespaces_nested_ref.chai @@ -0,0 +1,9 @@ +namespace("parent") +namespace("child") + +child.x = 3.0 +parent.child := child +parent.child.x = 5.0 + +assert_equal(5.0, child.x) +assert_equal(5.0, parent.child.x) \ No newline at end of file