-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest_class.dry
63 lines (52 loc) · 1.52 KB
/
test_class.dry
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
class TestClass {
def test_object_types() {
class Foo {}
let foo = Foo();
assert_equals("Type of class", typeof(Foo), "class");
assert_equals("Type of instance", typeof(foo), "instance");
}
def test_instance_properties() {
class Pet {
def sound() {
return "quack!";
}
}
let duck = Pet();
assert_equals("Ducks should quack!", duck.sound(), "quack!");
let denji = Pet();
denji.sound = lambda() {
return "Woof!";
};
assert_equals("Denji should say 'Woof!'", denji.sound(), "Woof!");
}
def test_class_properties() {
class Foo {}
Foo.bar = "bar value";
assert_equals("Class properties should be updated", Foo.bar, "bar value");
}
def test_name() {
class Foo {}
assert_equals("Class name attribute", "Foo", Foo.__name__);
}
def test_class_string() {
class Foo {}
assert_equals("Class stringification", str(Foo), "Foo");
}
def test_local_reference_self() {
{
class Foo {
def returnSelf() {
return Foo;
}
}
assert_equals("Local reference to self", str(Foo().returnSelf()), "Foo");
}
}
}
let classes = TestClass();
classes.test_object_types();
classes.test_instance_properties();
classes.test_class_properties();
classes.test_name();
classes.test_class_string();
classes.test_local_reference_self();