/
origin_spec.ik
110 lines (84 loc) · 2.48 KB
/
origin_spec.ik
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
use("ispec")
describe(Origin,
describe("print",
it("should print asText of object to 'System out'",
oldSystemOutPrint = System out cell(:print)
Ground expected = nil
System out print = method(arg, Ground expected = arg)
"foobarz" print
System out print = cell(:oldSystemOutPrint)
expected should == "foobarz"
)
)
describe("println",
it("should print asText of object to 'System out'",
oldSystemOutPrintln = System out cell(:println)
Ground expected = nil
System out println = method(arg, Ground expected = arg)
"foobarz" println
System out println = cell(:oldSystemOutPrintln)
expected should == "foobarz"
)
)
describe("===",
it("should check for mimicness if receiver is Origin",
Origin should === Origin
Origin should === Origin mimic
Origin should === "foo"
Origin should not === Ground
)
it("should check for equalness if receiver is not Origin",
x = Origin mimic
y = Origin mimic
z = Origin mimic
z == = fnx(other, other same?(x))
x should === x
x should not === y
x should not === Origin
x should not === z
z should not === z
z should === x
)
)
describe("around mimic",
it("should ignore arguments sent to mimic",
fn(Origin mimic(1,2,3,4,5)) should not signal(Condition Error)
)
it("should call initalize if such a cell exists",
X = Origin mimic
Ground argumentsGiven = []
X initialize = method(+rest, +:krest, argumentsGiven << [rest, krest])
X mimic(12, foo: 42, 555+2)
argumentsGiven should == [[[12, 557],{foo: 42}]]
)
it("should return a new mimic of the object",
X = Origin mimic
x = X mimic
x should not be same(X)
x should be mimic(X)
)
)
describe("eval",
it("should eval on the receiver",
x = Origin mimic
x foo = 42
x eval("foo should == 42")
x eval("identity") should be same(x)
)
it("should eval an empty string",
Origin eval("") should == nil
)
it("should eval a number",
Origin eval("1") should == 1
)
it("should eval a simple message",
Origin eval("[](1,2,3,4)") should == [1,2,3,4]
)
it("should eval a message with operator shuffling",
Origin eval("1 + 2") should == 3
)
it("should eval multiple message chains",
Origin eval("sam = 1. boris = 5. sooze = 10. sam + boris + sooze") should == 16
)
)
)