Browse Source

Added unit tests for Number>>floor and Number>>ceiling.

Matthias Springer 10 years ago
parent
commit
b76fbb2ca0
3 changed files with 76 additions and 2 deletions
  1. 27 1
      js/Kernel-Tests.deploy.js
  2. 37 1
      js/Kernel-Tests.js
  3. 12 0
      st/Kernel-Tests.st

+ 27 - 1
js/Kernel-Tests.deploy.js

@@ -1,5 +1,6 @@
 (function(smalltalk,nil,_st){
 smalltalk.addPackage('Kernel-Tests');
+
 smalltalk.addClass('BlockClosureTest', smalltalk.TestCase, [], 'Kernel-Tests');
 smalltalk.addMethod(
 smalltalk.method({
@@ -2842,6 +2843,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",
@@ -2892,6 +2906,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",
@@ -4078,5 +4105,4 @@ messageSends: ["assert:", "isNil", "deny:", "notNil"]}),
 smalltalk.UndefinedTest);
 
 
-
 })(global_smalltalk,global_nil,global__st);

+ 37 - 1
js/Kernel-Tests.js

@@ -1,5 +1,6 @@
 (function(smalltalk,nil,_st){
 smalltalk.addPackage('Kernel-Tests');
+
 smalltalk.addClass('BlockClosureTest', smalltalk.TestCase, [], 'Kernel-Tests');
 smalltalk.addMethod(
 smalltalk.method({
@@ -3617,6 +3618,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",
@@ -3682,6 +3701,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",
@@ -5179,5 +5216,4 @@ referencedClasses: []
 smalltalk.UndefinedTest);
 
 
-
 })(global_smalltalk,global_nil,global__st);

+ 12 - 0
st/Kernel-Tests.st

@@ -1356,6 +1356,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.
@@ -1390,6 +1396,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.