[macruby-changes] [4718] DietRB/trunk/spec
source_changes at macosforge.org
source_changes at macosforge.org
Fri Oct 8 04:04:12 PDT 2010
Revision: 4718
http://trac.macosforge.org/projects/ruby/changeset/4718
Author: eloy.de.enige at gmail.com
Date: 2010-10-08 04:04:11 -0700 (Fri, 08 Oct 2010)
Log Message:
-----------
Move specs for ext libs into a ext sub dir.
From: Eloy Duran <eloy.de.enige at gmail.com>
Added Paths:
-----------
DietRB/trunk/spec/ext/
DietRB/trunk/spec/ext/colorize_spec.rb
DietRB/trunk/spec/ext/completion_spec.rb
DietRB/trunk/spec/ext/history_spec.rb
Removed Paths:
-------------
DietRB/trunk/spec/colorize_spec.rb
DietRB/trunk/spec/completion_spec.rb
DietRB/trunk/spec/history_spec.rb
Deleted: DietRB/trunk/spec/colorize_spec.rb
===================================================================
--- DietRB/trunk/spec/colorize_spec.rb 2010-10-08 11:04:00 UTC (rev 4717)
+++ DietRB/trunk/spec/colorize_spec.rb 2010-10-08 11:04:11 UTC (rev 4718)
@@ -1,58 +0,0 @@
-require File.expand_path('../spec_helper', __FILE__)
-require 'irb/ext/colorize'
-
-main = self
-
-describe "IRB::ColoredFormatter" do
- before do
- @formatter = IRB::ColoredFormatter.new
- @context = IRB::Context.new(main)
- end
-
- it "colorizes a constant" do
- @formatter.result(Hash).should == "=> \e[1;32mHash\e[0;0m"
- end
-
- it "colorizes a numeric" do
- @formatter.result(1).should == "=> \e[0;36m1\e[0;0m"
- @formatter.result(1.2).should == "=> \e[0;36m1.2\e[0;0m"
- end
-
- # Not Wirble compliant
- it "colorizes a Range" do
- # @formatter.result(1..3).should == "=> \e[0;36m1\e[0;0m\e[0;31m..\e[0;0m\e[0;36m3\e[0;0m"
- @formatter.result(1..3).should == "=> \e[0;36m1\e[0;0m\e[0;34m..\e[0;0m\e[0;36m3\e[0;0m"
- end
-
- it "colorizes a String" do
- @formatter.result("foo bar").should == "=> \e[0;31m\"\e[0;0m\e[0;36mfoo bar\e[0;0m\e[0;31m\"\e[0;0m"
- end
-
- it "colorizes a Hash" do
- @formatter.result(:ok => :foo).should == "=> \e[0;32m{\e[0;0m\e[1;33m:\e[0;0m\e[1;33mok\e[0;0m\e[0;34m=>\e[0;0m\e[1;33m:\e[0;0m\e[1;33mfoo\e[0;0m\e[0;32m}\e[0;0m"
- end
-
- it "colorizes an Array" do
- @formatter.result([1, 2]).should == "=> \e[0;32m[\e[0;0m\e[0;36m1\e[0;0m\e[0;34m,\e[0;0m \e[0;36m2\e[0;0m\e[0;32m]\e[0;0m"
- end
-
- it "colorizes the prompt" do
- @formatter.colors[:prompt] = :light_green
- @formatter.prompt(@context).should == "\e[1;32m#{IRB::Formatter.new.prompt(@context)}\e[0;0m"
- end
-
- it "colorizes the result prefix" do
- @formatter.colors[:result_prefix] = :light_red
- @formatter.result("").should == "\e[1;31m=>\e[0;0m \e[0;31m\"\e[0;0m\e[0;31m\"\e[0;0m"
- end
-
- it "uses the dark_background color scheme by default" do
- @formatter.color_scheme.should == :dark_background
- end
-
- it "changes color scheme" do
- @formatter.color_scheme = :fresh
- @formatter.color_scheme.should == :fresh
- @formatter.colors[:result_prefix].should == :light_purple
- end
-end
\ No newline at end of file
Deleted: DietRB/trunk/spec/completion_spec.rb
===================================================================
--- DietRB/trunk/spec/completion_spec.rb 2010-10-08 11:04:00 UTC (rev 4717)
+++ DietRB/trunk/spec/completion_spec.rb 2010-10-08 11:04:11 UTC (rev 4718)
@@ -1,237 +0,0 @@
-require File.expand_path('../spec_helper', __FILE__)
-require 'irb/ext/completion'
-
-module CompletionHelper
- def complete(str)
- IRB::Completion.new(@context, str).results
- end
-
- def imethods(klass, receiver = nil)
- klass.instance_methods.map { |m| [receiver, m.to_s].compact.join('.') }.sort
- end
-
- def methods(object, receiver = nil)
- object.methods.map { |m| [receiver, m.to_s].compact.join('.') }.sort
- end
-end
-
-class CompletionStub
- def self.a_cmethod
- end
-
- def an_imethod
- end
-end
-
-class Playground
- CompletionStub = Object.new
- def CompletionStub.a_singleton_method; end
-
- def a_local_method; end
-end
-
-$a_completion_stub = CompletionStub.new
-
-describe "IRB::Completion" do
- extend CompletionHelper
-
- before do
- @context = IRB::Context.new(Playground.new)
- end
-
- it "quacks like a Proc" do
- IRB::Completion.call('//.').should == imethods(Regexp, '//')
- end
-
- describe "when doing a method call on an explicit receiver," do
- describe "and the source ends with a period," do
- describe "returns *all* public methods of the receiver that" do
- it "matches as a local variable" do
- @context.__evaluate__('foo = ::CompletionStub.new')
- complete('foo.').should == imethods(::CompletionStub, 'foo')
-
- @context.__evaluate__('def foo.singleton_method; end')
- complete('foo.').should include('foo.singleton_method')
- end
-
- it "matches as a global variable" do
- complete('$a_completion_stub.').should == imethods(::CompletionStub, '$a_completion_stub')
- end
-
- # TODO: fix
- # it "matches as a local constant" do
- # complete('CompletionStub.').should == methods(Playground::CompletionStub)
- # end
-
- it "matches as a top level constant" do
- complete('::CompletionStub.').should == methods(::CompletionStub, '::CompletionStub')
- end
- end
-
- describe "returns *all* public instance methods of the class (the receiver) that" do
- it "matches as a Regexp literal" do
- complete('//.').should == imethods(Regexp, '//')
- complete('/^(:[^:.]+)\.([^.]*)$/.').should == imethods(Regexp, '/^(:[^:.]+)\.([^.]*)$/')
- complete('/^(#{oops})\.([^.]*)$/.').should == imethods(Regexp, '/^(#{oops})\.([^.]*)$/')
- complete('%r{/foo/.*/bar}.').should == imethods(Regexp, '%r{/foo/.*/bar}')
- end
-
- it "matches as an Array literal" do
- complete('[].').should == imethods(Array, '[]')
- complete('[:ok, {}, "foo",].').should == imethods(Array, '[:ok, {}, "foo",]')
- complete('[*foo].').should == imethods(Array, '[*foo]')
- complete('%w{foo}.').should == imethods(Array, '%w{foo}')
- complete('%W{#{:foo}}.').should == imethods(Array, '%W{#{:foo}}')
- end
-
- # fails on MacRuby
- it "matches as a lambda literal" do
- complete('->{}.').should == imethods(Proc, '->{}')
- complete('->{x=:ok}.').should == imethods(Proc, '->{x=:ok}')
- complete('->(x){x=:ok}.').should == imethods(Proc, '->(x){x=:ok}')
- end
-
- it "matches as a Hash literal" do
- complete('{}.').should == imethods(Hash, '{}')
- complete('{:foo=>:bar,}.').should == imethods(Hash, '{:foo=>:bar,}')
- complete('{foo:"bar"}.').should == imethods(Hash, '{foo:"bar"}')
- end
-
- it "matches as a Symbol literal" do
- complete(':foo.').should == imethods(Symbol, ':foo')
- complete(':"foo.bar".').should == imethods(Symbol, ':"foo.bar"')
- complete(':"foo.#{"bar"}".').should == imethods(Symbol, ':"foo.#{"bar"}"')
- complete(':\'foo.#{"bar"}\'.').should == imethods(Symbol, ':\'foo.#{"bar"}\'')
- complete('%s{foo.bar}.').should == imethods(Symbol, '%s{foo.bar}')
- end
-
- it "matches as a String literal" do
- complete("'foo\\'bar'.").should == imethods(String, "'foo\\'bar'")
- complete('"foo\"bar".').should == imethods(String, '"foo\"bar"')
- complete('"foo#{"bar"}".').should == imethods(String, '"foo#{"bar"}"')
- complete('%{foobar}.').should == imethods(String, '%{foobar}')
- complete('%q{foo#{:bar}}.').should == imethods(String, '%q{foo#{:bar}}')
- complete('%Q{foo#{:bar}}.').should == imethods(String, '%Q{foo#{:bar}}')
- end
-
- it "matches as a Range literal" do
- complete('1..10.').should == imethods(Range, '1..10')
- complete('1...10.').should == imethods(Range, '1...10')
- complete('"a".."z".').should == imethods(Range, '"a".."z"')
- complete('"a"..."z".').should == imethods(Range, '"a"..."z"')
- end
-
- it "matches as a Fixnum literal" do
- complete('42.').should == imethods(Fixnum, '42')
- complete('+42.').should == imethods(Fixnum, '+42')
- complete('-42.').should == imethods(Fixnum, '-42')
- complete('42_000.').should == imethods(Fixnum, '42_000')
- end
-
- it "matches as a Bignum literal as a Fixnum" do
- complete('100_000_000_000_000_000_000.').should == imethods(Fixnum, '100_000_000_000_000_000_000')
- complete('-100_000_000_000_000_000_000.').should == imethods(Fixnum, '-100_000_000_000_000_000_000')
- complete('+100_000_000_000_000_000_000.').should == imethods(Fixnum, '+100_000_000_000_000_000_000')
- end
-
- it "matches as a Float with exponential literal" do
- complete('1.2e-3.').should == imethods(Float, '1.2e-3')
- complete('+1.2e-3.').should == imethods(Float, '+1.2e-3')
- complete('-1.2e-3.').should == imethods(Float, '-1.2e-3')
- end
-
- it "matches as a hex literal as a Fixnum" do
- complete('0xffff.').should == imethods(Fixnum, '0xffff')
- complete('+0xffff.').should == imethods(Fixnum, '+0xffff')
- complete('-0xffff.').should == imethods(Fixnum, '-0xffff')
- end
-
- it "matches as a binary literal as a Fixnum" do
- complete('0b01011.').should == imethods(Fixnum, '0b01011')
- complete('-0b01011.').should == imethods(Fixnum, '-0b01011')
- complete('+0b01011.').should == imethods(Fixnum, '+0b01011')
- end
-
- it "matches as an octal literal as a Fixnum" do
- complete('0377.').should == imethods(Fixnum, '0377')
- complete('-0377.').should == imethods(Fixnum, '-0377')
- complete('+0377.').should == imethods(Fixnum, '+0377')
- end
-
- it "matches as a Float literal" do
- complete('42.0.').should == imethods(Float, '42.0')
- complete('-42.0.').should == imethods(Float, '-42.0')
- complete('+42.0.').should == imethods(Float, '+42.0')
- complete('42_000.0.').should == imethods(Float, '42_000.0')
- end
-
- it "matches as a Bignum float literal as a Float" do
- complete('100_000_000_000_000_000_000.0.').should == imethods(Float, '100_000_000_000_000_000_000.0')
- complete('+100_000_000_000_000_000_000.0.').should == imethods(Float, '+100_000_000_000_000_000_000.0')
- complete('-100_000_000_000_000_000_000.0.').should == imethods(Float, '-100_000_000_000_000_000_000.0')
- end
- end
-
- it "returns *all* public instance methods of the class (the receiver) that ::new is called on" do
- complete("Playground.new.").should == imethods(Playground, 'Playground.new')
- complete("Playground.new.a_local_m").should == %w{ Playground.new.a_local_method }
-
- @context.__evaluate__("klass = Playground")
- complete("klass.new.").should == imethods(Playground, 'klass.new')
- complete("klass.new.a_local_m").should == %w{ klass.new.a_local_method }
- end
- end
-
- describe "and the source does *not* end with a period," do
- it "filters the methods, of the literal receiver, by the given method name" do
- complete('//.nam').should == %w{ //.named_captures //.names }
- complete('//.named').should == %w{ //.named_captures }
- end
-
- it "filters the methods, of the variable receiver, by the given method name" do
- @context.__evaluate__('foo = ::CompletionStub.new')
- complete('foo.an_im').should == %w{ foo.an_imethod }
- complete('$a_completion_stub.an_im').should == %w{ $a_completion_stub.an_imethod }
- # TODO: fix
- # complete('CompletionStub.a_sing').should == %w{ CompletionStub.a_singleton_method }
- end
- end
- end
-
- describe "when *not* doing a method call on an explicit receiver" do
- before do
- @context.__evaluate__("a_local_variable = :ok")
- end
-
- it "matches local variables" do
- complete("a_local_v").should == %w{ a_local_variable }
- end
-
- it "matches instance methods of the context object" do
- complete("a_local_m").should == %w{ a_local_method }
- end
-
- it "matches local variables and instance method of the context object" do
- complete("a_loc").should == %w{ a_local_method a_local_variable }
- end
-
- it "matches global variables" do
- complete("$a_completion_s").should == %w{ $a_completion_stub }
- end
-
- it "matches constants" do
- complete("Playgr").should == %w{ Playground }
- end
-
- it "matches top level constants" do
- complete("::CompletionSt").should == %w{ ::CompletionStub }
- end
- end
-
- it "completes reserved words as variables or constants" do
- (IRB::Completion::RESERVED_DOWNCASE_WORDS +
- IRB::Completion::RESERVED_UPCASE_WORDS).each do |word|
- complete(word[0..-2]).should include(word)
- end
- end
-end
\ No newline at end of file
Copied: DietRB/trunk/spec/ext/colorize_spec.rb (from rev 4717, DietRB/trunk/spec/colorize_spec.rb)
===================================================================
--- DietRB/trunk/spec/ext/colorize_spec.rb (rev 0)
+++ DietRB/trunk/spec/ext/colorize_spec.rb 2010-10-08 11:04:11 UTC (rev 4718)
@@ -0,0 +1,58 @@
+require File.expand_path('../../spec_helper', __FILE__)
+require 'irb/ext/colorize'
+
+main = self
+
+describe "IRB::ColoredFormatter" do
+ before do
+ @formatter = IRB::ColoredFormatter.new
+ @context = IRB::Context.new(main)
+ end
+
+ it "colorizes a constant" do
+ @formatter.result(Hash).should == "=> \e[1;32mHash\e[0;0m"
+ end
+
+ it "colorizes a numeric" do
+ @formatter.result(1).should == "=> \e[0;36m1\e[0;0m"
+ @formatter.result(1.2).should == "=> \e[0;36m1.2\e[0;0m"
+ end
+
+ # Not Wirble compliant
+ it "colorizes a Range" do
+ # @formatter.result(1..3).should == "=> \e[0;36m1\e[0;0m\e[0;31m..\e[0;0m\e[0;36m3\e[0;0m"
+ @formatter.result(1..3).should == "=> \e[0;36m1\e[0;0m\e[0;34m..\e[0;0m\e[0;36m3\e[0;0m"
+ end
+
+ it "colorizes a String" do
+ @formatter.result("foo bar").should == "=> \e[0;31m\"\e[0;0m\e[0;36mfoo bar\e[0;0m\e[0;31m\"\e[0;0m"
+ end
+
+ it "colorizes a Hash" do
+ @formatter.result(:ok => :foo).should == "=> \e[0;32m{\e[0;0m\e[1;33m:\e[0;0m\e[1;33mok\e[0;0m\e[0;34m=>\e[0;0m\e[1;33m:\e[0;0m\e[1;33mfoo\e[0;0m\e[0;32m}\e[0;0m"
+ end
+
+ it "colorizes an Array" do
+ @formatter.result([1, 2]).should == "=> \e[0;32m[\e[0;0m\e[0;36m1\e[0;0m\e[0;34m,\e[0;0m \e[0;36m2\e[0;0m\e[0;32m]\e[0;0m"
+ end
+
+ it "colorizes the prompt" do
+ @formatter.colors[:prompt] = :light_green
+ @formatter.prompt(@context).should == "\e[1;32m#{IRB::Formatter.new.prompt(@context)}\e[0;0m"
+ end
+
+ it "colorizes the result prefix" do
+ @formatter.colors[:result_prefix] = :light_red
+ @formatter.result("").should == "\e[1;31m=>\e[0;0m \e[0;31m\"\e[0;0m\e[0;31m\"\e[0;0m"
+ end
+
+ it "uses the dark_background color scheme by default" do
+ @formatter.color_scheme.should == :dark_background
+ end
+
+ it "changes color scheme" do
+ @formatter.color_scheme = :fresh
+ @formatter.color_scheme.should == :fresh
+ @formatter.colors[:result_prefix].should == :light_purple
+ end
+end
\ No newline at end of file
Copied: DietRB/trunk/spec/ext/completion_spec.rb (from rev 4717, DietRB/trunk/spec/completion_spec.rb)
===================================================================
--- DietRB/trunk/spec/ext/completion_spec.rb (rev 0)
+++ DietRB/trunk/spec/ext/completion_spec.rb 2010-10-08 11:04:11 UTC (rev 4718)
@@ -0,0 +1,237 @@
+require File.expand_path('../../spec_helper', __FILE__)
+require 'irb/ext/completion'
+
+module CompletionHelper
+ def complete(str)
+ IRB::Completion.new(@context, str).results
+ end
+
+ def imethods(klass, receiver = nil)
+ klass.instance_methods.map { |m| [receiver, m.to_s].compact.join('.') }.sort
+ end
+
+ def methods(object, receiver = nil)
+ object.methods.map { |m| [receiver, m.to_s].compact.join('.') }.sort
+ end
+end
+
+class CompletionStub
+ def self.a_cmethod
+ end
+
+ def an_imethod
+ end
+end
+
+class Playground
+ CompletionStub = Object.new
+ def CompletionStub.a_singleton_method; end
+
+ def a_local_method; end
+end
+
+$a_completion_stub = CompletionStub.new
+
+describe "IRB::Completion" do
+ extend CompletionHelper
+
+ before do
+ @context = IRB::Context.new(Playground.new)
+ end
+
+ it "quacks like a Proc" do
+ IRB::Completion.call('//.').should == imethods(Regexp, '//')
+ end
+
+ describe "when doing a method call on an explicit receiver," do
+ describe "and the source ends with a period," do
+ describe "returns *all* public methods of the receiver that" do
+ it "matches as a local variable" do
+ @context.__evaluate__('foo = ::CompletionStub.new')
+ complete('foo.').should == imethods(::CompletionStub, 'foo')
+
+ @context.__evaluate__('def foo.singleton_method; end')
+ complete('foo.').should include('foo.singleton_method')
+ end
+
+ it "matches as a global variable" do
+ complete('$a_completion_stub.').should == imethods(::CompletionStub, '$a_completion_stub')
+ end
+
+ # TODO: fix
+ # it "matches as a local constant" do
+ # complete('CompletionStub.').should == methods(Playground::CompletionStub)
+ # end
+
+ it "matches as a top level constant" do
+ complete('::CompletionStub.').should == methods(::CompletionStub, '::CompletionStub')
+ end
+ end
+
+ describe "returns *all* public instance methods of the class (the receiver) that" do
+ it "matches as a Regexp literal" do
+ complete('//.').should == imethods(Regexp, '//')
+ complete('/^(:[^:.]+)\.([^.]*)$/.').should == imethods(Regexp, '/^(:[^:.]+)\.([^.]*)$/')
+ complete('/^(#{oops})\.([^.]*)$/.').should == imethods(Regexp, '/^(#{oops})\.([^.]*)$/')
+ complete('%r{/foo/.*/bar}.').should == imethods(Regexp, '%r{/foo/.*/bar}')
+ end
+
+ it "matches as an Array literal" do
+ complete('[].').should == imethods(Array, '[]')
+ complete('[:ok, {}, "foo",].').should == imethods(Array, '[:ok, {}, "foo",]')
+ complete('[*foo].').should == imethods(Array, '[*foo]')
+ complete('%w{foo}.').should == imethods(Array, '%w{foo}')
+ complete('%W{#{:foo}}.').should == imethods(Array, '%W{#{:foo}}')
+ end
+
+ # fails on MacRuby
+ it "matches as a lambda literal" do
+ complete('->{}.').should == imethods(Proc, '->{}')
+ complete('->{x=:ok}.').should == imethods(Proc, '->{x=:ok}')
+ complete('->(x){x=:ok}.').should == imethods(Proc, '->(x){x=:ok}')
+ end
+
+ it "matches as a Hash literal" do
+ complete('{}.').should == imethods(Hash, '{}')
+ complete('{:foo=>:bar,}.').should == imethods(Hash, '{:foo=>:bar,}')
+ complete('{foo:"bar"}.').should == imethods(Hash, '{foo:"bar"}')
+ end
+
+ it "matches as a Symbol literal" do
+ complete(':foo.').should == imethods(Symbol, ':foo')
+ complete(':"foo.bar".').should == imethods(Symbol, ':"foo.bar"')
+ complete(':"foo.#{"bar"}".').should == imethods(Symbol, ':"foo.#{"bar"}"')
+ complete(':\'foo.#{"bar"}\'.').should == imethods(Symbol, ':\'foo.#{"bar"}\'')
+ complete('%s{foo.bar}.').should == imethods(Symbol, '%s{foo.bar}')
+ end
+
+ it "matches as a String literal" do
+ complete("'foo\\'bar'.").should == imethods(String, "'foo\\'bar'")
+ complete('"foo\"bar".').should == imethods(String, '"foo\"bar"')
+ complete('"foo#{"bar"}".').should == imethods(String, '"foo#{"bar"}"')
+ complete('%{foobar}.').should == imethods(String, '%{foobar}')
+ complete('%q{foo#{:bar}}.').should == imethods(String, '%q{foo#{:bar}}')
+ complete('%Q{foo#{:bar}}.').should == imethods(String, '%Q{foo#{:bar}}')
+ end
+
+ it "matches as a Range literal" do
+ complete('1..10.').should == imethods(Range, '1..10')
+ complete('1...10.').should == imethods(Range, '1...10')
+ complete('"a".."z".').should == imethods(Range, '"a".."z"')
+ complete('"a"..."z".').should == imethods(Range, '"a"..."z"')
+ end
+
+ it "matches as a Fixnum literal" do
+ complete('42.').should == imethods(Fixnum, '42')
+ complete('+42.').should == imethods(Fixnum, '+42')
+ complete('-42.').should == imethods(Fixnum, '-42')
+ complete('42_000.').should == imethods(Fixnum, '42_000')
+ end
+
+ it "matches as a Bignum literal as a Fixnum" do
+ complete('100_000_000_000_000_000_000.').should == imethods(Fixnum, '100_000_000_000_000_000_000')
+ complete('-100_000_000_000_000_000_000.').should == imethods(Fixnum, '-100_000_000_000_000_000_000')
+ complete('+100_000_000_000_000_000_000.').should == imethods(Fixnum, '+100_000_000_000_000_000_000')
+ end
+
+ it "matches as a Float with exponential literal" do
+ complete('1.2e-3.').should == imethods(Float, '1.2e-3')
+ complete('+1.2e-3.').should == imethods(Float, '+1.2e-3')
+ complete('-1.2e-3.').should == imethods(Float, '-1.2e-3')
+ end
+
+ it "matches as a hex literal as a Fixnum" do
+ complete('0xffff.').should == imethods(Fixnum, '0xffff')
+ complete('+0xffff.').should == imethods(Fixnum, '+0xffff')
+ complete('-0xffff.').should == imethods(Fixnum, '-0xffff')
+ end
+
+ it "matches as a binary literal as a Fixnum" do
+ complete('0b01011.').should == imethods(Fixnum, '0b01011')
+ complete('-0b01011.').should == imethods(Fixnum, '-0b01011')
+ complete('+0b01011.').should == imethods(Fixnum, '+0b01011')
+ end
+
+ it "matches as an octal literal as a Fixnum" do
+ complete('0377.').should == imethods(Fixnum, '0377')
+ complete('-0377.').should == imethods(Fixnum, '-0377')
+ complete('+0377.').should == imethods(Fixnum, '+0377')
+ end
+
+ it "matches as a Float literal" do
+ complete('42.0.').should == imethods(Float, '42.0')
+ complete('-42.0.').should == imethods(Float, '-42.0')
+ complete('+42.0.').should == imethods(Float, '+42.0')
+ complete('42_000.0.').should == imethods(Float, '42_000.0')
+ end
+
+ it "matches as a Bignum float literal as a Float" do
+ complete('100_000_000_000_000_000_000.0.').should == imethods(Float, '100_000_000_000_000_000_000.0')
+ complete('+100_000_000_000_000_000_000.0.').should == imethods(Float, '+100_000_000_000_000_000_000.0')
+ complete('-100_000_000_000_000_000_000.0.').should == imethods(Float, '-100_000_000_000_000_000_000.0')
+ end
+ end
+
+ it "returns *all* public instance methods of the class (the receiver) that ::new is called on" do
+ complete("Playground.new.").should == imethods(Playground, 'Playground.new')
+ complete("Playground.new.a_local_m").should == %w{ Playground.new.a_local_method }
+
+ @context.__evaluate__("klass = Playground")
+ complete("klass.new.").should == imethods(Playground, 'klass.new')
+ complete("klass.new.a_local_m").should == %w{ klass.new.a_local_method }
+ end
+ end
+
+ describe "and the source does *not* end with a period," do
+ it "filters the methods, of the literal receiver, by the given method name" do
+ complete('//.nam').should == %w{ //.named_captures //.names }
+ complete('//.named').should == %w{ //.named_captures }
+ end
+
+ it "filters the methods, of the variable receiver, by the given method name" do
+ @context.__evaluate__('foo = ::CompletionStub.new')
+ complete('foo.an_im').should == %w{ foo.an_imethod }
+ complete('$a_completion_stub.an_im').should == %w{ $a_completion_stub.an_imethod }
+ # TODO: fix
+ # complete('CompletionStub.a_sing').should == %w{ CompletionStub.a_singleton_method }
+ end
+ end
+ end
+
+ describe "when *not* doing a method call on an explicit receiver" do
+ before do
+ @context.__evaluate__("a_local_variable = :ok")
+ end
+
+ it "matches local variables" do
+ complete("a_local_v").should == %w{ a_local_variable }
+ end
+
+ it "matches instance methods of the context object" do
+ complete("a_local_m").should == %w{ a_local_method }
+ end
+
+ it "matches local variables and instance method of the context object" do
+ complete("a_loc").should == %w{ a_local_method a_local_variable }
+ end
+
+ it "matches global variables" do
+ complete("$a_completion_s").should == %w{ $a_completion_stub }
+ end
+
+ it "matches constants" do
+ complete("Playgr").should == %w{ Playground }
+ end
+
+ it "matches top level constants" do
+ complete("::CompletionSt").should == %w{ ::CompletionStub }
+ end
+ end
+
+ it "completes reserved words as variables or constants" do
+ (IRB::Completion::RESERVED_DOWNCASE_WORDS +
+ IRB::Completion::RESERVED_UPCASE_WORDS).each do |word|
+ complete(word[0..-2]).should include(word)
+ end
+ end
+end
\ No newline at end of file
Copied: DietRB/trunk/spec/ext/history_spec.rb (from rev 4717, DietRB/trunk/spec/history_spec.rb)
===================================================================
--- DietRB/trunk/spec/ext/history_spec.rb (rev 0)
+++ DietRB/trunk/spec/ext/history_spec.rb 2010-10-08 11:04:11 UTC (rev 4718)
@@ -0,0 +1,187 @@
+require File.expand_path('../../spec_helper', __FILE__)
+require "tempfile"
+
+describe "IRB::History, by default," do
+ it "stores the history in ~/.irb_history" do
+ IRB::History.file.should == File.expand_path("~/.irb_history")
+ end
+end
+
+describe "IRB::History" do
+ before do
+ @file = Tempfile.new("irb_history.txt")
+ IRB::History.file = @file.path
+ @history = IRB::History.new(nil)
+ end
+
+ after do
+ @file.close
+ end
+
+ it "adds input to the history file" do
+ @history.input "puts :ok"
+ @file.rewind; @file.read.should == "puts :ok\n"
+ @history.input "foo(x)"
+ @file.rewind; @file.read.should == "puts :ok\nfoo(x)\n"
+ end
+
+ it "returns the same input value" do
+ @history.input("foo(x)").should == "foo(x)"
+ end
+
+ it "returns the contents of the history file as an array of lines" do
+ @history.input "puts :ok"
+ @history.to_a.should == ["puts :ok"]
+ @history.input "foo(x)"
+ @history.to_a.should == ["puts :ok", "foo(x)"]
+ end
+
+ it "returns an empty array if the history file doesn't exist yet and create it once input is added" do
+ @file.close
+ FileUtils.rm(@file.path)
+
+ @history.to_a.should == []
+ File.exist?(@file.path).should == false
+
+ @history.input "puts :ok"
+ File.exist?(@file.path).should == true
+ @history.to_a.should == ["puts :ok"]
+ end
+
+ it "stores the contents of the history file in Readline::HISTORY once" do
+ Readline::HISTORY.clear
+
+ @history.input "puts :ok"
+ @history.input "foo(x)"
+
+ IRB::History.new(nil)
+ IRB::History.new(nil)
+
+ Readline::HISTORY.to_a.should == ["puts :ok", "foo(x)"]
+ end
+
+ it "clears the history and history file" do
+ @history.input "puts :ok"
+ @history.input "foo(x)"
+ @history.clear!
+
+ @file.rewind; @file.read.should == ""
+ Readline::HISTORY.to_a.should == []
+ end
+end
+
+class IRB::History
+ def printed
+ @printed ||= ""
+ end
+
+ def print(s)
+ printed << s
+ end
+
+ def puts(s)
+ printed << "#{s}\n"
+ end
+
+ def clear!
+ @cleared = true
+ end
+ def cleared?
+ @cleared
+ end
+end
+
+describe "IRB::History, concerning the user api, by default," do
+ it "shows a maximum of 50 history entries" do
+ IRB::History.max_entries_in_overview.should == 50
+ end
+end
+
+describe "IRB::History, concerning the user api," do
+ before do
+ sources = [
+ "puts :ok",
+ "x = foo(x)",
+ "class AAA",
+ " def bar",
+ " :ok",
+ " end",
+ "end",
+ "THIS LINE REPRESENTS THE ENTERED COMMAND AND SHOULD BE OMITTED!"
+ ]
+
+ Readline::HISTORY.clear
+ sources.each { |source| Readline::HISTORY.push(source) }
+
+ IRB::History.max_entries_in_overview = 5
+
+ @context = IRB::Context.new(Object.new)
+ IRB::Context.current = @context
+
+ @history = @context.processors.find { |p| p.is_a?(IRB::History) }
+ end
+
+ after do
+ IRB::Context.current = nil
+ end
+
+ it "returns nil so that IRB doesn't cache some arbitrary line number" do
+ history.should == nil
+ end
+
+ it "prints a formatted list with, by default IRB::History.max_entries_in_overview, number of history entries" do
+ history
+
+ @history.printed.should == %{
+2: class AAA
+3: def bar
+4: :ok
+5: end
+6: end
+}.sub(/\n/, '')
+ end
+
+ it "prints a formatted list of N most recent history entries" do
+ history(7)
+
+ @history.printed.should == %{
+0: puts :ok
+1: x = foo(x)
+2: class AAA
+3: def bar
+4: :ok
+5: end
+6: end
+}.sub(/\n/, '')
+ end
+
+ it "prints a formatted list of all history entries if the request number of entries is more than there is" do
+ history(777)
+
+ @history.printed.should == %{
+0: puts :ok
+1: x = foo(x)
+2: class AAA
+3: def bar
+4: :ok
+5: end
+6: end
+}.sub(/\n/, '')
+ end
+
+ it "evaluates the history entry specified" do
+ @context.__evaluate__("x = 2; def foo(x); x * 2; end")
+ history! 1
+ @context.__evaluate__("x").should == 4
+ end
+
+ it "evaluates the history entries specified by a range" do
+ history! 2..6
+ @context.__evaluate__("AAA.new.bar").should == :ok
+ end
+
+ it "clears the history and history file" do
+ clear_history!
+ @history.cleared?.should == true
+ end
+end
\ No newline at end of file
Deleted: DietRB/trunk/spec/history_spec.rb
===================================================================
--- DietRB/trunk/spec/history_spec.rb 2010-10-08 11:04:00 UTC (rev 4717)
+++ DietRB/trunk/spec/history_spec.rb 2010-10-08 11:04:11 UTC (rev 4718)
@@ -1,187 +0,0 @@
-require File.expand_path('../spec_helper', __FILE__)
-require "tempfile"
-
-describe "IRB::History, by default," do
- it "stores the history in ~/.irb_history" do
- IRB::History.file.should == File.expand_path("~/.irb_history")
- end
-end
-
-describe "IRB::History" do
- before do
- @file = Tempfile.new("irb_history.txt")
- IRB::History.file = @file.path
- @history = IRB::History.new(nil)
- end
-
- after do
- @file.close
- end
-
- it "adds input to the history file" do
- @history.input "puts :ok"
- @file.rewind; @file.read.should == "puts :ok\n"
- @history.input "foo(x)"
- @file.rewind; @file.read.should == "puts :ok\nfoo(x)\n"
- end
-
- it "returns the same input value" do
- @history.input("foo(x)").should == "foo(x)"
- end
-
- it "returns the contents of the history file as an array of lines" do
- @history.input "puts :ok"
- @history.to_a.should == ["puts :ok"]
- @history.input "foo(x)"
- @history.to_a.should == ["puts :ok", "foo(x)"]
- end
-
- it "returns an empty array if the history file doesn't exist yet and create it once input is added" do
- @file.close
- FileUtils.rm(@file.path)
-
- @history.to_a.should == []
- File.exist?(@file.path).should == false
-
- @history.input "puts :ok"
- File.exist?(@file.path).should == true
- @history.to_a.should == ["puts :ok"]
- end
-
- it "stores the contents of the history file in Readline::HISTORY once" do
- Readline::HISTORY.clear
-
- @history.input "puts :ok"
- @history.input "foo(x)"
-
- IRB::History.new(nil)
- IRB::History.new(nil)
-
- Readline::HISTORY.to_a.should == ["puts :ok", "foo(x)"]
- end
-
- it "clears the history and history file" do
- @history.input "puts :ok"
- @history.input "foo(x)"
- @history.clear!
-
- @file.rewind; @file.read.should == ""
- Readline::HISTORY.to_a.should == []
- end
-end
-
-class IRB::History
- def printed
- @printed ||= ""
- end
-
- def print(s)
- printed << s
- end
-
- def puts(s)
- printed << "#{s}\n"
- end
-
- def clear!
- @cleared = true
- end
- def cleared?
- @cleared
- end
-end
-
-describe "IRB::History, concerning the user api, by default," do
- it "shows a maximum of 50 history entries" do
- IRB::History.max_entries_in_overview.should == 50
- end
-end
-
-describe "IRB::History, concerning the user api," do
- before do
- sources = [
- "puts :ok",
- "x = foo(x)",
- "class AAA",
- " def bar",
- " :ok",
- " end",
- "end",
- "THIS LINE REPRESENTS THE ENTERED COMMAND AND SHOULD BE OMITTED!"
- ]
-
- Readline::HISTORY.clear
- sources.each { |source| Readline::HISTORY.push(source) }
-
- IRB::History.max_entries_in_overview = 5
-
- @context = IRB::Context.new(Object.new)
- IRB::Context.current = @context
-
- @history = @context.processors.find { |p| p.is_a?(IRB::History) }
- end
-
- after do
- IRB::Context.current = nil
- end
-
- it "returns nil so that IRB doesn't cache some arbitrary line number" do
- history.should == nil
- end
-
- it "prints a formatted list with, by default IRB::History.max_entries_in_overview, number of history entries" do
- history
-
- @history.printed.should == %{
-2: class AAA
-3: def bar
-4: :ok
-5: end
-6: end
-}.sub(/\n/, '')
- end
-
- it "prints a formatted list of N most recent history entries" do
- history(7)
-
- @history.printed.should == %{
-0: puts :ok
-1: x = foo(x)
-2: class AAA
-3: def bar
-4: :ok
-5: end
-6: end
-}.sub(/\n/, '')
- end
-
- it "prints a formatted list of all history entries if the request number of entries is more than there is" do
- history(777)
-
- @history.printed.should == %{
-0: puts :ok
-1: x = foo(x)
-2: class AAA
-3: def bar
-4: :ok
-5: end
-6: end
-}.sub(/\n/, '')
- end
-
- it "evaluates the history entry specified" do
- @context.__evaluate__("x = 2; def foo(x); x * 2; end")
- history! 1
- @context.__evaluate__("x").should == 4
- end
-
- it "evaluates the history entries specified by a range" do
- history! 2..6
- @context.__evaluate__("AAA.new.bar").should == :ok
- end
-
- it "clears the history and history file" do
- clear_history!
- @history.cleared?.should == true
- end
-end
\ No newline at end of file
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101008/a96dc7e0/attachment-0001.html>
More information about the macruby-changes
mailing list