1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
eregon 2017-09-20 20:18:52 +00:00
parent 75bfc6440d
commit 1d15d5f080
4370 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,34 @@
module KernelSpecs
class CalleeTest
def f
__callee__
end
alias_method :g, :f
def in_block
(1..2).map { __callee__ }
end
define_method(:dm) do
__callee__
end
define_method(:dm_block) do
(1..2).map { __callee__ }
end
def from_send
send "__callee__"
end
def from_eval
eval "__callee__"
end
@@method = __callee__
def from_class_body
@@method
end
end
end

View file

@ -0,0 +1,34 @@
module KernelSpecs
class MethodTest
def f
__method__
end
alias_method :g, :f
def in_block
(1..2).map { __method__ }
end
define_method(:dm) do
__method__
end
define_method(:dm_block) do
(1..2).map { __method__ }
end
def from_send
send "__method__"
end
def from_eval
eval "__method__"
end
@@method = __method__
def from_class_body
@@method
end
end
end

View file

@ -0,0 +1,5 @@
module KSAutoloadB
def self.loaded
:ksautoload_b
end
end

View file

@ -0,0 +1,5 @@
module KSAutoloadC
def self.loaded
:ksautoload_c
end
end

View file

@ -0,0 +1,5 @@
module KSAutoloadD
def self.loaded
:ksautoload_d
end
end

View file

@ -0,0 +1,7 @@
Object.freeze
begin
autoload :ANY_CONSTANT, "no_autoload.rb"
rescue Exception => e
print e.class, " - ", defined?(ANY_CONSTANT).inspect
end

View file

@ -0,0 +1,7 @@
module KernelSpecs
class CallerTest
def self.locations(*args)
caller(*args)
end
end
end

View file

@ -0,0 +1,7 @@
module KernelSpecs
class CallerLocationsTest
def self.locations(*args)
caller_locations(*args)
end
end
end

View file

@ -0,0 +1,4 @@
# -*- encoding: utf-8 -*-
$_ = "あれ\r\n"
print Kernel.chomp

View file

@ -0,0 +1,4 @@
# -*- encoding: utf-8 -*-
$_ = "あれ\r\n"
print chomp

View file

@ -0,0 +1,4 @@
# -*- encoding: utf-8 -*-
$_ = "あれ"
print Kernel.chop

View file

@ -0,0 +1,4 @@
# -*- encoding: utf-8 -*-
$_ = "あれ"
print chop

View file

@ -0,0 +1,419 @@
module KernelSpecs
def self.Array_function(arg)
Array(arg)
end
def self.Array_method(arg)
Kernel.Array(arg)
end
def self.Hash_function(arg)
Hash(arg)
end
def self.Hash_method(arg)
Kernel.Hash(arg)
end
def self.Integer_function(arg)
Integer(arg)
end
def self.Integer_method(arg)
Kernel.Integer(arg)
end
def self.putc_function(arg)
putc arg
end
def self.putc_method(arg)
Kernel.putc arg
end
def self.has_private_method(name)
IO.popen([*ruby_exe, "-n", "-e", "print Kernel.private_method_defined?(#{name.inspect})"], "r+") do |io|
io.puts
io.close_write
io.read
end == "true"
end
def self.chop(str, method)
IO.popen([*ruby_exe, "-n", "-e", "$_ = #{str.inspect}; #{method}; print $_"], "r+") do |io|
io.puts
io.close_write
io.read
end
end
def self.chomp(str, method, sep="\n")
code = "$_ = #{str.inspect}; $/ = #{sep.inspect}; #{method}; print $_"
IO.popen([*ruby_exe, "-n", "-e", code], "r+") do |io|
io.puts
io.close_write
io.read
end
end
def self.run_with_dash_n(file)
IO.popen([*ruby_exe, "-n", file], "r+") do |io|
io.puts
io.close_write
io.read
end
end
# kind_of?, is_a?, instance_of?
module SomeOtherModule; end
module AncestorModule; end
module MyModule; end
module MyExtensionModule; end
class AncestorClass < String
include AncestorModule
end
class InstanceClass < AncestorClass
include MyModule
end
class KindaClass < AncestorClass
include MyModule
def initialize
self.extend MyExtensionModule
end
end
class Method
public :abort, :exit, :exit!, :fork, :system
end
class Methods
module MetaclassMethods
def peekaboo
end
protected
def nopeeking
end
private
def shoo
end
end
def self.ichi; end
def ni; end
class << self
def san; end
end
private
def self.shi; end
def juu_shi; end
class << self
def roku; end
private
def shichi; end
end
protected
def self.hachi; end
def ku; end
class << self
def juu; end
protected
def juu_ichi; end
end
public
def self.juu_ni; end
def juu_san; end
end
class PrivateSup
def public_in_sub
end
private :public_in_sub
end
class PublicSub < PrivateSup
def public_in_sub
end
end
class A
# There is Kernel#public_method, so we don't want this one to clash
def pub_method; :public_method; end
def undefed_method; :undefed_method; end
undef_method :undefed_method
protected
def protected_method; :protected_method; end
private
def private_method; :private_method; end
public
define_method(:defined_method) { :defined }
end
class B < A
alias aliased_pub_method pub_method
end
class VisibilityChange
class << self
private :new
end
end
class Binding
@@super_secret = "password"
def initialize(n)
@secret = n
end
def square(n)
n * n
end
def get_binding
a = true
@bind = binding
# Add/Change stuff
b = true
@secret += 1
@bind
end
end
module BlockGiven
def self.accept_block
block_given?
end
def self.accept_block_as_argument(&block)
block_given?
end
class << self
define_method(:defined_block) do
block_given?
end
end
end
module SelfBlockGiven
def self.accept_block
self.send(:block_given?)
end
def self.accept_block_as_argument(&block)
self.send(:block_given?)
end
class << self
define_method(:defined_block) do
self.send(:block_given?)
end
end
end
module KernelBlockGiven
def self.accept_block
Kernel.block_given?
end
def self.accept_block_as_argument(&block)
Kernel.block_given?
end
class << self
define_method(:defined_block) do
Kernel.block_given?
end
end
end
class EvalTest
def self.eval_yield_with_binding
eval("yield", binding)
end
def self.call_yield
yield
end
end
module DuplicateM
def repr
self.class.name.to_s
end
end
class Duplicate
attr_accessor :one, :two
def initialize(one, two)
@one = one
@two = two
end
def initialize_copy(other)
ScratchPad.record object_id
end
end
class Clone
def initialize_clone(other)
ScratchPad.record other.object_id
end
end
class Dup
def initialize_dup(other)
ScratchPad.record other.object_id
end
end
module ParentMixin
def parent_mixin_method; end
end
class Parent
include ParentMixin
def parent_method; end
def another_parent_method; end
def self.parent_class_method; :foo; end
end
class Child < Parent
undef_method :parent_method
end
class Grandchild < Child
undef_method :parent_mixin_method
end
# for testing lambda
class Lambda
def outer
inner
end
def mp(&b); b; end
def inner
b = mp { return :good }
pr = lambda { |x| x.call }
pr.call(b)
# We shouldn't be here, b should have unwinded through
return :bad
end
end
class RespondViaMissing
def respond_to_missing?(method, priv=false)
case method
when :handled_publicly
true
when :handled_privately
priv
when :not_handled
false
else
raise "Typo in method name"
end
end
def method_missing(method, *args)
"Done #{method}(#{args})"
end
end
class InstanceVariable
def initialize
@greeting = "hello"
end
end
class PrivateToAry
private
def to_ary
[1, 2]
end
def to_a
[3, 4]
end
end
class PrivateToA
private
def to_a
[3, 4]
end
end
end
class EvalSpecs
class A
eval "class B; end"
def c
eval "class C; end"
end
end
class CoercedObject
def to_str
'2 + 3'
end
def hash
nil
end
end
def f
yield
end
def self.call_eval
f = __FILE__
eval "true", binding, "(eval)", 1
return f
end
end
# for Kernel#sleep to have Channel in it's specs
# TODO: switch directly to queue for both Kernel#sleep and Thread specs?
unless defined? Channel
require 'thread'
class Channel < Queue
alias receive shift
end
end

View file

@ -0,0 +1,6 @@
begin
eval("a = 2")
eval("p a")
rescue Object => e
puts e.class
end

View file

@ -0,0 +1,12 @@
print "a,"
x = lambda do
print "b,"
Proc.new do
print "c,"
eval("return :eval")
print "d,"
end.call
print "e,"
end.call
print x, ","
print "f"

View file

@ -0,0 +1,14 @@
print "a,"
begin
print "b,"
x = Proc.new do
print "c,"
eval("return :eval")
print "d,"
end.call
print x, ","
rescue LocalJumpError => e
print "e,"
print e.class, ","
end
print "f"

View file

@ -0,0 +1,362 @@
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