forked from olabini/ioke
/
mixins_spec.ik
118 lines (91 loc) · 3.33 KB
/
mixins_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
110
111
112
113
114
115
116
117
118
use("ispec")
describe(Mixins,
describe("cells",
it("should return the cells of this object by default",
x = Mixins mimic. x cells should == {}
x = Mixins mimic. x f = 13. x cells should == {f: 13}
x = Mixins mimic. x f = 13. x Why = 1. x cells should == {f: 13, Why: 1}
x = Mixins mimic. x Why = 1. x f = 13. x cells should == {f: 13, Why: 1}
)
)
describe("cellNames",
it("should return the cell names of this object by default",
x = Mixins mimic. x cellNames should == []
x = Mixins mimic. x f = 13. x cellNames should == [:f]
x = Mixins mimic. x f = 13. x Why = 1. x cellNames should == [:f, :Why]
x = Mixins mimic. x Why = 1. x f = 13. x cellNames should == [:Why, :f]
)
)
describe("cell",
it("should be possible to get a cell using a Text argument",
Mixins x = 42
Mixins cell("x") should == Mixins x
Mixins Comparing x = 43
Mixins Comparing cell("x") should == Mixins Comparing x
)
it("should be possible to get a cell using a Symbol argument",
Mixins x = 42
Mixins cell(:x) should == Mixins x
Mixins Comparing x = 43
Mixins Comparing cell(:x) should == Mixins Comparing x
)
it("should report an error if trying to get a cell that doesn't exist in that object",
fn(Mixins cell(:mixins_spec_non_existing)) should signal(Condition Error NoSuchCell)
fn(Mixins cell("mixins_spec_non_existing")) should signal(Condition Error NoSuchCell)
fn(Mixins Comparing cell(:mixins_spec_non_existing)) should signal(Condition Error NoSuchCell)
fn(Mixins Comparing cell("mixins_spec_non_existing")) should signal(Condition Error NoSuchCell)
)
)
describe("cell=",
it("should be possible to set a cell using a Text argument",
Mixins cell("blurg") = 42
Mixins blurg should == 42
Mixins Comparing cell("murg") = 43
Mixins Comparing murg should == 43
)
it("should be possible to set a cell using a Symbol argument",
Mixins cell(:blurg) = 42
Mixins blurg should == 42
Mixins Comparing cell(:murg) = 43
Mixins Comparing murg should == 43
)
it("should be possible to set a cell with an empty name",
oldEmpty = cell("")
Mixins Comparing cell("") = 42
Mixins Comparing cell("") should == 42
Mixins Comparing cell("") = cell(:oldEmpty)
)
it("should be possible to set a cell with complicated expressions",
f = Origin mimic
f b = "foobar"
Mixins cell(f b) = 42+24-3
Mixins cell(:foobar) should == 63
)
it("should be possible to set a cell that doesn't exist",
Mixins cell(:blurg) = 42
Mixins blurg should == 42
Mixins Comparing cell(:murg) = 43
Mixins Comparing murg should == 43
)
it("should be possible to set a cell that does exist",
Mixins x = 42
Mixins cell(:x) = 43
Mixins x should == 43
Mixins Comparing x = 42
Mixins Comparing cell(:x) = 44
Mixins Comparing x should == 44
)
it("should be possible to set a cell that does exist in a mimic. this should not change the mimic value",
one = Mixins mimic
one x = 42
two = one mimic
two cell(:x) = 43
one x should == 42
one = Mixins mimic
one x = 42
two = one mimic
two cell(:x) = 43
two x should == 43
)
)
)