summaryrefslogtreecommitdiff
path: root/spec/rubyspec/fixtures
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-07 12:04:49 +0000
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-07 12:04:49 +0000
commit95e8c48dd3348503a8c7db5d0498894a1b676395 (patch)
tree9eef7f720314ebaff56845a74e203770e62284e4 /spec/rubyspec/fixtures
parented7d803500de38186c74bce94d233e85ef51e503 (diff)
Add in-tree mspec and ruby/spec
* For easier modifications of ruby/spec by MRI developers. * .gitignore: track changes under spec. * spec/mspec, spec/rubyspec: add in-tree mspec and ruby/spec. These files can therefore be updated like any other file in MRI. Instructions are provided in spec/README. [Feature #13156] [ruby-core:79246] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/rubyspec/fixtures')
-rw-r--r--spec/rubyspec/fixtures/basicobject/method_missing.rb55
-rw-r--r--spec/rubyspec/fixtures/class.rb136
-rw-r--r--spec/rubyspec/fixtures/class_variables.rb58
-rw-r--r--spec/rubyspec/fixtures/code/a/load_fixture.bundle1
-rw-r--r--spec/rubyspec/fixtures/code/a/load_fixture.dll1
-rw-r--r--spec/rubyspec/fixtures/code/a/load_fixture.so1
-rw-r--r--spec/rubyspec/fixtures/code/b/load_fixture.rb1
-rw-r--r--spec/rubyspec/fixtures/code/concurrent.rb12
-rw-r--r--spec/rubyspec/fixtures/code/concurrent2.rb8
-rw-r--r--spec/rubyspec/fixtures/code/concurrent3.rb2
-rw-r--r--spec/rubyspec/fixtures/code/file_fixture.rb1
-rw-r--r--spec/rubyspec/fixtures/code/gem/load_fixture.rb1
-rw-r--r--spec/rubyspec/fixtures/code/line_fixture.rb5
-rw-r--r--spec/rubyspec/fixtures/code/load_ext_fixture.rb1
-rw-r--r--spec/rubyspec/fixtures/code/load_fixture1
-rw-r--r--spec/rubyspec/fixtures/code/load_fixture.bundle1
-rw-r--r--spec/rubyspec/fixtures/code/load_fixture.dll1
-rw-r--r--spec/rubyspec/fixtures/code/load_fixture.ext1
-rw-r--r--spec/rubyspec/fixtures/code/load_fixture.ext.bundle1
-rw-r--r--spec/rubyspec/fixtures/code/load_fixture.ext.dll1
-rw-r--r--spec/rubyspec/fixtures/code/load_fixture.ext.rb1
-rw-r--r--spec/rubyspec/fixtures/code/load_fixture.ext.so1
-rw-r--r--spec/rubyspec/fixtures/code/load_fixture.rb1
-rw-r--r--spec/rubyspec/fixtures/code/load_fixture.so1
-rw-r--r--spec/rubyspec/fixtures/code/load_wrap_method_fixture.rb9
-rw-r--r--spec/rubyspec/fixtures/code/methods_fixture.rb364
-rw-r--r--spec/rubyspec/fixtures/code/raise_fixture.rb1
-rw-r--r--spec/rubyspec/fixtures/code/recursive_load_fixture.rb5
-rw-r--r--spec/rubyspec/fixtures/code/recursive_require_fixture.rb3
-rw-r--r--spec/rubyspec/fixtures/code/symlink/symlink1.rb1
-rw-r--r--spec/rubyspec/fixtures/code/symlink/symlink2/symlink2.rb1
-rw-r--r--spec/rubyspec/fixtures/code/wrap_fixture.rb3
-rw-r--r--spec/rubyspec/fixtures/code_loading.rb26
-rw-r--r--spec/rubyspec/fixtures/constants.rb288
-rw-r--r--spec/rubyspec/fixtures/enumerator/classes.rb15
-rw-r--r--spec/rubyspec/fixtures/math/common.rb3
-rw-r--r--spec/rubyspec/fixtures/rational.rb11
-rw-r--r--spec/rubyspec/fixtures/reflection.rb352
38 files changed, 1375 insertions, 0 deletions
diff --git a/spec/rubyspec/fixtures/basicobject/method_missing.rb b/spec/rubyspec/fixtures/basicobject/method_missing.rb
new file mode 100644
index 0000000000..17a0fe904c
--- /dev/null
+++ b/spec/rubyspec/fixtures/basicobject/method_missing.rb
@@ -0,0 +1,55 @@
+module KernelSpecs
+ module ModuleNoMM
+ class << self
+ def method_public() :module_public_method end
+
+ def method_protected() :module_private_method end
+ protected :method_protected
+
+ def method_private() :module_private_method end
+ private :method_private
+ end
+ end
+
+ module ModuleMM
+ class << self
+ def method_missing(*args) :module_method_missing end
+
+ def method_public() :module_public_method end
+
+ def method_protected() :module_private_method end
+ protected :method_protected
+
+ def method_private() :module_private_method end
+ private :method_private
+ end
+ end
+
+ class ClassNoMM
+ class << self
+ def method_public() :class_public_method end
+
+ def method_protected() :class_private_method end
+ protected :method_protected
+
+ def method_private() :class_private_method end
+ private :method_private
+ end
+
+ def method_public() :instance_public_method end
+
+ def method_protected() :instance_private_method end
+ protected :method_protected
+
+ def method_private() :instance_private_method end
+ private :method_private
+ end
+
+ class ClassMM < ClassNoMM
+ class << self
+ def method_missing(*args) :class_method_missing end
+ end
+
+ def method_missing(*args) :instance_method_missing end
+ end
+end
diff --git a/spec/rubyspec/fixtures/class.rb b/spec/rubyspec/fixtures/class.rb
new file mode 100644
index 0000000000..9609eb6f3c
--- /dev/null
+++ b/spec/rubyspec/fixtures/class.rb
@@ -0,0 +1,136 @@
+module ClassSpecs
+
+ def self.sclass_with_block
+ class << self
+ yield
+ end
+ end
+
+ def self.sclass_with_return
+ class << self
+ return :inner
+ end
+ return :outer
+ end
+
+ class A; end
+
+ def self.string_class_variables(obj)
+ obj.class_variables.map { |x| x.to_s }
+ end
+
+ def self.string_instance_variables(obj)
+ obj.instance_variables.map { |x| x.to_s }
+ end
+
+ class B
+ @@cvar = :cvar
+ @ivar = :ivar
+
+ end
+
+ class C
+ def self.make_class_variable
+ @@cvar = :cvar
+ end
+
+ def self.make_class_instance_variable
+ @civ = :civ
+ end
+ end
+
+ class D
+ def make_class_variable
+ @@cvar = :cvar
+ end
+ end
+
+ class E
+ def self.cmeth() :cmeth end
+ def meth() :meth end
+
+ class << self
+ def smeth() :smeth end
+ end
+
+ CONSTANT = :constant!
+ end
+
+ class F; end
+ class F
+ def meth() :meth end
+ end
+ class F
+ def another() :another end
+ end
+
+ class G
+ def override() :nothing end
+ def override() :override end
+ end
+
+ class Container
+ class A; end
+ class B; end
+ end
+
+ O = Object.new
+ class << O
+ def smeth
+ :smeth
+ end
+ end
+
+ class H
+ def self.inherited(sub)
+ track_inherited << sub
+ end
+
+ def self.track_inherited
+ @inherited_modules ||= []
+ end
+ end
+
+ class K < H; end
+
+ class I
+ class J < self
+ end
+ end
+
+ class K
+ def example_instance_method
+ end
+ def self.example_class_method
+ end
+ end
+
+ class L; end
+
+ class M < L; end
+
+ # Can't use a method here because of class definition in method body error
+ ANON_CLASS_FOR_NEW = lambda do
+ Class.new do
+ class NamedInModule
+ end
+
+ def self.get_class_name
+ NamedInModule.name
+ end
+ end
+ end
+end
+
+class Class
+ def example_instance_method_of_class; end
+ def self.example_class_method_of_class; end
+end
+class << Class
+ def example_instance_method_of_singleton_class; end
+ def self.example_class_method_of_singleton_class; end
+end
+class Object
+ def example_instance_method_of_object; end
+ def self.example_class_method_of_object; end
+end
diff --git a/spec/rubyspec/fixtures/class_variables.rb b/spec/rubyspec/fixtures/class_variables.rb
new file mode 100644
index 0000000000..02ca042230
--- /dev/null
+++ b/spec/rubyspec/fixtures/class_variables.rb
@@ -0,0 +1,58 @@
+module ClassVariablesSpec
+
+ class ClassA
+ @@cvar_a = :cvar_a
+
+ def cvar_a
+ @@cvar_a
+ end
+
+ def cvar_a=(val)
+ @@cvar_a = val
+ end
+ end
+
+ class ClassB < ClassA; end
+
+ # Extended in ClassC
+ module ModuleM
+ @@cvar_m = :value
+
+ def cvar_m
+ @@cvar_m
+ end
+
+ def cvar_m=(val)
+ @@cvar_m = val
+ end
+ end
+
+ # Extended in ModuleO
+ module ModuleN
+ @@cvar_n = :value
+
+ def cvar_n
+ @@cvar_n
+ end
+
+ def cvar_n=(val)
+ @@cvar_n = val
+ end
+ end
+
+ module ModuleO
+ extend ModuleN
+ end
+
+ class ClassC
+ extend ModuleM
+
+ def self.cvar_defined?
+ self.class_variable_defined?(:@@cvar)
+ end
+
+ def self.cvar_c=(val)
+ @@cvar = val
+ end
+ end
+end
diff --git a/spec/rubyspec/fixtures/code/a/load_fixture.bundle b/spec/rubyspec/fixtures/code/a/load_fixture.bundle
new file mode 100644
index 0000000000..30b53d7c0c
--- /dev/null
+++ b/spec/rubyspec/fixtures/code/a/load_fixture.bundle
@@ -0,0 +1 @@
+ScratchPad << :ext_bundle
diff --git a/spec/rubyspec/fixtures/code/a/load_fixture.dll b/spec/rubyspec/fixtures/code/a/load_fixture.dll
new file mode 100644
index 0000000000..77c65b315b
--- /dev/null
+++ b/spec/rubyspec/fixtures/code/a/load_fixture.dll
@@ -0,0 +1 @@
+ScratchPad << :ext_dll
diff --git a/spec/rubyspec/fixtures/code/a/load_fixture.so b/spec/rubyspec/fixtures/code/a/load_fixture.so
new file mode 100644
index 0000000000..4d02dea086
--- /dev/null
+++ b/spec/rubyspec/fixtures/code/a/load_fixture.so
@@ -0,0 +1 @@
+ScratchPad << :ext_so
diff --git a/spec/rubyspec/fixtures/code/b/load_fixture.rb b/spec/rubyspec/fixtures/code/b/load_fixture.rb
new file mode 100644
index 0000000000..4a6e9c9601
--- /dev/null
+++ b/spec/rubyspec/fixtures/code/b/load_fixture.rb
@@ -0,0 +1 @@
+ScratchPad << :loaded
diff --git a/spec/rubyspec/fixtures/code/concurrent.rb b/spec/rubyspec/fixtures/code/concurrent.rb
new file mode 100644
index 0000000000..054b8fc055
--- /dev/null
+++ b/spec/rubyspec/fixtures/code/concurrent.rb
@@ -0,0 +1,12 @@
+ScratchPad.recorded << :con_pre
+Thread.current[:in_concurrent_rb] = true
+
+if t = Thread.current[:wait_for]
+ Thread.pass until t.backtrace && t.backtrace.any? { |call| call.include? 'require' }
+end
+
+if Thread.current[:con_raise]
+ raise "con1"
+end
+
+ScratchPad.recorded << :con_post
diff --git a/spec/rubyspec/fixtures/code/concurrent2.rb b/spec/rubyspec/fixtures/code/concurrent2.rb
new file mode 100644
index 0000000000..08a7264023
--- /dev/null
+++ b/spec/rubyspec/fixtures/code/concurrent2.rb
@@ -0,0 +1,8 @@
+ScratchPad.recorded << :con2_pre
+
+Thread.current[:in_concurrent_rb2] = true
+
+t = Thread.current[:concurrent_require_thread]
+Thread.pass until t[:in_concurrent_rb3]
+
+ScratchPad.recorded << :con2_post
diff --git a/spec/rubyspec/fixtures/code/concurrent3.rb b/spec/rubyspec/fixtures/code/concurrent3.rb
new file mode 100644
index 0000000000..edb441d15d
--- /dev/null
+++ b/spec/rubyspec/fixtures/code/concurrent3.rb
@@ -0,0 +1,2 @@
+ScratchPad.recorded << :con3
+Thread.current[:in_concurrent_rb3] = true
diff --git a/spec/rubyspec/fixtures/code/file_fixture.rb b/spec/rubyspec/fixtures/code/file_fixture.rb
new file mode 100644
index 0000000000..27388c7d8d
--- /dev/null
+++ b/spec/rubyspec/fixtures/code/file_fixture.rb
@@ -0,0 +1 @@
+ScratchPad << __FILE__
diff --git a/spec/rubyspec/fixtures/code/gem/load_fixture.rb b/spec/rubyspec/fixtures/code/gem/load_fixture.rb
new file mode 100644
index 0000000000..e1806de201
--- /dev/null
+++ b/spec/rubyspec/fixtures/code/gem/load_fixture.rb
@@ -0,0 +1 @@
+ScratchPad << :loaded_gem
diff --git a/spec/rubyspec/fixtures/code/line_fixture.rb b/spec/rubyspec/fixtures/code/line_fixture.rb
new file mode 100644
index 0000000000..2a2a0568cd
--- /dev/null
+++ b/spec/rubyspec/fixtures/code/line_fixture.rb
@@ -0,0 +1,5 @@
+ScratchPad << __LINE__
+
+# line 3
+
+ScratchPad << __LINE__
diff --git a/spec/rubyspec/fixtures/code/load_ext_fixture.rb b/spec/rubyspec/fixtures/code/load_ext_fixture.rb
new file mode 100644
index 0000000000..4a6e9c9601
--- /dev/null
+++ b/spec/rubyspec/fixtures/code/load_ext_fixture.rb
@@ -0,0 +1 @@
+ScratchPad << :loaded
diff --git a/spec/rubyspec/fixtures/code/load_fixture b/spec/rubyspec/fixtures/code/load_fixture
new file mode 100644
index 0000000000..1b76dc8cad
--- /dev/null
+++ b/spec/rubyspec/fixtures/code/load_fixture
@@ -0,0 +1 @@
+ScratchPad << :no_ext
diff --git a/spec/rubyspec/fixtures/code/load_fixture.bundle b/spec/rubyspec/fixtures/code/load_fixture.bundle
new file mode 100644
index 0000000000..30b53d7c0c
--- /dev/null
+++ b/spec/rubyspec/fixtures/code/load_fixture.bundle
@@ -0,0 +1 @@
+ScratchPad << :ext_bundle
diff --git a/spec/rubyspec/fixtures/code/load_fixture.dll b/spec/rubyspec/fixtures/code/load_fixture.dll
new file mode 100644
index 0000000000..77c65b315b
--- /dev/null
+++ b/spec/rubyspec/fixtures/code/load_fixture.dll
@@ -0,0 +1 @@
+ScratchPad << :ext_dll
diff --git a/spec/rubyspec/fixtures/code/load_fixture.ext b/spec/rubyspec/fixtures/code/load_fixture.ext
new file mode 100644
index 0000000000..f25b8e2951
--- /dev/null
+++ b/spec/rubyspec/fixtures/code/load_fixture.ext
@@ -0,0 +1 @@
+ScratchPad << :no_rb_ext
diff --git a/spec/rubyspec/fixtures/code/load_fixture.ext.bundle b/spec/rubyspec/fixtures/code/load_fixture.ext.bundle
new file mode 100644
index 0000000000..30b53d7c0c
--- /dev/null
+++ b/spec/rubyspec/fixtures/code/load_fixture.ext.bundle
@@ -0,0 +1 @@
+ScratchPad << :ext_bundle
diff --git a/spec/rubyspec/fixtures/code/load_fixture.ext.dll b/spec/rubyspec/fixtures/code/load_fixture.ext.dll
new file mode 100644
index 0000000000..77c65b315b
--- /dev/null
+++ b/spec/rubyspec/fixtures/code/load_fixture.ext.dll
@@ -0,0 +1 @@
+ScratchPad << :ext_dll
diff --git a/spec/rubyspec/fixtures/code/load_fixture.ext.rb b/spec/rubyspec/fixtures/code/load_fixture.ext.rb
new file mode 100644
index 0000000000..4a6e9c9601
--- /dev/null
+++ b/spec/rubyspec/fixtures/code/load_fixture.ext.rb
@@ -0,0 +1 @@
+ScratchPad << :loaded
diff --git a/spec/rubyspec/fixtures/code/load_fixture.ext.so b/spec/rubyspec/fixtures/code/load_fixture.ext.so
new file mode 100644
index 0000000000..4d02dea086
--- /dev/null
+++ b/spec/rubyspec/fixtures/code/load_fixture.ext.so
@@ -0,0 +1 @@
+ScratchPad << :ext_so
diff --git a/spec/rubyspec/fixtures/code/load_fixture.rb b/spec/rubyspec/fixtures/code/load_fixture.rb
new file mode 100644
index 0000000000..4a6e9c9601
--- /dev/null
+++ b/spec/rubyspec/fixtures/code/load_fixture.rb
@@ -0,0 +1 @@
+ScratchPad << :loaded
diff --git a/spec/rubyspec/fixtures/code/load_fixture.so b/spec/rubyspec/fixtures/code/load_fixture.so
new file mode 100644
index 0000000000..4d02dea086
--- /dev/null
+++ b/spec/rubyspec/fixtures/code/load_fixture.so
@@ -0,0 +1 @@
+ScratchPad << :ext_so
diff --git a/spec/rubyspec/fixtures/code/load_wrap_method_fixture.rb b/spec/rubyspec/fixtures/code/load_wrap_method_fixture.rb
new file mode 100644
index 0000000000..b617473b4d
--- /dev/null
+++ b/spec/rubyspec/fixtures/code/load_wrap_method_fixture.rb
@@ -0,0 +1,9 @@
+def top_level_method
+ ::ScratchPad << :load_wrap_loaded
+end
+
+begin
+ top_level_method
+rescue NameError
+ ::ScratchPad << :load_wrap_error
+end
diff --git a/spec/rubyspec/fixtures/code/methods_fixture.rb b/spec/rubyspec/fixtures/code/methods_fixture.rb
new file mode 100644
index 0000000000..d42b5e4018
--- /dev/null
+++ b/spec/rubyspec/fixtures/code/methods_fixture.rb
@@ -0,0 +1,364 @@
+def foo1
+end
+
+def foo2
+end
+
+def foo3
+end
+
+def foo4
+end
+
+def foo5
+end
+
+def foo6
+end
+
+def foo7
+end
+
+def foo8
+end
+
+def foo9
+end
+
+def foo10
+end
+
+def foo11
+end
+
+def foo12
+end
+
+def foo13
+end
+
+def foo14
+end
+
+def foo15
+end
+
+def foo16
+end
+
+def foo17
+end
+
+def foo18
+end
+
+def foo19
+end
+
+def foo20
+end
+
+def foo21
+end
+
+def foo22
+end
+
+def foo23
+end
+
+def foo24
+end
+
+def foo25
+end
+
+def foo26
+end
+
+def foo27
+end
+
+def foo28
+end
+
+def foo29
+end
+
+def foo30
+end
+
+def foo31
+end
+
+def foo32
+end
+
+def foo33
+end
+
+def foo34
+end
+
+def foo35
+end
+
+def foo36
+end
+
+def foo37
+end
+
+def foo38
+end
+
+def foo39
+end
+
+def foo40
+end
+
+def foo41
+end
+
+def foo42
+end
+
+def foo43
+end
+
+def foo44
+end
+
+def foo45
+end
+
+def foo46
+end
+
+def foo47
+end
+
+def foo48
+end
+
+def foo49
+end
+
+def foo50
+end
+
+def foo51
+end
+
+def foo52
+end
+
+def foo53
+end
+
+def foo54
+end
+
+def foo55
+end
+
+def foo56
+end
+
+def foo57
+end
+
+def foo58
+end
+
+def foo59
+end
+
+def foo60
+end
+
+def foo61
+end
+
+def foo62
+end
+
+def foo63
+end
+
+def foo64
+end
+
+def foo65
+end
+
+def foo66
+end
+
+def foo67
+end
+
+def foo68
+end
+
+def foo69
+end
+
+def foo70
+end
+
+def foo71
+end
+
+def foo72
+end
+
+def foo73
+end
+
+def foo74
+end
+
+def foo75
+end
+
+def foo76
+end
+
+def foo77
+end
+
+def foo78
+end
+
+def foo79
+end
+
+def foo80
+end
+
+def foo81
+end
+
+def foo82
+end
+
+def foo83
+end
+
+def foo84
+end
+
+def foo85
+end
+
+def foo86
+end
+
+def foo87
+end
+
+def foo88
+end
+
+def foo89
+end
+
+def foo90
+end
+
+def foo91
+end
+
+def foo92
+end
+
+def foo93
+end
+
+def foo94
+end
+
+def foo95
+end
+
+def foo96
+end
+
+def foo97
+end
+
+def foo98
+end
+
+def foo99
+end
+
+def foo100
+end
+
+def foo101
+end
+
+def foo102
+end
+
+def foo103
+end
+
+def foo104
+end
+
+def foo105
+end
+
+def foo106
+end
+
+def foo107
+end
+
+def foo108
+end
+
+def foo109
+end
+
+def foo110
+end
+
+def foo111
+end
+
+def foo112
+end
+
+def foo113
+end
+
+def foo114
+end
+
+def foo115
+end
+
+def foo116
+end
+
+def foo117
+end
+
+def foo118
+end
+
+def foo119
+end
+
+def foo120
+end
+
+def foo121
+end
+
+ScratchPad << :loaded
diff --git a/spec/rubyspec/fixtures/code/raise_fixture.rb b/spec/rubyspec/fixtures/code/raise_fixture.rb
new file mode 100644
index 0000000000..9419089a06
--- /dev/null
+++ b/spec/rubyspec/fixtures/code/raise_fixture.rb
@@ -0,0 +1 @@
+raise "Exception loading a file"
diff --git a/spec/rubyspec/fixtures/code/recursive_load_fixture.rb b/spec/rubyspec/fixtures/code/recursive_load_fixture.rb
new file mode 100644
index 0000000000..18b144d44a
--- /dev/null
+++ b/spec/rubyspec/fixtures/code/recursive_load_fixture.rb
@@ -0,0 +1,5 @@
+ScratchPad << :loaded
+
+if ScratchPad.recorded == [:loaded]
+ load File.expand_path("../recursive_load_fixture.rb", __FILE__)
+end
diff --git a/spec/rubyspec/fixtures/code/recursive_require_fixture.rb b/spec/rubyspec/fixtures/code/recursive_require_fixture.rb
new file mode 100644
index 0000000000..8842a6ad74
--- /dev/null
+++ b/spec/rubyspec/fixtures/code/recursive_require_fixture.rb
@@ -0,0 +1,3 @@
+require File.expand_path("../recursive_require_fixture.rb", __FILE__)
+
+ScratchPad << :loaded
diff --git a/spec/rubyspec/fixtures/code/symlink/symlink1.rb b/spec/rubyspec/fixtures/code/symlink/symlink1.rb
new file mode 100644
index 0000000000..6a006eef14
--- /dev/null
+++ b/spec/rubyspec/fixtures/code/symlink/symlink1.rb
@@ -0,0 +1 @@
+require_relative 'symlink2/symlink2'
diff --git a/spec/rubyspec/fixtures/code/symlink/symlink2/symlink2.rb b/spec/rubyspec/fixtures/code/symlink/symlink2/symlink2.rb
new file mode 100644
index 0000000000..4a6e9c9601
--- /dev/null
+++ b/spec/rubyspec/fixtures/code/symlink/symlink2/symlink2.rb
@@ -0,0 +1 @@
+ScratchPad << :loaded
diff --git a/spec/rubyspec/fixtures/code/wrap_fixture.rb b/spec/rubyspec/fixtures/code/wrap_fixture.rb
new file mode 100644
index 0000000000..b83a8970d7
--- /dev/null
+++ b/spec/rubyspec/fixtures/code/wrap_fixture.rb
@@ -0,0 +1,3 @@
+class LoadSpecWrap
+ ScratchPad << self
+end
diff --git a/spec/rubyspec/fixtures/code_loading.rb b/spec/rubyspec/fixtures/code_loading.rb
new file mode 100644
index 0000000000..d6cf0edb47
--- /dev/null
+++ b/spec/rubyspec/fixtures/code_loading.rb
@@ -0,0 +1,26 @@
+module CodeLoadingSpecs
+ # The #require instance method is private, so this class enables
+ # calling #require like obj.require(file). This is used to share
+ # specs between Kernel#require and Kernel.require.
+ class Method
+ def require(name)
+ super name
+ end
+
+ def load(name, wrap=false)
+ super
+ end
+ end
+
+ def self.spec_setup
+ @saved_loaded_features = $LOADED_FEATURES.clone
+ @saved_load_path = $LOAD_PATH.clone
+ ScratchPad.record []
+ end
+
+ def self.spec_cleanup
+ $LOADED_FEATURES.replace @saved_loaded_features
+ $LOAD_PATH.replace @saved_load_path
+ ScratchPad.clear
+ end
+end
diff --git a/spec/rubyspec/fixtures/constants.rb b/spec/rubyspec/fixtures/constants.rb
new file mode 100644
index 0000000000..e5b20596ef
--- /dev/null
+++ b/spec/rubyspec/fixtures/constants.rb
@@ -0,0 +1,288 @@
+# Contains all static code examples of all constants behavior in language and
+# library specs. The specs include language/constants_spec.rb and the specs
+# for Module#const_defined?, Module#const_get, Module#const_set,
+# Module#remove_const, Module#const_missing and Module#constants.
+#
+# Rather than defining a class structure for each example, a canonical set of
+# classes is used along with numerous constants, in most cases, a unique
+# constant for each facet of behavior. This potentially leads to some
+# redundancy but hopefully the minimal redundancy that includes reasonable
+# variety in class and module configurations, including hierarchy,
+# containment, inclusion, singletons and toplevel.
+#
+# Constants are numbered for for uniqueness. The CS_ prefix is uniformly used
+# and is to minimize clashes with other toplevel constants (see e.g. ModuleA
+# which is included in Object). Constant values are symbols. A numbered suffix
+# is used to distinguish constants with the same name defined in different
+# areas (e.g. CS_CONST10 has values :const10_1, :const10_2, etc.).
+#
+# Methods are named after the constants they reference (e.g. ClassA.const10
+# references CS_CONST10). Where it is reasonable to do so, both class and
+# instance methods are defined. This is an instance of redundancy (class
+# methods should behave no differently than instance methods) but is useful
+# for ensuring compliance in implementations.
+
+
+# This constant breaks the rule of defining all constants, classes, modules
+# inside a module namespace for the particular specs, however, it is needed
+# for completeness. No other constant of this name should be defined in the
+# specs.
+CS_CONST1 = :const1 # only defined here
+
+module ConstantSpecs
+
+ # Included at toplevel
+ module ModuleA
+ CS_CONST10 = :const10_1
+ CS_CONST12 = :const12_2
+ CS_CONST13 = :const13
+ CS_CONST21 = :const21_2
+ end
+
+ # Included in ParentA
+ module ModuleB
+ CS_CONST10 = :const10_9
+ CS_CONST11 = :const11_2
+ CS_CONST12 = :const12_1
+ end
+
+ # Included in ChildA
+ module ModuleC
+ CS_CONST10 = :const10_4
+ CS_CONST15 = :const15_1
+ end
+
+ # Included in ChildA metaclass
+ module ModuleH
+ CS_CONST10 = :const10_7
+ end
+
+ # Included in ModuleD
+ module ModuleM
+ CS_CONST10 = :const10_11
+ CS_CONST24 = :const24
+ end
+
+ # Included in ContainerA
+ module ModuleD
+ include ModuleM
+
+ CS_CONST10 = :const10_8
+ end
+
+ # The following classes/modules have all the constants set "statically".
+ # Contrast with the classes below where the constants are set as the specs
+ # are run.
+
+ class ClassA
+ CS_CONST10 = :const10_10
+ CS_CONST16 = :const16
+ CS_CONST17 = :const17_2
+ CS_CONST22 = :const22_1
+
+ def self.const_missing(const)
+ const
+ end
+
+ def self.constx; CS_CONSTX; end
+ def self.const10; CS_CONST10; end
+ def self.const16; ParentA.const16; end
+ def self.const22; ParentA.const22 { CS_CONST22 }; end
+
+ def const10; CS_CONST10; end
+ def constx; CS_CONSTX; end
+ end
+
+ class ParentA
+ include ModuleB
+
+ CS_CONST4 = :const4
+ CS_CONST10 = :const10_5
+ CS_CONST11 = :const11_1
+ CS_CONST15 = :const15_2
+ CS_CONST20 = :const20_2
+ CS_CONST21 = :const21_1
+ CS_CONST22 = :const22_2
+
+ def self.constx; CS_CONSTX; end
+ def self.const10; CS_CONST10; end
+ def self.const16; CS_CONST16; end
+ def self.const22; yield; end
+
+ def const10; CS_CONST10; end
+ def constx; CS_CONSTX; end
+ end
+
+ class ContainerA
+ include ModuleD
+
+ CS_CONST5 = :const5
+ CS_CONST10 = :const10_2
+ CS_CONST23 = :const23
+
+ class ChildA < ParentA
+ include ModuleC
+
+ class << self
+ include ModuleH
+
+ CS_CONST10 = :const10_6
+ CS_CONST14 = :const14_1
+ CS_CONST19 = :const19_1
+
+ def const19; CS_CONST19; end
+ end
+
+ CS_CONST6 = :const6
+ CS_CONST10 = :const10_3
+ CS_CONST19 = :const19_2
+
+ def self.const10; CS_CONST10; end
+ def self.const11; CS_CONST11; end
+ def self.const12; CS_CONST12; end
+ def self.const13; CS_CONST13; end
+ def self.const15; CS_CONST15; end
+ def self.const21; CS_CONST21; end
+
+ def const10; CS_CONST10; end
+ def const11; CS_CONST11; end
+ def const12; CS_CONST12; end
+ def const13; CS_CONST13; end
+ def const15; CS_CONST15; end
+ end
+
+ def self.const10; CS_CONST10; end
+
+ def const10; CS_CONST10; end
+ end
+
+ class ContainerA::ChildA
+ def self.const23; CS_CONST23; end
+ end
+
+ class ::Object
+ CS_CONST20 = :const20_1
+
+ module ConstantSpecs
+ class ContainerA
+ class ChildA
+ def self.const20; CS_CONST20; end
+ end
+ end
+ end
+ end
+
+ # Included in ParentB
+ module ModuleE
+ end
+
+ # Included in ChildB
+ module ModuleF
+ end
+
+ # Included in ContainerB
+ module ModuleG
+ end
+
+ # The following classes/modules have the same structure as the ones above
+ # but the constants are set as the specs are run.
+
+ class ClassB
+ def self.const201; CS_CONST201; end
+ def self.const209; ParentB.const209; end
+ def self.const210; ParentB.const210 { CS_CONST210 }; end
+
+ def const201; CS_CONST201; end
+ end
+
+ class ParentB
+ include ModuleE
+
+ def self.const201; CS_CONST201; end
+ def self.const209; CS_CONST209; end
+ def self.const210; yield; end
+
+ def const201; CS_CONST201; end
+ end
+
+ class ContainerB
+ include ModuleG
+
+ class ChildB < ParentB
+ include ModuleF
+
+ class << self
+ def const206; CS_CONST206; end
+ end
+
+ def self.const201; CS_CONST201; end
+ def self.const202; CS_CONST202; end
+ def self.const203; CS_CONST203; end
+ def self.const204; CS_CONST204; end
+ def self.const205; CS_CONST205; end
+ def self.const212; CS_CONST212; end
+ def self.const213; CS_CONST213; end
+
+ def const201; CS_CONST201; end
+ def const202; CS_CONST202; end
+ def const203; CS_CONST203; end
+ def const204; CS_CONST204; end
+ def const205; CS_CONST205; end
+ def const213; CS_CONST213; end
+ end
+
+ def self.const201; CS_CONST201; end
+ end
+
+ class ContainerB::ChildB
+ def self.const214; CS_CONST214; end
+ end
+
+ class ::Object
+ module ConstantSpecs
+ class ContainerB
+ class ChildB
+ def self.const211; CS_CONST211; end
+ end
+ end
+ end
+ end
+
+ # Constants
+ CS_CONST2 = :const2 # only defined here
+ CS_CONST17 = :const17_1
+
+ class << self
+ CS_CONST14 = :const14_2
+ end
+
+ # Singleton
+ a = ClassA.new
+ def a.const17; CS_CONST17; end
+ CS_CONST18 = a
+
+ b = ClassB.new
+ def b.const207; CS_CONST207; end
+ CS_CONST208 = b
+
+ # Methods
+ def self.get_const; self; end
+
+ def const10; CS_CONST10; end
+
+ class ClassC
+ CS_CONST1 = 1
+
+ class ClassE
+ CS_CONST2 = 2
+ end
+ end
+
+ class ClassD < ClassC
+ end
+
+ CS_PRIVATE = :cs_private
+ private_constant :CS_PRIVATE
+end
+
+include ConstantSpecs::ModuleA
diff --git a/spec/rubyspec/fixtures/enumerator/classes.rb b/spec/rubyspec/fixtures/enumerator/classes.rb
new file mode 100644
index 0000000000..6f285b8efa
--- /dev/null
+++ b/spec/rubyspec/fixtures/enumerator/classes.rb
@@ -0,0 +1,15 @@
+module EnumSpecs
+ class Numerous
+
+ include Enumerable
+
+ def initialize(*list)
+ @list = list.empty? ? [2, 5, 3, 6, 1, 4] : list
+ end
+
+ def each
+ @list.each { |i| yield i }
+ end
+ end
+
+end
diff --git a/spec/rubyspec/fixtures/math/common.rb b/spec/rubyspec/fixtures/math/common.rb
new file mode 100644
index 0000000000..024732fa7a
--- /dev/null
+++ b/spec/rubyspec/fixtures/math/common.rb
@@ -0,0 +1,3 @@
+class IncludesMath
+ include Math
+end
diff --git a/spec/rubyspec/fixtures/rational.rb b/spec/rubyspec/fixtures/rational.rb
new file mode 100644
index 0000000000..d0d05d0437
--- /dev/null
+++ b/spec/rubyspec/fixtures/rational.rb
@@ -0,0 +1,11 @@
+module RationalSpecs
+ class SubNumeric < Numeric
+ def initialize(value)
+ @value = Rational(value)
+ end
+
+ def to_r
+ @value
+ end
+ end
+end
diff --git a/spec/rubyspec/fixtures/reflection.rb b/spec/rubyspec/fixtures/reflection.rb
new file mode 100644
index 0000000000..fe004f6a82
--- /dev/null
+++ b/spec/rubyspec/fixtures/reflection.rb
@@ -0,0 +1,352 @@
+# These modules and classes are fixtures used by the Ruby reflection specs.
+# These include specs for methods:
+#
+# Module:
+# instance_methods
+# public_instance_methods
+# protected_instance_methods
+# private_instance_methods
+#
+# Kernel:
+# methods
+# public_methods
+# protected_methods
+# private_methods
+# singleton_methods
+#
+# The following naming scheme is used to keep the method names short and still
+# communicate the relevant facts about the methods:
+#
+# X[s]_VIS
+#
+# where
+#
+# X is the name of the module or class in lower case
+# s is the literal character 's' for singleton methods
+# VIS is the first three letters of the corresponding visibility
+# pub(lic), pro(tected), pri(vate)
+#
+# For example:
+#
+# l_pub is a public method on module L
+# ls_pri is a private singleton method on module L
+
+module ReflectSpecs
+ # An object with no singleton methods.
+ def self.o
+ mock("Object with no singleton methods")
+ end
+
+ # An object with singleton methods.
+ def self.os
+ obj = mock("Object with singleton methods")
+ class << obj
+ def os_pub; :os_pub; end
+
+ def os_pro; :os_pro; end
+ protected :os_pro
+
+ def os_pri; :os_pri; end
+ private :os_pri
+ end
+ obj
+ end
+
+ # An object extended with a module.
+ def self.oe
+ obj = mock("Object extended")
+ obj.extend M
+ obj
+ end
+
+ # An object with duplicate methods extended with a module.
+ def self.oed
+ obj = mock("Object extended")
+ obj.extend M
+
+ class << obj
+ def pub; :pub; end
+
+ def pro; :pro; end
+ protected :pro
+
+ def pri; :pri; end
+ private :pri
+ end
+
+ obj
+ end
+
+ # An object extended with two modules.
+ def self.oee
+ obj = mock("Object extended twice")
+ obj.extend M
+ obj.extend N
+ obj
+ end
+
+ # An object extended with a module including a module.
+ def self.oei
+ obj = mock("Object extended, included")
+ obj.extend N
+ obj
+ end
+
+ # A simple module.
+ module L
+ class << self
+ def ls_pub; :ls_pub; end
+
+ def ls_pro; :ls_pro; end
+ protected :ls_pro
+
+ def ls_pri; :ls_pri; end
+ private :ls_pri
+ end
+
+ def l_pub; :l_pub; end
+
+ def l_pro; :l_pro; end
+ protected :l_pro
+
+ def l_pri; :l_pri; end
+ private :l_pri
+ end
+
+ # A module with no singleton methods.
+ module K
+ end
+
+ # A simple module.
+ module M
+ class << self
+ def ms_pub; :ms_pub; end
+
+ def ms_pro; :ms_pro; end
+ protected :ms_pro
+
+ def ms_pri; :ms_pri; end
+ private :ms_pri
+ end
+
+ def m_pub; :m_pub; end
+
+ def m_pro; :m_pro; end
+ protected :m_pro
+
+ def m_pri; :m_pri; end
+ private :m_pri
+
+ def pub; :pub; end
+
+ def pro; :pro; end
+ protected :pro
+
+ def pri; :pri; end
+ private :pri
+ end
+
+ # A module including a module
+ module N
+ include M
+
+ class << self
+ def ns_pub; :ns_pub; end
+
+ def ns_pro; :ns_pro; end
+ protected :ns_pro
+
+ def ns_pri; :ns_pri; end
+ private :ns_pri
+ end
+
+ def n_pub; :n_pub; end
+
+ def n_pro; :n_pro; end
+ protected :n_pro
+
+ def n_pri; :n_pri; end
+ private :n_pri
+ end
+
+ # A simple class.
+ class A
+ class << self
+ def as_pub; :as_pub; end
+
+ def as_pro; :as_pro; end
+ protected :as_pro
+
+ def as_pri; :as_pri; end
+ private :as_pri
+
+ def pub; :pub; end
+
+ def pro; :pro; end
+ protected :pro
+
+ def pri; :pri; end
+ private :pri
+ end
+
+ def a_pub; :a_pub; end
+
+ def a_pro; :a_pro; end
+ protected :a_pro
+
+ def a_pri; :a_pri; end
+ private :a_pri
+ end
+
+ # A simple subclass.
+ class B < A
+ class << self
+ def bs_pub; :bs_pub; end
+
+ def bs_pro; :bs_pro; end
+ protected :bs_pro
+
+ def bs_pri; :bs_pri; end
+ private :bs_pri
+
+ def pub; :pub; end
+
+ def pro; :pro; end
+ protected :pro
+
+ def pri; :pri; end
+ private :pri
+ end
+
+ def b_pub; :b_pub; end
+
+ def b_pro; :b_pro; end
+ protected :b_pro
+
+ def b_pri; :b_pri; end
+ private :b_pri
+ end
+
+ # A subclass including a module.
+ class C < A
+ include M
+
+ class << self
+ def cs_pub; :cs_pub; end
+
+ def cs_pro; :cs_pro; end
+ protected :cs_pro
+
+ def cs_pri; :cs_pri; end
+ private :cs_pri
+
+ def pub; :pub; end
+
+ def pro; :pro; end
+ protected :pro
+
+ def pri; :pri; end
+ private :pri
+ end
+
+ def c_pub; :c_pub; end
+
+ def c_pro; :c_pro; end
+ protected :c_pro
+
+ def c_pri; :c_pri; end
+ private :c_pri
+ end
+
+ # A simple class including a module
+ class D
+ include M
+
+ class << self
+ def ds_pub; :ds_pub; end
+
+ def ds_pro; :ds_pro; end
+ protected :ds_pro
+
+ def ds_pri; :ds_pri; end
+ private :ds_pri
+ end
+
+ def d_pub; :d_pub; end
+
+ def d_pro; :d_pro; end
+ protected :d_pro
+
+ def d_pri; :d_pri; end
+ private :d_pri
+
+ def pub; :pub; end
+
+ def pro; :pro; end
+ protected :pro
+
+ def pri; :pri; end
+ private :pri
+ end
+
+ # A subclass of a class including a module.
+ class E < D
+ class << self
+ def es_pub; :es_pub; end
+
+ def es_pro; :es_pro; end
+ protected :es_pro
+
+ def es_pri; :es_pri; end
+ private :es_pri
+ end
+
+ def e_pub; :e_pub; end
+
+ def e_pro; :e_pro; end
+ protected :e_pro
+
+ def e_pri; :e_pri; end
+ private :e_pri
+
+ def pub; :pub; end
+
+ def pro; :pro; end
+ protected :pro
+
+ def pri; :pri; end
+ private :pri
+ end
+
+ # A subclass that includes a module of a class including a module.
+ class F < D
+ include L
+
+ class << self
+ def fs_pub; :fs_pub; end
+
+ def fs_pro; :fs_pro; end
+ protected :fs_pro
+
+ def fs_pri; :fs_pri; end
+ private :fs_pri
+ end
+
+ def f_pub; :f_pub; end
+
+ def f_pro; :f_pro; end
+ protected :f_pro
+
+ def f_pri; :f_pri; end
+ private :f_pri
+ end
+
+ # Class with no singleton methods.
+ class O
+ end
+
+ # Class extended with a module.
+ class P
+ end
+ P.extend M
+end