|
@@ -37,5 +37,25 @@ module Chervil
|
37
|
37
|
Error.new("Expected 1 argument but received 2")
|
38
|
38
|
)
|
39
|
39
|
end
|
|
40
|
+
|
|
41
|
+ it 'can do car and cdr' do
|
|
42
|
+ expect(Core::CORE['car'].call([[1, 2, 3]])).to eq(1)
|
|
43
|
+ expect(Core::CORE['cdr'].call([[1, 2, 3]])).to eq([2, 3])
|
|
44
|
+ expect(Core::CORE['car'].call([1.0])).to eq(
|
|
45
|
+ Error.new("Expected an argument of type list but got number")
|
|
46
|
+ )
|
|
47
|
+ expect(Core::CORE['cdr'].call([1.0])).to eq(
|
|
48
|
+ Error.new("Expected an argument of type list but got number")
|
|
49
|
+ )
|
|
50
|
+ expect(Core::CORE['car'].call([[1, 2, 3], [4, 5, 6]])).to eq(
|
|
51
|
+ Error.new("Expected 1 argument but received 2")
|
|
52
|
+ )
|
|
53
|
+ expect(Core::CORE['cdr'].call([[1, 2, 3], [4, 5, 6]])).to eq(
|
|
54
|
+ Error.new("Expected 1 argument but received 2")
|
|
55
|
+ )
|
|
56
|
+ expect(Core::CORE['car'].call([Array.new])).to eq(
|
|
57
|
+ Error.new("`car` expects a non-empty list")
|
|
58
|
+ )
|
|
59
|
+ end
|
40
|
60
|
end
|
41
|
61
|
end
|