Permalink
Browse files

Fixed typo in Struct class and added tests.

  • Loading branch information...
bakkdoor committed Jun 24, 2011
1 parent 8fdace7 commit 337a3098096ffe1634704a7ca3e938f71aad0fbe
Showing with 28 additions and 1 deletion.
  1. +1 −1 lib/struct.fy
  2. +27 −0 tests/struct.fy
View
@@ -10,7 +10,7 @@ class Struct {
Creates a new Struct class with the given slots.
"""
- struct = new(*slot)
+ struct = new(*slots)
struct read_write_slots: slots
def struct new: values {
View
@@ -0,0 +1,27 @@
+FancySpec describe: Struct with: {
+ Point = Struct new: ('x, 'y)
+
+ it: "creates a struct class" when: {
+ Point is_a?: Class is == true
+ }
+
+ it: "creates setter methods for a struct's fields" when: {
+ Point instance_methods includes?: "x:" is == true
+ Point instance_methods includes?: "y:" is == true
+ }
+
+ it: "creates getter methods for a struct's fields" when: {
+ Point instance_methods includes?: ":x" is == true
+ Point instance_methods includes?: ":y" is == true
+ }
+
+ it: "works with getter and setter methods as expected" when: {
+ p = Point new: (2, 3)
+ p x is == 2
+ p y is == 3
+ p x: 10
+ p y: 20
+ p x is == 10
+ p y is == 20
+ }
+}

0 comments on commit 337a309

Please sign in to comment.