diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-20 20:18:52 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-20 20:18:52 +0000 |
commit | 1d15d5f08032acf1b7bceacbb450d617ff6e0931 (patch) | |
tree | a3785a79899302bc149e4a6e72f624ac27dc1f10 /spec/ruby/core/hash/fixtures | |
parent | 75bfc6440d595bf339007f4fb280fd4d743e89c1 (diff) |
Move spec/rubyspec to spec/ruby for consistency
* Other ruby implementations use the spec/ruby directory.
[Misc #13792] [ruby-core:82287]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/core/hash/fixtures')
-rw-r--r-- | spec/ruby/core/hash/fixtures/classes.rb | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/spec/ruby/core/hash/fixtures/classes.rb b/spec/ruby/core/hash/fixtures/classes.rb new file mode 100644 index 0000000000..3d3df576cf --- /dev/null +++ b/spec/ruby/core/hash/fixtures/classes.rb @@ -0,0 +1,68 @@ +module HashSpecs + class MyHash < Hash; end + + class MyInitializerHash < Hash + + def initialize + raise "Constructor called" + end + + end + + class NewHash < Hash + def initialize(*args) + args.each_with_index do |val, index| + self[index] = val + end + end + end + + class DefaultHash < Hash + def default(key) + 100 + end + end + + class ToHashHash < Hash + def to_hash + { "to_hash" => "was", "called!" => "duh." } + end + end + + class KeyWithPrivateHash + private :hash + end + + class ByIdentityKey + def hash + fail("#hash should not be called on compare_by_identity Hash") + end + end + + class ByValueKey + attr_reader :n + def initialize(n) + @n = n + end + + def hash + n + end + + def eql? other + ByValueKey === other and @n == other.n + end + end + + def self.empty_frozen_hash + @empty ||= {} + @empty.freeze + @empty + end + + def self.frozen_hash + @hash ||= { 1 => 2, 3 => 4 } + @hash.freeze + @hash + end +end |