Skip to content

Commit

Permalink
Add all remaining Struct specs from rubyspec
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Dec 9, 2013
1 parent bd10abe commit e7ccf31
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
2 changes: 2 additions & 0 deletions opal/corelib/struct.rb
Expand Up @@ -136,4 +136,6 @@ def inspect

result
end

alias to_s inspect
end
25 changes: 25 additions & 0 deletions spec/opal/filters/bugs/struct.rb
Expand Up @@ -2,8 +2,28 @@
fails "Struct#[] fails when it does not know about the requested attribute"
fails "Struct#[] fails if not passed a string, symbol, or integer"

fails "Struct#[]= fails when trying to assign attributes which don't exist"

fails "Struct#== returns true if the other has all the same fields"
fails "Struct#== handles recursive structures by returning false if a difference can be found "

fails "Struct#eql? returns false if any corresponding elements are not #eql?"
fails "Struct#eql? handles recursive structures by returning false if a difference can be found "

fails "Struct#hash returns the same fixnum for structs with the same content"
fails "Struct#hash returns the same value if structs are #eql?"
fails "Struct#hash returns the same hash for recursive structs"

fails "Struct#to_h returns a Hash with members as keys"
fails "Struct#to_h returns a Hash that is independent from the struct"

fails "Struct#initialize can be overriden"

fails "Struct#inspect returns a string representation of some kind"

fails "Struct#instance_variables returns an array with one name if an instance variable is added"
fails "Struct#instance_variables returns an empty array if only attributes are defined"

fails "Struct.new fails with too many arguments"
fails "Struct.new creates a constant in subclass' namespace"
fails "Struct.new raises a TypeError if object is not a Symbol"
Expand All @@ -12,4 +32,9 @@
fails "Struct.new does not create a constant with symbol as first argument"
fails "Struct.new creates a new anonymous class with nil first argument"
fails "Struct.new calls to_str on its first argument (constant name)"

fails "Struct#values_at fails when passed unsupported types"
fails "Struct#values_at returns an array of values"

fails "Struct anonymous class instance methods Enumerable methods should work"
end
17 changes: 17 additions & 0 deletions spec/opal/rubyspecs
Expand Up @@ -320,8 +320,25 @@ core/symbol/to_proc_spec
core/struct/each_pair_spec
core/struct/each_spec
core/struct/element_reference_spec
core/struct/element_set_spec
core/struct/eql_spec
core/struct/equal_value_spec
core/struct/hash_spec
core/struct/initialize_copy_spec
core/struct/initialize_spec
core/struct/inspect_spec
core/struct/instance_variables_spec
core/struct/length_spec
core/struct/members_spec
core/struct/new_spec
core/struct/select_spec
core/struct/size_spec
core/struct/struct_spec
core/struct/to_a_spec
core/struct/to_h_spec
core/struct/to_s_spec
core/struct/values_at_spec
core/struct/values_spec

core/class/new_spec

Expand Down

0 comments on commit e7ccf31

Please sign in to comment.