Browse Source

Merge branch 'master' into debugger

Nicolas Petton 10 years ago
parent
commit
8f6a331380
7 changed files with 138 additions and 1 deletions
  1. 22 0
      js/Kernel-Objects.deploy.js
  2. 32 0
      js/Kernel-Objects.js
  3. 26 0
      js/Kernel-Tests.deploy.js
  4. 36 0
      js/Kernel-Tests.js
  5. 8 0
      st/Kernel-Objects.st
  6. 12 0
      st/Kernel-Tests.st
  7. 2 1
      support/boot.js

+ 22 - 0
js/Kernel-Objects.deploy.js

@@ -1788,6 +1788,17 @@ return $1;
 messageSends: ["+", "truncated", "*", "next", "new"]}),
 smalltalk.Number);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "ceiling",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+return Math.ceil(self);;
+return self}, function($ctx1) {$ctx1.fill(self,"ceiling",{},smalltalk.Number)})},
+messageSends: []}),
+smalltalk.Number);
+
 smalltalk.addMethod(
 smalltalk.method({
 selector: "copy",
@@ -1827,6 +1838,17 @@ return $1;
 messageSends: ["=", "\x5c\x5c"]}),
 smalltalk.Number);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "floor",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+return Math.floor(self);;
+return self}, function($ctx1) {$ctx1.fill(self,"floor",{},smalltalk.Number)})},
+messageSends: []}),
+smalltalk.Number);
+
 smalltalk.addMethod(
 smalltalk.method({
 selector: "identityHash",

+ 32 - 0
js/Kernel-Objects.js

@@ -2502,6 +2502,22 @@ referencedClasses: ["Random"]
 }),
 smalltalk.Number);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "ceiling",
+category: 'converting',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+return Math.ceil(self);;
+return self}, function($ctx1) {$ctx1.fill(self,"ceiling",{},smalltalk.Number)})},
+args: [],
+source: "ceiling\x0a\x09<return Math.ceil(self);>",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.Number);
+
 smalltalk.addMethod(
 smalltalk.method({
 selector: "copy",
@@ -2556,6 +2572,22 @@ referencedClasses: []
 }),
 smalltalk.Number);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "floor",
+category: 'converting',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+return Math.floor(self);;
+return self}, function($ctx1) {$ctx1.fill(self,"floor",{},smalltalk.Number)})},
+args: [],
+source: "floor\x0a\x09<return Math.floor(self);>",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.Number);
+
 smalltalk.addMethod(
 smalltalk.method({
 selector: "identityHash",

+ 26 - 0
js/Kernel-Tests.deploy.js

@@ -2858,6 +2858,19 @@ return self}, function($ctx1) {$ctx1.fill(self,"testArithmetic",{},smalltalk.Num
 messageSends: ["assert:equals:", "+", "-", "/", "*"]}),
 smalltalk.NumberTest);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "testCeiling",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+self._assert_equals_((1.2)._ceiling(),(2));
+self._assert_equals_((-1.2)._ceiling(),(-1));
+self._assert_equals_((1)._ceiling(),(1));
+return self}, function($ctx1) {$ctx1.fill(self,"testCeiling",{},smalltalk.NumberTest)})},
+messageSends: ["assert:equals:", "ceiling"]}),
+smalltalk.NumberTest);
+
 smalltalk.addMethod(
 smalltalk.method({
 selector: "testComparison",
@@ -2908,6 +2921,19 @@ return self}, function($ctx1) {$ctx1.fill(self,"testEquality",{},smalltalk.Numbe
 messageSends: ["assert:", "=", "deny:", "yourself"]}),
 smalltalk.NumberTest);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "testFloor",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+self._assert_equals_((1.2)._floor(),(1));
+self._assert_equals_((-1.2)._floor(),(-2));
+self._assert_equals_((1)._floor(),(1));
+return self}, function($ctx1) {$ctx1.fill(self,"testFloor",{},smalltalk.NumberTest)})},
+messageSends: ["assert:equals:", "floor"]}),
+smalltalk.NumberTest);
+
 smalltalk.addMethod(
 smalltalk.method({
 selector: "testHexNumbers",

+ 36 - 0
js/Kernel-Tests.js

@@ -3638,6 +3638,24 @@ referencedClasses: []
 }),
 smalltalk.NumberTest);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "testCeiling",
+category: 'tests',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+self._assert_equals_((1.2)._ceiling(),(2));
+self._assert_equals_((-1.2)._ceiling(),(-1));
+self._assert_equals_((1)._ceiling(),(1));
+return self}, function($ctx1) {$ctx1.fill(self,"testCeiling",{},smalltalk.NumberTest)})},
+args: [],
+source: "testCeiling\x0a\x09self assert: 1.2 ceiling equals: 2.\x0a\x09self assert: -1.2 ceiling equals: -1.\x0a\x09self assert: 1.0 ceiling equals: 1.",
+messageSends: ["assert:equals:", "ceiling"],
+referencedClasses: []
+}),
+smalltalk.NumberTest);
+
 smalltalk.addMethod(
 smalltalk.method({
 selector: "testComparison",
@@ -3703,6 +3721,24 @@ referencedClasses: []
 }),
 smalltalk.NumberTest);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "testFloor",
+category: 'tests',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+self._assert_equals_((1.2)._floor(),(1));
+self._assert_equals_((-1.2)._floor(),(-2));
+self._assert_equals_((1)._floor(),(1));
+return self}, function($ctx1) {$ctx1.fill(self,"testFloor",{},smalltalk.NumberTest)})},
+args: [],
+source: "testFloor\x0a\x09self assert: 1.2 floor equals: 1.\x0a\x09self assert: -1.2 floor equals: -2.\x0a\x09self assert: 1.0 floor equals: 1.",
+messageSends: ["assert:equals:", "floor"],
+referencedClasses: []
+}),
+smalltalk.NumberTest);
+
 smalltalk.addMethod(
 smalltalk.method({
 selector: "testHexNumbers",

+ 8 - 0
st/Kernel-Objects.st

@@ -844,6 +844,14 @@ atRandom
 	^(Random new next * self) truncated + 1
 !
 
+ceiling
+	<return Math.ceil(self);>
+!
+
+floor
+	<return Math.floor(self);>
+!
+
 rounded
 	<return Math.round(self);>
 !

+ 12 - 0
st/Kernel-Tests.st

@@ -1360,6 +1360,12 @@ testArithmetic
 	self assert: 1 + (2 * 3) equals: 7
 !
 
+testCeiling
+	self assert: 1.2 ceiling equals: 2.
+	self assert: -1.2 ceiling equals: -1.
+	self assert: 1.0 ceiling equals: 1.
+!
+
 testComparison
 
 	self assert: 3 > 2.
@@ -1394,6 +1400,12 @@ testEquality
 	self deny: 0 = ''
 !
 
+testFloor
+	self assert: 1.2 floor equals: 1.
+	self assert: -1.2 floor equals: -2.
+	self assert: 1.0 floor equals: 1.
+!
+
 testHexNumbers
 
 	self assert: 16r9 equals: 9.

+ 2 - 1
support/boot.js

@@ -821,9 +821,10 @@ function RuntimeBrik(brikz, st) {
 			this.lookupClass = lookupClass;
 		};
 
-		SmalltalkMethodContext.prototype.fillBlock = function(locals, ctx) {
+		SmalltalkMethodContext.prototype.fillBlock = function(locals, ctx, index) {
 			this.locals        = locals || {};
 			this.outerContext  = ctx;
+			this.index         = index || 0;
 		};
 
 		SmalltalkMethodContext.prototype.init = function() {