summaryrefslogtreecommitdiff
path: root/spec/ruby/optional/capi/fixtures
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/optional/capi/fixtures')
-rw-r--r--spec/ruby/optional/capi/fixtures/class.rb104
-rw-r--r--spec/ruby/optional/capi/fixtures/const_get.rb5
-rw-r--r--spec/ruby/optional/capi/fixtures/const_get_at.rb5
-rw-r--r--spec/ruby/optional/capi/fixtures/const_get_from.rb5
-rw-r--r--spec/ruby/optional/capi/fixtures/const_get_object.rb3
-rw-r--r--spec/ruby/optional/capi/fixtures/encoding.rb3
-rw-r--r--spec/ruby/optional/capi/fixtures/foo.rb1
-rw-r--r--spec/ruby/optional/capi/fixtures/kernel.rb19
-rw-r--r--spec/ruby/optional/capi/fixtures/module.rb39
-rw-r--r--spec/ruby/optional/capi/fixtures/module_autoload.rb4
-rw-r--r--spec/ruby/optional/capi/fixtures/object.rb29
-rw-r--r--spec/ruby/optional/capi/fixtures/path_to_class.rb6
-rw-r--r--spec/ruby/optional/capi/fixtures/proc.rb20
-rw-r--r--spec/ruby/optional/capi/fixtures/read.txt1
14 files changed, 244 insertions, 0 deletions
diff --git a/spec/ruby/optional/capi/fixtures/class.rb b/spec/ruby/optional/capi/fixtures/class.rb
new file mode 100644
index 0000000000..b463e3b4c3
--- /dev/null
+++ b/spec/ruby/optional/capi/fixtures/class.rb
@@ -0,0 +1,104 @@
+class CApiClassSpecs
+ module M
+ def included?
+ true
+ end
+ end
+
+ class Alloc
+ attr_reader :initialized
+ attr_reader :arguments
+
+ def initialize(*args)
+ @initialized = true
+ @arguments = args
+ end
+ end
+
+ class KeywordAlloc
+ attr_reader :initialized, :args, :kwargs
+
+ def initialize(*args, **kwargs)
+ @initialized = true
+ @args = args
+ @kwargs = kwargs
+ end
+ end
+
+ class Attr
+ def initialize
+ @foo, @bar, @baz = 1, 2, 3
+ end
+ end
+
+ class CVars
+ @@cvar = :cvar
+ @c_ivar = :c_ivar
+
+ def new_cv
+ @@new_cv if defined? @@new_cv
+ end
+
+ def new_cvar
+ @@new_cvar if defined? @@new_cvar
+ end
+
+ def rbdcv_cvar
+ @@rbdcv_cvar if defined? @@rbdcv_cvar
+ end
+ end
+
+ class Inherited
+ def self.inherited(klass)
+ klass
+ end
+ end
+
+ class NewClass
+ def self.inherited(klass)
+ raise "#{name}.inherited called"
+ end
+ end
+
+ class Super
+ def call_super_method
+ :super_method
+ end
+ end
+
+ class Sub < Super
+ def call_super_method
+ :subclass_method
+ end
+ end
+
+ class SubM < Super
+ include M
+ end
+
+ class SubSub < Sub
+ def call_super_method
+ :subsubclass_method
+ end
+ end
+
+ class SuperSelf
+ def call_super_method
+ self
+ end
+ end
+
+ class SubSelf < SuperSelf
+ end
+
+ class A
+ C = 1
+ autoload :D, File.expand_path('../path_to_class.rb', __FILE__)
+
+ class B
+ end
+
+ module M
+ end
+ end
+end
diff --git a/spec/ruby/optional/capi/fixtures/const_get.rb b/spec/ruby/optional/capi/fixtures/const_get.rb
new file mode 100644
index 0000000000..b261a07f7e
--- /dev/null
+++ b/spec/ruby/optional/capi/fixtures/const_get.rb
@@ -0,0 +1,5 @@
+class CApiModuleSpecs
+ class A
+ D = 123
+ end
+end
diff --git a/spec/ruby/optional/capi/fixtures/const_get_at.rb b/spec/ruby/optional/capi/fixtures/const_get_at.rb
new file mode 100644
index 0000000000..700b570607
--- /dev/null
+++ b/spec/ruby/optional/capi/fixtures/const_get_at.rb
@@ -0,0 +1,5 @@
+class CApiModuleSpecs
+ class A
+ B = 123
+ end
+end
diff --git a/spec/ruby/optional/capi/fixtures/const_get_from.rb b/spec/ruby/optional/capi/fixtures/const_get_from.rb
new file mode 100644
index 0000000000..9e297daba7
--- /dev/null
+++ b/spec/ruby/optional/capi/fixtures/const_get_from.rb
@@ -0,0 +1,5 @@
+class CApiModuleSpecs
+ class A
+ C = 123
+ end
+end
diff --git a/spec/ruby/optional/capi/fixtures/const_get_object.rb b/spec/ruby/optional/capi/fixtures/const_get_object.rb
new file mode 100644
index 0000000000..03d9365a3e
--- /dev/null
+++ b/spec/ruby/optional/capi/fixtures/const_get_object.rb
@@ -0,0 +1,3 @@
+class Object
+ CApiModuleSpecsAutoload = 123
+end
diff --git a/spec/ruby/optional/capi/fixtures/encoding.rb b/spec/ruby/optional/capi/fixtures/encoding.rb
new file mode 100644
index 0000000000..0858807aa0
--- /dev/null
+++ b/spec/ruby/optional/capi/fixtures/encoding.rb
@@ -0,0 +1,3 @@
+class CApiEncodingSpecs
+ class S < String; end
+end
diff --git a/spec/ruby/optional/capi/fixtures/foo.rb b/spec/ruby/optional/capi/fixtures/foo.rb
new file mode 100644
index 0000000000..bc4e8f3f7d
--- /dev/null
+++ b/spec/ruby/optional/capi/fixtures/foo.rb
@@ -0,0 +1 @@
+$foo = 7
diff --git a/spec/ruby/optional/capi/fixtures/kernel.rb b/spec/ruby/optional/capi/fixtures/kernel.rb
new file mode 100644
index 0000000000..d3fc7c57e8
--- /dev/null
+++ b/spec/ruby/optional/capi/fixtures/kernel.rb
@@ -0,0 +1,19 @@
+class CApiKernelSpecs
+ class ClassWithPublicMethod
+ def public_method(*, **)
+ :public
+ end
+ end
+
+ class ClassWithPrivateMethod
+ private def private_method(*, **)
+ :private
+ end
+ end
+
+ class ClassWithProtectedMethod
+ protected def protected_method(*, **)
+ :protected
+ end
+ end
+end
diff --git a/spec/ruby/optional/capi/fixtures/module.rb b/spec/ruby/optional/capi/fixtures/module.rb
new file mode 100644
index 0000000000..aac8bfbfb3
--- /dev/null
+++ b/spec/ruby/optional/capi/fixtures/module.rb
@@ -0,0 +1,39 @@
+class Object
+ autoload :CApiModuleSpecsAutoload, File.expand_path('../const_get_object.rb', __FILE__)
+
+ module CApiModuleSpecsModuleA
+ X = 1
+ end
+end
+
+class CApiModuleSpecs
+ class A
+ autoload :B, File.expand_path('../const_get_at.rb', __FILE__)
+ autoload :C, File.expand_path('../const_get_from.rb', __FILE__)
+ autoload :D, File.expand_path('../const_get.rb', __FILE__)
+
+ X = 1
+ Q = 1
+ R = 2
+ S = 3
+ T = 5
+ end
+
+ class B < A
+ Y = 2
+ end
+
+ class C
+ Z = 3
+ end
+
+ module M
+ end
+
+ class Super
+ end
+
+ autoload :ModuleUnderAutoload, "#{object_path}/module_under_autoload_spec"
+ autoload :RubyUnderAutoload, File.expand_path('../module_autoload', __FILE__)
+
+end
diff --git a/spec/ruby/optional/capi/fixtures/module_autoload.rb b/spec/ruby/optional/capi/fixtures/module_autoload.rb
new file mode 100644
index 0000000000..8130a24421
--- /dev/null
+++ b/spec/ruby/optional/capi/fixtures/module_autoload.rb
@@ -0,0 +1,4 @@
+class CApiModuleSpecs
+ module RubyUnderAutoload
+ end
+end
diff --git a/spec/ruby/optional/capi/fixtures/object.rb b/spec/ruby/optional/capi/fixtures/object.rb
new file mode 100644
index 0000000000..a59f2309d8
--- /dev/null
+++ b/spec/ruby/optional/capi/fixtures/object.rb
@@ -0,0 +1,29 @@
+class CApiObjectSpecs
+ class IVars
+ def initialize
+ @a = 3
+ @b = 7
+ @c = 4
+ end
+
+ def self.set_class_variables
+ @@foo = :a
+ @@bar = :b
+ @@baz = :c
+ end
+ end
+
+ module MVars
+ @@mvar = :foo
+ @@mvar2 = :bar
+
+ @ivar = :baz
+ end
+
+ module CVars
+ @@cvar = :foo
+ @@cvar2 = :bar
+
+ @ivar = :baz
+ end
+end
diff --git a/spec/ruby/optional/capi/fixtures/path_to_class.rb b/spec/ruby/optional/capi/fixtures/path_to_class.rb
new file mode 100644
index 0000000000..acd577ff24
--- /dev/null
+++ b/spec/ruby/optional/capi/fixtures/path_to_class.rb
@@ -0,0 +1,6 @@
+class CApiClassSpecs
+ class A
+ module D
+ end
+ end
+end
diff --git a/spec/ruby/optional/capi/fixtures/proc.rb b/spec/ruby/optional/capi/fixtures/proc.rb
new file mode 100644
index 0000000000..fbe37312da
--- /dev/null
+++ b/spec/ruby/optional/capi/fixtures/proc.rb
@@ -0,0 +1,20 @@
+class CApiProcSpecs
+ def call_nothing
+ end
+
+ def call_Proc_new
+ Proc.new
+ end
+
+ def call_block_given?
+ block_given?
+ end
+
+ def call_rb_Proc_new
+ rb_Proc_new(0)
+ end
+
+ def call_rb_Proc_new_with_block
+ rb_Proc_new(0) { :calling_with_block }
+ end
+end
diff --git a/spec/ruby/optional/capi/fixtures/read.txt b/spec/ruby/optional/capi/fixtures/read.txt
new file mode 100644
index 0000000000..f7065a35d0
--- /dev/null
+++ b/spec/ruby/optional/capi/fixtures/read.txt
@@ -0,0 +1 @@
+fixture file contents to test read() with RSTRING_PTR