Add class keyword for easier user defined types.

Issue #118
This commit is contained in:
Jason Turner
2014-08-22 21:11:49 -06:00
parent cb1c7730cf
commit fa1f4b795b
6 changed files with 205 additions and 31 deletions

27
unittests/class.chai Normal file
View File

@@ -0,0 +1,27 @@
class Vector3
{
// you can use attr, auto or var in this context
attr x
auto y
var z
def Vector3(x,y,z)
{
this.x = x
this.y = y
this.z = z
}
def doSomething(mult)
{
return this.x * this.y * this.z * mult
}
}
auto v = Vector3(1,2,3)
assert_equal(1, v.x)
assert_equal(v.doSomething(2), 12)