Changeset 2328
- Timestamp:
- 12/03/07 11:30:58 (5 years ago)
- Location:
- lang/javascript/jsruby/trunk
- Files:
-
- 5 modified
-
src/builtinobjects.js (modified) (1 diff)
-
src/interpreter.js (modified) (1 diff)
-
src/parse.js (modified) (1 diff)
-
tests/integer.html (modified) (1 diff)
-
tests/string.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lang/javascript/jsruby/trunk/src/builtinobjects.js
r2314 r2328 46 46 RubyEngine.RubyObject.Numeric.prototype.div = function(x){ return new RubyEngine.RubyObject.Numeric(parseInt(this.num / x.num)); } 47 47 RubyEngine.RubyObject.Numeric.prototype.mod = function(x){ return new RubyEngine.RubyObject.Numeric(this.num % x.num); } 48 RubyEngine.RubyObject.Numeric.prototype.pow = function(x){ return new RubyEngine.RubyObject.Numeric(Math.pow(this.num, x.num)); } 48 49 RubyEngine.RubyObject.Numeric.prototype.eql = function(x){ return this.num == x.num; } 49 50 RubyEngine.RubyObject.Numeric.methods = { -
lang/javascript/jsruby/trunk/src/interpreter.js
r2174 r2328 85 85 stk.push(stk.pop().mod(a)); 86 86 break; 87 case "**": 88 var a = stk.pop(); 89 stk.push(stk.pop().pow(a)); 90 break; 87 91 case "..": 88 92 var to = stk.pop(); -
lang/javascript/jsruby/trunk/src/parse.js
r2313 r2328 294 294 295 295 RubyEngine.Parser.prototype.operator = function() { 296 if (this.body.match(/^[ \t]*(\.\.|\+|\-|\* |\/|%|==)/)) {296 if (this.body.match(/^[ \t]*(\.\.|\+|\-|\*{1,2}|\/|%|==|[<>]=?|&&|\|\||<<|>>)/)) { 297 297 this.body = RegExp.rightContext; 298 298 return new RubyEngine.Node.Operator(RegExp.$1); -
lang/javascript/jsruby/trunk/tests/integer.html
r2314 r2328 45 45 assertEquals("calc 3", ruby.exec("3-4"), -1); 46 46 assertEquals("calc 4", ruby.exec("3/4"), 0); 47 //assertEquals("calc 5", ruby.exec("3**4"), 81);47 assertEquals("calc 5", ruby.exec("3**4"), 81); 48 48 assertFalse("calc 6", ruby.exec("3==4") ); 49 49 assertTrue("calc 7", ruby.exec("4==4") ); -
lang/javascript/jsruby/trunk/tests/string.html
r2184 r2328 24 24 } 25 25 26 function testAdd() { 27 assertEquals("string add 1", ruby.exec(" 'a'+'b' "), "ab"); 28 assertEquals("string add 2", ruby.exec(" 'd'+'e'+'f' "), "def"); 29 assertEquals("string add 3", ruby.exec(" x='u'+'b'; \"r\"+x+\"y\" "), "ruby"); 30 } 31 26 32 function testReverse() { 27 33 assertEquals("reverse 1", ruby.exec(' "a".reverse '), "a");
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)