Skip to content

Commit

Permalink
"numeric + someOtherObj" should call someOtherObj.method_missing(:coe…
Browse files Browse the repository at this point in the history
…rce)

backtraces now include file names for builtin methods in IronRuby.Libraries.dll in a DEBUG builds and with -X:ExceptionDetail
Enables RubyGems tests in irtests.bat
  • Loading branch information
Shri Borde committed May 7, 2009
1 parent d78808a commit 09b25e8
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 18 deletions.
Expand Up @@ -16,4 +16,16 @@
lambda { @bignum + "10" }.should raise_error(TypeError)
lambda { @bignum + :symbol}.should raise_error(TypeError)
end

it "calls #coerce on the passed argument with self" do
(m = mock('10')).should_receive(:coerce).with(@bignum).and_return([10, @bignum])
(@bignum + m).should == @bignum + 10
end

it "calls #method_missing(:coerce) on the passed argument" do
m = mock('10')
m.should_not_receive(:respond_to?).with(:coerce)
m.should_receive(:method_missing).with(:coerce, @bignum).and_return([10, @bignum])
(@bignum + m).should == @bignum + 10
end
end
Expand Up @@ -17,4 +17,16 @@
lambda { 13 + "10" }.should raise_error(TypeError)
lambda { 13 + :symbol }.should raise_error(TypeError)
end

it "calls #coerce on the passed argument with self" do
(m = mock('10')).should_receive(:coerce).with(13).and_return([10, 13])
(13 + m).should == 23
end

it "calls #method_missing(:coerce) on the passed argument" do
m = mock('10')
m.should_not_receive(:respond_to?).with(:coerce)
m.should_receive(:method_missing).with(:coerce, 13).and_return([10, 13])
(13 + m).should == 23
end
end
Expand Up @@ -6,4 +6,16 @@
(9.99 + bignum_value).should be_close(9223372036854775808.000, TOLERANCE)
(1001.99 + 5.219).should be_close(1007.209, TOLERANCE)
end

it "calls #coerce on the passed argument with self" do
(m = mock('10')).should_receive(:coerce).with(1.5).and_return([10.0, 1.5])
(1.5 + m).should == 11.5
end

it "calls #method_missing(:coerce) on the passed argument" do
m = mock('10')
m.should_not_receive(:respond_to?).with(:coerce)
m.should_receive(:method_missing).with(:coerce, 1.5).and_return([10.0, 1.5])
(1.5 + m).should == 11.5
end
end
Expand Up @@ -47,4 +47,15 @@
(@infinity + @infinity_minus).nan?.should == true
end

it "calls #coerce on the passed argument with self" do
(m = mock('10')).should_receive(:coerce).with(@eleven).and_return([@ten, @eleven])
(@eleven + m).should == @eleven + 10
end

it "calls #method_missing(:coerce) on the passed argument" do
m = mock('10')
m.should_not_receive(:respond_to?).with(:coerce)
m.should_receive(:method_missing).with(:coerce, @eleven).and_return([@ten, @eleven])
(@eleven + m).should == @eleven + 10
end
end
3 changes: 1 addition & 2 deletions Merlin/Main/Languages/Ruby/Ruby/Runtime/Protocols.cs
Expand Up @@ -350,8 +350,7 @@ public static class Protocols {
BinaryOpStorage/*!*/ binaryOpStorage, string/*!*/ binaryOp,
object self, object other, out object result) {

// doesn't call method_missing:
var coerce = coercionStorage.GetCallSite("coerce", new RubyCallSignature(1, RubyCallFlags.IsTryCall | RubyCallFlags.HasImplicitSelf));
var coerce = coercionStorage.GetCallSite("coerce", new RubyCallSignature(1, RubyCallFlags.HasImplicitSelf));

IList coercedValues;

Expand Down
8 changes: 6 additions & 2 deletions Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyExceptionData.cs
Expand Up @@ -228,8 +228,12 @@ public sealed class RubyExceptionData {
// Ruby library method:
// TODO: aliases
methodName = ((RubyMethodAttribute)attrs[0]).Name;
fileName = null;
line = 0;
#if !DEBUG
if (!exceptionDetail) {
fileName = null;
line = 0;
}
#endif
return true;
} else if (exceptionDetail || IsVisibleClrFrame(method)) {
// Visible CLR method:
Expand Down
3 changes: 1 addition & 2 deletions Merlin/Main/Languages/Ruby/Scripts/Dev.bat
Expand Up @@ -13,8 +13,7 @@ set RUBY18_BIN=
set RUBY18_EXE=ruby.exe
set RUBY19_EXE=c:\ruby19\bin\ruby.exe
set RUBYOPT=
REM Optimistically set GEM_PATH so that IronRuby can find gems installed by MRI. Users can override this from Merlin\Users\%username%\Dev.bat
set GEM_PATH=c:\Ruby\lib\ruby\gems\1.8
set GEM_PATH=%MERLIN_ROOT%\..\External.LCA_RESTRICTED\Languages\Ruby\ruby-1.8.6p287\lib\ruby\gems\1.8

if exist "%PROGRAM_FILES_x86%" set PROGRAM_FILES_32=%PROGRAM_FILES_x86%

Expand Down
20 changes: 9 additions & 11 deletions Merlin/Main/Languages/Ruby/Scripts/irtests.bat
Expand Up @@ -2,7 +2,7 @@
setlocal

if "%1" == "-?" (
echo irtests.bat [-par] [-nocompile] [-all] [-?]
echo irtests.bat [-p] [-nocompile] [-?]
exit /b 0
)

Expand Down Expand Up @@ -87,16 +87,14 @@ if defined PARALLEL_IRTESTS (
:==============================================================================
: RubyGems

if "%1" == "-all" (
if defined PARALLEL_IRTESTS (
start "RubyGems tests" cmd.exe /k %MERLIN_ROOT%\bin\Debug\ir.exe %MERLIN_ROOT%\Languages\Ruby\Scripts\RubyGemsTests.rb
) else (
%MERLIN_ROOT%\bin\Debug\ir.exe %MERLIN_ROOT%\Languages\Ruby\Scripts\RubyGemsTests.rb
if not %ERRORLEVEL%==0 (
set IRTESTS_ERRORS=%IRTESTS_ERRORS% RubyGems tests failed!!!
echo %IRTESTS_ERRORS%
)
)
if defined PARALLEL_IRTESTS (
start "RubyGems tests" cmd.exe /k %MERLIN_ROOT%\bin\Debug\ir.exe %MERLIN_ROOT%\Languages\Ruby\Scripts\RubyGemsTests.rb
) else (
%MERLIN_ROOT%\bin\Debug\ir.exe %MERLIN_ROOT%\Languages\Ruby\Scripts\RubyGemsTests.rb
if not %ERRORLEVEL%==0 (
set IRTESTS_ERRORS=%IRTESTS_ERRORS% RubyGems tests failed!!!
echo %IRTESTS_ERRORS%
)
)

:==============================================================================
Expand Down
1 change: 0 additions & 1 deletion Merlin/Users/sborde/Dev.bat
Expand Up @@ -13,5 +13,4 @@ REM but mspec launches mspec-run as a separate process
set RUBY_EXE=%MERLIN_ROOT%\bin\Debug\ir.exe
set RUBY19_EXE=%MERLIN_TFS%\..\External.LCA_RESTRICTED\Languages\Ruby\ruby-1.9.1p0\bin\ruby.exe

set GEM_PATH=%MERLIN_TFS%\..\External.LCA_RESTRICTED\languages\ruby\ruby-1.8.6p287\lib\ruby\gems\1.8
set JAVA_HOME=C:\Progra~1\Java\jre6

0 comments on commit 09b25e8

Please sign in to comment.