tests/object.fy in fancy-0.6.0 vs tests/object.fy in fancy-0.7.0
- old
+ new
@@ -169,33 +169,31 @@
4 == 5
}
}
MyClass new do_wacky_things is: false
- {
- true is: false
- } call_with_receiver: (MyClass new)
+ @{ true is: false } call: [MyClass new]
}
it: "overrides nil" with: 'nil when: {
class MyClass {
def nil {
true
}
}
- { nil is: true } call_with_receiver: (MyClass new)
+ @{ nil is: true } call: [MyClass new]
}
it: "overrides false" with: 'false when: {
class MyClass2 {
def false {
true
}
}
- { false is: true } call_with_receiver: (MyClass2 new)
+ @{ false is: true } call: [MyClass2 new]
}
it: "implicitly sends a message to self if no receiver is specified" when: {
def test { 42 }
test is: 42
@@ -275,7 +273,35 @@
}
v = []
bar: [1,2,3] values: v . is: 1
v is: [1]
+ }
+
+ it: "provides temporarily mutable slots" with: 'with_mutable_slots: when: {
+ class Student {
+ read_slots: ('name, 'age, 'city)
+ def initialize: block {
+ with_mutable_slots: ('name, 'age, 'city) do: block
+ }
+ }
+
+ p = Student new: @{
+ name: "Chris"
+ age: 24
+ city: "Osnabrück"
+ }
+
+ p name is: "Chris"
+ p age is: 24
+ p city is: "Osnabrück"
+
+ { p name: "New Name" } raises: NoMethodError
+ { p age: 25 } raises: NoMethodError
+ { p city: "New City" } raises: NoMethodError
+
+ # no changes
+ p name is: "Chris"
+ p age is: 24
+ p city is: "Osnabrück"
}
}