Permalink
Browse files

changes to support better CI specs

hat mini_rspec will take a filename as an exclude/include argument and read the actual excludes/includes from the file.
added that mspec will take -o FILE to use an alternate to STDOUT for the spec reporter output.
updated spec tasks. misc spec changes.
added naive implementation of IO#each.
  • Loading branch information...
1 parent 05e36a6 commit d0e6b658d9065b0fbc9180cd5d19139834f64f59 @brixen brixen committed Aug 19, 2007
View
23 Rakefile
@@ -74,6 +74,7 @@ end
# spec tasks
desc "Run continuous integration examples"
task :spec => 'spec:ci'
+
namespace :spec do
namespace :setup do
desc "Setup for subtend examples"
@@ -86,19 +87,9 @@ namespace :spec do
desc "Run continuous integration examples"
task :ci do
- begin
- stat = File.stat("CI-specs")
- if stat.file?
- raise "CI-specs is a file. Remove it to run CI specs"
- elsif stat.directory?
- sh "svn up CI-specs"
- end
- rescue
- sh("svn co http://code.fallingsnow.net/svn/rubinius/branches/CI-specs")
- end
target = ENV['SPEC_TARGET'] || 'rbx'
system %(shotgun/rubinius -e 'puts "rbx build: \#{Rubinius::BUILDREV}"') if target == 'rbx'
- sh "bin/mspec -t #{target} -f ci CI-specs"
+ sh "bin/mspec -t #{target} -f ci -x spec/reports/ci-excludes.txt spec"
end
spec_targets = %w(compiler core language library parser rubinius)
@@ -112,7 +103,7 @@ namespace :spec do
desc "Run subtend examples"
task :subtend => "spec:setup:subtend" do
- sh "bin/mspec spec/subtend"
+ sh "bin/mspec spec/rubinius/subtend"
end
# Specdiffs to make it easier to see what your changes have affected :)
@@ -122,14 +113,14 @@ namespace :spec do
namespace :diff do
desc 'Run specs and produce a diff against current base'
task :run do
- system 'bin/mspec spec > /tmp/rbs_specdiff'
- system 'diff -u spec/diffs/base.txt /tmp/rbs_specdiff'
- system 'rm /tmp/rbs_specdiff'
+ system 'bin/mspec -f ci -o spec/reports/specdiff.txt spec'
+ system 'diff -u spec/reports/base.txt spec/reports/specdiff.txt'
+ system 'rm spec/reports/specdiff.txt'
end
desc 'Replace the base spec file with a new one'
task :replace do
- system 'bin/mspec spec > spec/diffs/base.txt'
+ system 'bin/mspec -f ci -o spec/reports/base.txt spec'
end
end
View
7 bin/mspec
@@ -16,6 +16,7 @@ requires = ['-rmini_rspec.rb', '-rmini_mock.rb']
except = []
only = []
name = nil
+output = nil
target = 'shotgun/rubinius'
format = 'DottedReporter'
@@ -69,6 +70,10 @@ opts = OptionParser.new("", 24, ' ') do |opts|
"Overrides the name used to determine the implementation") do |n|
name = "RUBY_NAME = \"#{n}\";"
end
+ opts.on("-o", "--output FILE", String,
+ "Reporter output will be sent to FILE") do |f|
+ output = f
+ end
opts.on("-e", "--example RE", String,
"Execute example(s) with descriptions matching RE") do |r|
only << r
@@ -104,7 +109,7 @@ end
cmd = <<-EOC
#{target} #{includes.join(" ")} #{requires.join(" ")} -e '#{name}
-@runner = SpecRunner.new(#{format}.new);
+@runner = SpecRunner.new(#{format}.new(#{output.inspect if output}));
@runner.only(*#{only.inspect});
@runner.except(*#{except.inspect});
#{files.inspect}.each { |f| load f }'
View
8 kernel/core/00io.rb
@@ -78,7 +78,7 @@ def sync
true
end
- def gets
+ def gets(sep=$/)
cur = read(1)
return nil unless cur
out = cur
@@ -91,6 +91,12 @@ def gets
return out
end
+ def each(sep=$/)
+ while line = gets(sep)
+ yield line
+ end
+ end
+
def self.pipe
lhs = IO.allocate
rhs = IO.allocate
View
BIN runtime/core.rba
Binary file not shown.
View
142 spec/compiler/rubinius/compiler_spec.rb
@@ -13,122 +13,122 @@ def compile(sexp)
@method = @compiler.compile_as_method(sexp, :test)
end
- it "should compile the sexpression to a method" do
+ it "compiles the sexpression to a method" do
compile [:and, [:true], [:false]]
@method.kind_of?(Bytecode::MethodDescription).should == true
@method.name.should == :test
@method.assembly.kind_of?(String).should == true
end
- it "should compile true" do
+ it "compiles true" do
compile [:true]
@method.assembly.should == "push true\nret\n"
end
- it "should compile false" do
+ it "compiles false" do
compile [:false]
@method.assembly.should == "push false\nret\n"
end
- it "should compile nil" do
+ it "compiles nil" do
compile [:nil]
@method.assembly.should == "push nil\nret\n"
end
- it "should compile or" do
+ it "compiles or" do
compile [:or, [:true], [:false]]
@method.assembly.should ==
"push true\ndup\ngit lbl1\npop\npush false\nlbl1:\nret\n"
end
- it "should compile not" do
+ it "compiles not" do
compile [:not, [:true]]
@method.assembly.should ==
"push true\ngit lbl1\npush true\ngoto lbl2\nlbl1:\npush false\nlbl2:\nret\n"
end
- it "should compile a number literal" do
+ it "compiles a number literal" do
compile [:lit, 9]
@method.assembly.should == "push 9\nret\n"
end
- it "should compile a symbol literal" do
+ it "compiles a symbol literal" do
compile [:lit, :blah]
@method.assembly.should == "push_literal 0\nret\n"
end
- it "should compile a regexp literal" do
+ it "compiles a regexp literal" do
compile [:lit, /hello/]
@method.assembly.should ==
"push 16\npush_literal 0\npush Regexp\nsend new 2\nret\n"
end
- it "should compile if" do
+ it "compiles if" do
compile [:if, [:true], [:lit, 9], [:lit, 10]]
@method.assembly.should ==
"push true\ngif lbl1\npush 9\ngoto lbl2\nlbl1:\npush 10\nlbl2:\nret\n"
end
- it "should compile if with no else" do
+ it "compiles if with no else" do
compile [:if, [:true], [:lit, 9]]
@method.assembly.should ==
"push true\ngif lbl1\npush 9\ngoto lbl2\nlbl1:\npush nil\nlbl2:\nret\n"
end
- it "should compile if with no then" do
+ it "compiles if with no then" do
compile [:if, [:true], nil, [:lit, 10]]
@method.assembly.should ==
"push true\ngit lbl1\npush 10\ngoto lbl2\nlbl1:\npush nil\nlbl2:\nret\n"
end
- it "should compile a block" do
+ it "compiles a block" do
compile [:block, [:true], [:lit, 11]]
@method.assembly.should == "push true\npop\npush 11\nret\n"
end
- it "should compile scope" do
+ it "compiles scope" do
compile [:scope, [:true]]
@method.assembly.should == "push true\nret\n"
end
- it "should compile while" do
+ it "compiles while" do
compile [:while, [:true], [:lit, 10]]
@method.assembly.should ==
"lbl1:\npush true\ngif lbl2\nlbl3:\npush 10\npop\ngoto lbl1\nlbl2:\npush nil\nret\n"
end
- it "should compile until" do
+ it "compiles until" do
compile [:until, [:true], [:lit, 10]]
@method.assembly.should ==
"lbl1:\npush true\ngit lbl2\nlbl3:\npush 10\npop\ngoto lbl1\nlbl2:\npush nil\nret\n"
end
- it "should compile lasgn" do
+ it "compiles lasgn" do
compile [:lasgn, :x, 8, [:false]]
@method.assembly.should == "push false\nset x:2\nret\n"
end
- it "should compile lvar" do
+ it "compiles lvar" do
compile [:lvar, :x, 8]
@method.assembly.should == "push x:2\nret\n"
end
- it "should compile an array literal" do
+ it "compiles an array literal" do
compile [:array, [:lit, 99]]
@method.assembly.should == "push 99\nmake_array 1\nret\n"
end
- it "should compile zarray" do
+ it "compiles zarray" do
compile [:zarray]
@method.assembly.should == "make_array 0\nret\n"
end
- it "should compile to_ary" do
+ it "compiles to_ary" do
compile [:to_ary, [:lit, 8]]
@method.assembly.should == "push 8\ncast_array\nret\n"
end
- it "should compile a simple rescue" do
+ it "compiles a simple rescue" do
compile [:rescue, [:true], [:resbody, nil, [:lit, 2], nil]]
@method.assembly.should ==
"lbl4:\n#exc_start exc1\npush true\ngoto lbl2\n#exceptions exc1\n" \
@@ -137,7 +137,7 @@ def compile(sexp)
"lbl2:\nclear_exception\n#exc_end exc1\nret\n"
end
- it "should compile rescue with two resbodies" do
+ it "compiles rescue with two resbodies" do
compile [:rescue, [:true], [:resbody, nil, [:lit, 2], [:resbody, nil, [:lit, 3]]]]
@method.assembly.should ==
"lbl4:\n#exc_start exc1\npush true\ngoto lbl2\n#exceptions exc1\n" \
@@ -149,7 +149,7 @@ def compile(sexp)
"lbl2:\nclear_exception\n#exc_end exc1\nret\n"
end
- it "should compile rescue with multiple classes" do
+ it "compiles rescue with multiple classes" do
compile [:rescue, [:true], [:resbody,
[:array, [:const, :Blah], [:const, :Bleh]], [:lit, 4]]]
@method.assembly.should ==
@@ -162,45 +162,45 @@ def compile(sexp)
"lbl2:\nclear_exception\n#exc_end exc1\nret\n"
end
- it "should compile argscat" do
+ it "compiles argscat" do
compile [:argscat, [:array, [:lit, 1], [:lit, 2]], [:lit, 99]]
@method.assembly.should == "push 99\ncast_array_for_args 2\npush_array\npush 2\npush 1\nret\n"
end
- it "should compile call with argscat" do
+ it "compiles call with argscat" do
compile [:call, [:self], :b, [:argscat, [:array, [:lit, 1], [:lit, 2]], [:lit, 99]]]
@method.assembly.should ==
"push 99\ncast_array_for_args 2\npush_array\npush 2\npush 1\nget_args\npush nil\n" \
"swap\npush self\nswap\nset_args\nsend b +\nret\n"
end
- it "should compile call with argscat and newline" do
+ it "compiles call with argscat and newline" do
compile [:call, [:const, :Hash], :[], [:newline, 1, "(eval)", [:argscat, [:array, [:lit, 1], [:lit, 2]]]]]
@method.assembly.should == "cast_array_for_args 2\npush_array\npush 2\npush 1\nget_args\npush nil\nswap\npush Hash\nswap\nset_args\nsend [] +\nret\n"
end
- it "should compile yield" do
+ it "compiles yield" do
compile [:yield, [:array, [:lit, 1], [:lit, 2]], false]
@method.assembly.should ==
"push 2\npush 1\npush_block\nsend call 2\nret\n"
end
- it "should compile yield with a splat" do
+ it "compiles yield with a splat" do
compile [:yield, [:splat, [:array, [:lit, 5], [:lit, 6]]], true]
@method.assembly.should == "push 5\npush 6\nmake_array 2\ncast_array_for_args 0\npush_array\nget_args\npush_block\nsend call +\nret\n"
end
- it "should compile ivar" do
+ it "compiles ivar" do
compile [:ivar, :@blah]
@method.assembly.should == "push @blah\nret\n"
end
- it "should compile iasgn" do
+ it "compiles iasgn" do
compile [:iasgn, :@blah, [:lit, 99]]
@method.assembly.should == "push 99\nset @blah\nret\n"
end
- it "should compile ivar_as_index" do
+ it "compiles ivar_as_index" do
compile [:class, [:colon2, :B], nil,
[:scope, [:block,
[:fcall, :ivar_as_index, [:array,
@@ -222,37 +222,37 @@ def compile(sexp)
"check_argcount 0 0\npush_my_field 1\npop\npush 11\nstore_my_field 1\nret\n"
end
- it "should compile a hash literal" do
+ it "compiles a hash literal" do
compile [:hash, [:lit, 1], [:lit, 2], [:lit, 3], [:lit, 4]]
@method.assembly.should == "push 4\npush 3\npush 2\npush 1\nmake_hash 4\nret\n"
end
- it "should compile colon2" do
+ it "compiles colon2" do
compile [:colon2, [:const, :B], :A]
@method.assembly.should == "push B\nfind A\nret\n"
end
- it "should compile colon3" do
+ it "compiles colon3" do
compile [:colon3, :A]
@method.assembly.should == "push_cpath_top\nfind A\nret\n"
end
- it "should compile const" do
+ it "compiles const" do
compile [:const, :A]
@method.assembly.should == "push A\nret\n"
end
- it "should compile cdecl" do
+ it "compiles cdecl" do
compile [:cdecl, :Blah, [:lit, 8], nil]
@method.assembly.should == "push 8\nset Blah\nret\n"
end
- it "should compile cdecl with path" do
+ it "compiles cdecl with path" do
compile [:cdecl, nil, [:lit, 8], [:colon2, [:const, :A], :Blah]]
@method.assembly.should == "push A\npush 8\nset +Blah\nret\n"
end
- it "should compile class" do
+ it "compiles class" do
compile [:class, [:colon2, :Blah], nil, [:scope, [:true]]]
@method.assembly.should ==
"push nil\nopen_class Blah\ndup\npush_literal 0\nswap\n" \
@@ -263,7 +263,7 @@ def compile(sexp)
m.assembly.should == "push self\nset_encloser\npush true\nret\n"
end
- it "should compile class with sugar" do
+ it "compiles class with sugar" do
compile [:class, [:colon2, :Blah], [:colon2, [:const, :A], :B], [:scope, [:true]]]
@method.assembly.should == "push A\nfind B\n" \
"open_class Blah\ndup\npush_literal 0\nswap\n" \
@@ -274,7 +274,7 @@ def compile(sexp)
m.assembly.should == "push self\nset_encloser\npush true\nret\n"
end
- it "should compile class at cpath" do
+ it "compiles class at cpath" do
compile [:class, [:colon2, [:const, :A], :Blah], nil, [:scope, [:true]]]
@method.assembly.should ==
"push A\npush nil\nopen_class_under Blah\ndup\npush_literal 0\nswap\n" \
@@ -285,7 +285,7 @@ def compile(sexp)
m.assembly.should == "push self\nset_encloser\npush true\nret\n"
end
- it "should compile module" do
+ it "compiles module" do
compile [:module, [:colon2, :A], [:scope, [:true]]]
@method.assembly.should ==
"open_module A\ndup\npush_literal 0\nswap\n" \
@@ -296,7 +296,7 @@ def compile(sexp)
m.assembly.should == "push self\nset_encloser\npush true\nret\n"
end
- it "should compile module at cpath" do
+ it "compiles module at cpath" do
compile [:module, [:colon2, [:const, :B], :A], [:scope, [:true]]]
@method.assembly.should ==
"push B\nopen_module_under A\ndup\npush_literal 0\nswap\n" \
@@ -307,17 +307,17 @@ def compile(sexp)
m.assembly.should == "push self\nset_encloser\npush true\nret\n"
end
- it "should compile return" do
+ it "compiles return" do
compile [:return, [:lit, 8]]
@method.assembly.should == "push 8\nret\nret\n"
end
- it "should compile ensure" do
+ it "compiles ensure" do
compile [:ensure, [:lit, 10], [:lit, 11]]
@method.assembly.should == "#exc_start exc1\npush 10\n#exceptions exc1\npush_exception\n#exc_start exc2\npush 11\npop\ngoto lbl3\n#exceptions exc2\ngit lbl4\npop\nlbl4:\npush_exception\nlbl3:\n#exc_end exc2\ndup\ngif lbl5\nraise_exc\nlbl5:\npop\n#exc_end exc1\nret\n"
end
- it "should compile defn" do
+ it "compiles defn" do
compile [:defn, :blah, [:scope, [:block,
[:args, [:a, :b], [], nil, nil],
[:true]],
@@ -330,7 +330,7 @@ def compile(sexp)
"check_argcount 2 2\nset a:2\npop\nset b:3\npop\npush true\nret\n"
end
- it "should compile defn with splat" do
+ it "compiles defn with splat" do
compile [:defn, :blah, [:scope, [:block,
[:args, [:a, :b], [], [:c, 4], nil],
[:true]],
@@ -344,7 +344,7 @@ def compile(sexp)
"push true\nret\n"
end
- it "should compile defn with default" do
+ it "compiles defn with default" do
compile [:defn, :blah,
[:scope,
[:block,
@@ -360,7 +360,7 @@ def compile(sexp)
"set1:\nset b:3\npop\npush false\npop\npush true\nret\n"
end
- it "should compile defn with block arg" do
+ it "compiles defn with block arg" do
compile [:defn, :blah,
[:scope,
[:block,
@@ -377,7 +377,7 @@ def compile(sexp)
"\npop\npush true\nret\n"
end
- it "should compile defn with primitive" do
+ it "compiles defn with primitive" do
compile [:defn, :blah, [:scope, [:block,
[:args, [:a, :b], [], nil, nil],
[:call, [:const, :Ruby], :primitive, [:array, [:lit, :at]]],
@@ -391,7 +391,7 @@ def compile(sexp)
defn.primitive.should == :at
end
- it "should compile defn with inline bytecodes" do
+ it "compiles defn with inline bytecodes" do
compile [:defn, :blah, [:scope, [:block,
[:args, [:a, :b], [], nil, nil],
[:true],
@@ -404,7 +404,7 @@ def compile(sexp)
defn.assembly.should == "check_argcount 2 2\nset a:2\npop\nset b:3\npop\npush true\npop\npush self\nret\n"
end
- it "should compile defs" do
+ it "compiles defs" do
compile [:defs, [:const, :Object], :blah, [:scope, [:block,
[:args, [:a, :b], [], nil, nil],
[:true]],
@@ -416,7 +416,7 @@ def compile(sexp)
@method.assembly.should == "push_literal 0\npush Object\nattach_method blah\nret\n"
end
- it "should compile masgn with no splat" do
+ it "compiles masgn with no splat" do
compile [:masgn,
[:array, [:lasgn, :a, 2], [:lasgn, :b, 3], [:lasgn, :c, 4]],
nil,
@@ -427,7 +427,7 @@ def compile(sexp)
"unshift_tuple\nset c:4\npop\npop\npush true\nret\n"
end
- it "should compile masgn with splat" do
+ it "compiles masgn with splat" do
compile [:masgn,
[:array, [:lasgn, :a, 2], [:lasgn, :b, 3]],
[:lasgn, :c, 4],
@@ -438,7 +438,7 @@ def compile(sexp)
"cast_array\nset c:4\npop\npop\npush true\nret\n"
end
- it "should compile masgn with array as the source" do
+ it "compiles masgn with array as the source" do
compile [:masgn,
[:array, [:lasgn, :a, 2], [:lasgn, :b, 3]],
nil,
@@ -448,7 +448,7 @@ def compile(sexp)
end
# TODO - Add correct asm expectation, remove should_raise
- it "should compile masgn with array as the source and too many lhs" do
+ it "compiles masgn with array as the source and too many lhs" do
should_raise(RuntimeError) {
compile [:masgn,
[:array, [:lasgn, :a, 2], [:lasgn, :b, 3], [:lasgn, :c, 4]],
@@ -458,7 +458,7 @@ def compile(sexp)
end
# TODO - Add correct asm expectation, remove should_raise
- it "should compile masgn with array as the source and too many rhs" do
+ it "compiles masgn with array as the source and too many rhs" do
should_raise(RuntimeError) {
compile [:masgn,
[:array, [:lasgn, :a, 2], [:lasgn, :b, 3]],
@@ -468,7 +468,7 @@ def compile(sexp)
end
# TODO - Add correct asm expectation, remove should_raise
- it "should compile masgn with array as source splat is stupid" do
+ it "compiles masgn with array as source splat is stupid" do
should_raise(RuntimeError) {
compile [:masgn,
[:array, [:lasgn, :a, 2], [:lasgn, :b, 3]],
@@ -477,17 +477,17 @@ def compile(sexp)
}
end
- it "should compile call" do
+ it "compiles call" do
compile [:call, [:self], :b, [:array, [:lit, 1], [:lit, 2]]]
@method.assembly.should == "push 2\npush 1\npush self\nsend b 2\nret\n"
end
- it "should compile block pass" do
+ it "compiles block pass" do
compile [:block_pass, [:lit, 10], [:fcall, :d, [:array, [:lit, 9]]]]
@method.assembly.should == "push 9\npush 10\npush self\n&send d 1\nlbl1:\nret\n"
end
- it "should compile iter" do
+ it "compiles iter" do
compile [:iter, [:fcall, :m], [:lasgn, :a, 0], [:block, [:dasgn_curr, :a],
[:true], [:fcall, :p, [:array, [:lit, 2]] ] ] ]
@method.assembly.should == "push &lbl1\npush &lbl2\ncreate_block 1\ngoto lbl3\n" \
@@ -497,12 +497,12 @@ def compile(sexp)
"set_call_flags 1\n&send m 0\nlbl1:\nret\n"
end
- it "should compile a string literal" do
+ it "compiles a string literal" do
compile [:str, "blah"]
@method.assembly.should == "push_literal 0\nstring_dup\nret\n"
end
- it "should compile dstr" do
+ it "compiles dstr" do
compile [:dstr, "blah ", [:evstr, [:lit, 1]], [:str, " more "], [:evstr, [:lit, 2]]]
@method.assembly.should ==
"push 2\nsend to_s\npush_literal 0\nstring_dup\npush 1\n" \
@@ -511,13 +511,13 @@ def compile(sexp)
"string_append\nret\n"
end
- it "should compile newline" do
+ it "compiles newline" do
compile [:newline, 7, "blah.rb", [:true]]
@method.assembly.should == "\#line 7\npush true\nret\n"
@method.file.should == "blah.rb"
end
- it "should compile correct lvars" do
+ it "compiles correct lvars" do
m1 = [:defn, :blah, [:scope, [:block,
[:args, [], [:fuck], nil, nil], [:true]], []]]
m2 = [:defn, :to_s,
@@ -540,14 +540,14 @@ def compile(sexp)
"pop\npush base:2\npush self\nsend based_to_s 1\nret\n"
end
- it "should compile a simple case" do
+ it "compiles a simple case" do
compile [:case, [:lit, 1], [[:when, [:array, [:const, :String]], [:lit, 9]]]]
@method.assembly.should ==
"push 1\ndup\npush String\nsend === 1\ngif lbl1\n" \
"push 9\nlbl1:\nswap\npop\nret\n"
end
- it "should compile a case with many when" do
+ it "compiles a case with many when" do
compile [:case, [:lit, 1], [
[:when, [:array, [:const, :String], [:const, :Fixnum]], [:lit, 9]],
[:when, [:array, [:const, :Blah]], [:lit, 3423]]
@@ -560,15 +560,15 @@ def compile(sexp)
"push 3423\nlbl2:\nswap\npop\nret\n"
end
- it "should compile case with else" do
+ it "compiles case with else" do
compile [:case, [:lit, 1], [[:when, [:array, [:const, :String]],
[:lit, 9]]], [:lit, 10]]
@method.assembly.should ==
"push 1\ndup\npush String\nsend === 1\ngif lbl1\n" \
"push 9\ngoto lbl2\nlbl1:\npush 10\nlbl2:\nswap\npop\nret\n"
end
- it "should compile case with else and multiple when" do
+ it "compiles case with else and multiple when" do
compile [:case, [:lit, 1], [
[:when, [:array, [:const, :String], [:const, :Fixnum]], [:lit, 9]],
[:when, [:array, [:const, :Blah], [:const, :Go]], [:lit, 3423]]
@@ -583,12 +583,12 @@ def compile(sexp)
"lbl3:\nswap\npop\nret\n"
end
- it "should compile dot2" do
+ it "compiles dot2" do
compile [:dot2, [:lit, 100], [:lit, 1]]
@method.assembly.should == "push 1\npush 100\npush Range\nsend new 2\nret\n"
end
- it "should compile dot3" do
+ it "compiles dot3" do
compile [:dot3, [:lit, 100], [:lit, 1]]
@method.assembly.should == "push true\npush 1\npush 100\npush Range\nsend new 3\nret\n"
end
View
10 spec/core/array_spec.rb
@@ -227,7 +227,7 @@ def obj.to_ary() [1, 2, 3] end
([ 1, 2, 3 ] * ",").should == [1, 2, 3].join(",")
end
- it "handles recursive arrays like join" do
+ it "handles recursive arrays like #join" do
x = []
x << x
(x * ":").should == x.join(":")
@@ -3627,15 +3627,15 @@ class X; def to_s; "unnamed object"; end; end
[].pack('x').should == "\000"
end
- it "with count returns string of count zero chars with ('x')" do
+ it "returns string of count zero chars with count and ('x')" do
[].pack('x5').should == "\000\000\000\000\000"
end
- it "with count = 0 returns empty string with ('x')" do
+ it "returns empty string with count == 0 and ('x')" do
[].pack('x0').should == ""
end
- it "with star parameter behaves like with count = 0 with ('x')" do
+ it "behaves like with count == 0 with star parameter and ('x')" do
[].pack('x*').should == ""
end
@@ -3647,7 +3647,7 @@ class X; def to_s; "unnamed object"; end; end
['abcde'].pack('Z3').should == 'abc'
end
- it "consider count = 1 if count omited with ('Z')" do
+ it "considers count = 1 if count omited with ('Z')" do
['abcde'].pack('Z').should == 'a'
end
View
180 spec/core/kernel_spec.rb
@@ -290,4 +290,182 @@ def write(warning); @written << warning; end;
(rand(100) < 100).should == true
end
end
-end
+end
+
+describe "Kernel#instance_variable_get" do
+ it "returns the value of the instance variable" do
+ class Fred
+ def initialize(p1, p2)
+ @a, @b = p1, p2
+ end
+ end
+ fred = Fred.new('cat', 99)
+ fred.instance_variable_get(:@a).should == "cat"
+ fred.instance_variable_get("@b").should == 99
+
+ a = []
+ a.instance_variable_set(:@c, 1)
+ a.instance_variable_get(:@c).should == 1
+ end
+
+ it "returns nil if the instance variable does not exist" do
+ [].instance_variable_get(:@c).should == nil
+ end
+
+ it "raises NameError exception if the argument is not of form '@x'" do
+ class NoFred; end
+ should_raise(NameError) { NoFred.new.instance_variable_get(:c) }
+ should_raise(NameError) { [].instance_variable_get(:c) }
+ end
+end
+
+describe "Kernel#instance_variable_set" do
+ it "sets the value of the specified instance variable" do
+ class Dog
+ def initialize(p1, p2)
+ @a, @b = p1, p2
+ end
+ end
+ Dog.new('cat', 99).instance_variable_set(:@a, 'dog').should == "dog"
+ end
+
+ it "sets the value of the instance variable when no instance variables exist yet" do
+ class NoVariables; end
+ NoVariables.new.instance_variable_set(:@a, "new").should == "new"
+ end
+
+ it "raises NameError exception if the argument is not of form '@x'" do
+ class NoDog; end
+ should_raise(NameError) { NoDog.new.instance_variable_set(:c, "cat") }
+ end
+end
+
+describe "Array inherited instance method" do
+ it "instance_variable_get returns the value of the instance variable" do
+ a = []
+ a.instance_variable_set(:@c, 1)
+ a.instance_variable_get(:@c).should == 1
+ end
+
+ it "instance_variable_get returns nil if the instance variable does not exist" do
+ [].instance_variable_get(:@c).should == nil
+ end
+
+ it "instance_variable_get should raise NameError if the argument is not of form '@x'" do
+ should_raise(NameError) { [].instance_variable_get(:c) }
+ end
+end
+
+
+class KernelMethods
+ 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
+
+describe "Kernel#methods" do
+ it "returns a list of the names of publicly accessible methods in the object" do
+ KernelMethods.methods(false).sort.should ==
+ ["hachi", "ichi", "juu", "juu_ichi", "juu_ni", "roku", "san", "shi"]
+ KernelMethods.new.methods(false).should == []
+ end
+
+ it "returns a list of the names of publicly accessible methods in the object and its ancestors and mixed-in modules" do
+ (KernelMethods.methods(false) & KernelMethods.methods).sort.should ==
+ ["hachi", "ichi", "juu", "juu_ichi", "juu_ni", "roku", "san", "shi"]
+ m = KernelMethods.new.methods
+ m.should_include('ku')
+ m.should_include('ni')
+ m.should_include('juu_san')
+ end
+end
+
+describe "Kernel#singleton_methods" do
+ it "returns a list of the names of singleton methods in the object" do
+ KernelMethods.singleton_methods(false).sort.should ==
+ ["hachi", "ichi", "juu", "juu_ichi", "juu_ni", "roku", "san", "shi"]
+ KernelMethods.new.singleton_methods(false).should == []
+ end
+
+ it "returns a list of the names of singleton methods in the object and its ancestors and mixed-in modules" do
+ (KernelMethods.singleton_methods(false) & KernelMethods.singleton_methods).sort.should ==
+ ["hachi", "ichi", "juu", "juu_ichi", "juu_ni", "roku", "san", "shi"]
+ KernelMethods.new.singleton_methods.should == []
+ end
+end
+
+describe "Kernel#public_methods" do
+ it "returns a list of the names of publicly accessible methods in the object" do
+ KernelMethods.public_methods(false).sort.should ==
+ ["allocate", "hachi", "ichi", "juu", "juu_ni", "new", "roku", "san", "shi", "superclass"]
+ KernelMethods.new.public_methods(false).sort.should == ["juu_san", "ni"]
+ end
+
+ it "returns a list of the names of publicly accessible methods in the object and its ancestors and mixed-in modules" do
+ (KernelMethods.public_methods(false) & KernelMethods.public_methods).sort.should ==
+ ["allocate", "hachi", "ichi", "juu", "juu_ni", "new", "roku", "san", "shi", "superclass"]
+ m = KernelMethods.new.public_methods
+ m.should_include('ni')
+ m.should_include('juu_san')
+ end
+end
+
+describe "Kernel#private_methods" do
+ it "returns a list of the names of privately accessible methods in the object" do
+ KernelMethods.private_methods(false).sort.should ==
+ ["inherited", "initialize", "initialize_copy", "shichi"]
+ KernelMethods.new.private_methods(false).sort.should == ["juu_shi"]
+ end
+
+ it "returns a list of the names of privately accessible methods in the object and its ancestors and mixed-in modules" do
+ (KernelMethods.private_methods(false) & KernelMethods.private_methods).sort.should ==
+ ["inherited", "initialize", "initialize_copy", "shichi"]
+ m = KernelMethods.new.private_methods
+ m.should_include('juu_shi')
+ end
+end
+
+describe "Kernel#protected_methods" do
+ it "returns a list of the names of protected methods accessible in the object" do
+ KernelMethods.protected_methods(false).sort.should == ["juu_ichi"]
+ KernelMethods.new.protected_methods(false).should == ["ku"]
+ end
+
+ it "returns a list of the names of protected methods accessible in the object and from its ancestors and mixed-in modules" do
+ (KernelMethods.protected_methods(false) & KernelMethods.protected_methods).sort.should == ["juu_ichi"]
+ KernelMethods.new.protected_methods.should_include('ku')
+ end
+end
View
148 spec/core/object_spec.rb
@@ -161,41 +161,6 @@ def initialize
Klass.new.instance_eval("@secret").should == 99
end
- specify "instance_variable_get should return the value of the instance variable" do
- class Fred
- def initialize(p1, p2)
- @a, @b = p1, p2
- end
- end
- fred = Fred.new('cat', 99)
- fred.instance_variable_get(:@a).should == "cat"
- fred.instance_variable_get("@b").should == 99
- end
-
- specify "instance_variable_get should raise NameError exception if the argument is not of form '@x'" do
- class NoFred; end
- should_raise(NameError) { NoFred.new.instance_variable_get(:c) }
- end
-
- specify "instance_variable_set should set the value of the specified instance variable" do
- class Dog
- def initialize(p1, p2)
- @a, @b = p1, p2
- end
- end
- Dog.new('cat', 99).instance_variable_set(:@a, 'dog').should == "dog"
- end
-
- specify "instance_variable_set should set the value of the instance variable when no instance variables exist yet" do
- class NoVariables; end
- NoVariables.new.instance_variable_set(:@a, "new").should == "new"
- end
-
- specify "instance_variable_set should raise NameError exception if the argument is not of form '@x'" do
- class NoDog; end
- should_raise(NameError) { NoDog.new.instance_variable_set(:c, "cat") }
- end
-
specify "metaclass should return the object's metaclass" do
foo = "foo"
foo.instance_eval "class << self; def meta_test_method; 5; end; end"
@@ -421,116 +386,3 @@ def self.a_private_class_method
AClassWithProtectedMethodAndMetohdMissing.a_protected_class_method.should == :a_protected_class_method
end
end
-
-class ObjectMethods
- 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
-
-describe "Object#methods" do
- it "returns a list of the names of publicly accessible methods in the object" do
- ObjectMethods.methods(false).sort.should ==
- ["hachi", "ichi", "juu", "juu_ichi", "juu_ni", "roku", "san", "shi"]
- ObjectMethods.new.methods(false).should == []
- end
-
- it "returns a list of the names of publicly accessible methods in the object and its ancestors and mixed-in modules" do
- (ObjectMethods.methods(false) & ObjectMethods.methods).sort.should ==
- ["hachi", "ichi", "juu", "juu_ichi", "juu_ni", "roku", "san", "shi"]
- m = ObjectMethods.new.methods
- m.should_include('ku')
- m.should_include('ni')
- m.should_include('juu_san')
- end
-end
-
-describe "Object#singleton_methods" do
- it "returns a list of the names of singleton methods in the object" do
- ObjectMethods.singleton_methods(false).sort.should ==
- ["hachi", "ichi", "juu", "juu_ichi", "juu_ni", "roku", "san", "shi"]
- ObjectMethods.new.singleton_methods(false).should == []
- end
-
- it "returns a list of the names of singleton methods in the object and its ancestors and mixed-in modules" do
- (ObjectMethods.singleton_methods(false) & ObjectMethods.singleton_methods).sort.should ==
- ["hachi", "ichi", "juu", "juu_ichi", "juu_ni", "roku", "san", "shi"]
- ObjectMethods.new.singleton_methods.should == []
- end
-end
-
-describe "Object#public_methods" do
- it "returns a list of the names of publicly accessible methods in the object" do
- ObjectMethods.public_methods(false).sort.should ==
- ["allocate", "hachi", "ichi", "juu", "juu_ni", "new", "roku", "san", "shi", "superclass"]
- ObjectMethods.new.public_methods(false).sort.should == ["juu_san", "ni"]
- end
-
- it "returns a list of the names of publicly accessible methods in the object and its ancestors and mixed-in modules" do
- (ObjectMethods.public_methods(false) & ObjectMethods.public_methods).sort.should ==
- ["allocate", "hachi", "ichi", "juu", "juu_ni", "new", "roku", "san", "shi", "superclass"]
- m = ObjectMethods.new.public_methods
- m.should_include('ni')
- m.should_include('juu_san')
- end
-end
-
-describe "Object#private_methods" do
- it "returns a list of the names of privately accessible methods in the object" do
- ObjectMethods.private_methods(false).sort.should ==
- ["inherited", "initialize", "initialize_copy", "shichi"]
- ObjectMethods.new.private_methods(false).sort.should == ["juu_shi"]
- end
-
- it "returns a list of the names of privately accessible methods in the object and its ancestors and mixed-in modules" do
- (ObjectMethods.private_methods(false) & ObjectMethods.private_methods).sort.should ==
- ["inherited", "initialize", "initialize_copy", "shichi"]
- m = ObjectMethods.new.private_methods
- m.should_include('juu_shi')
- end
-end
-
-describe "Object#protected_methods" do
- it "returns a list of the names of protected methods accessible in the object" do
- ObjectMethods.protected_methods(false).sort.should == ["juu_ichi"]
- ObjectMethods.new.protected_methods(false).should == ["ku"]
- end
-
- it "returns a list of the names of protected methods accessible in the object and from its ancestors and mixed-in modules" do
- (ObjectMethods.protected_methods(false) & ObjectMethods.protected_methods).sort.should == ["juu_ichi"]
- ObjectMethods.new.protected_methods.should_include('ku')
- end
-end
View
53 spec/mini_rspec.rb
@@ -19,15 +19,15 @@ def exception
end
def describe=(d)
- @describe = d
+ @describe = d.to_s
end
def describe
@describe
end
def it=(i)
- @it = i
+ @it = i.to_s
end
def it
@@ -36,7 +36,11 @@ def it
end
def initialize(out=STDOUT)
- @out = out
+ if out.respond_to?(:print)
+ @out = out
+ else
+ @out = File.open(out, "w")
+ end
@examples = 0
@failures = 0
@exceptions = []
@@ -80,7 +84,7 @@ def print_summary
end
def print_failure(i,r)
- @out.print i.to_s + ")\n" + r.describe.to_s + " " + r.it.to_s + " FAILED\n"
+ @out.print i.to_s + ")\n" + r.describe + " " + r.it + " FAILED\n"
end
def print_backtrace(e)
@@ -109,7 +113,7 @@ def before_describe(msg)
def print_describe
unless @describe_printed
- @out.print "\n" + @describe + "\n"
+ @out.print "\n" + @describe.to_s + "\n"
@describe_printed = true
end
end
@@ -153,21 +157,24 @@ class HtmlReporter < SpecReporter
class CIReporter < SpecReporter
def print_failure(i,r)
- @out.print i.to_s + ") " + r.describe + " " + r.it + " FAILED\n"
+ @out.print r.describe + " " + r.it + "\n"
end
- def print_backtrace(e)
- end
-
- def warn(str)
+ def summary
+ unless @summarized
+ @exceptions.each_with_index do |r,i|
+ print_failure(i+1,r)
+ end
+ @summarized = true
+ end
end
end
class ImmediateReporter < SpecReporter
def after_it(msg)
if @report.exception
@out.print 'F'
- @out.print "\n" + @describe + " " + @report.it + " FAILED\n"
+ @out.print "\n" + @report.describe + " " + @report.it + " FAILED\n"
print_backtrace(@report.exception)
else
@out.print '.'
@@ -256,12 +263,32 @@ def reporter
@reporter
end
+ def escape(str)
+ Regexp.new(Regexp.escape(str))
+ end
+
+ def convert_to_regexps(args)
+ args.inject([]) do |list, item|
+ if File.exists?(item)
+ File.open(item, "r") do |f|
+ f.each do |line|
+ line.chomp!
+ list << Regexp.new(Regexp.escape(line)) unless line.empty?
+ end
+ end
+ list
+ else
+ list << escape(item)
+ end
+ end
+ end
+
def only(*args)
- @only = args.map { |a| Regexp.new(Regexp.escape(a)) }
+ @only = convert_to_regexps(args)
end
def except(*args)
- @except = args.map { |a| Regexp.new(Regexp.escape(a)) }
+ @except = convert_to_regexps(args)
end
def skip?
View
0 spec/diffs/base.txt → spec/reports/base.txt
File renamed without changes.
View
0 spec/reports/ci-excludes.txt
No changes.

0 comments on commit d0e6b65

Please sign in to comment.