Browse Source

Added tests for send rcv/arg order.

Herbert Vojčík 12 năm trước cách đây
mục cha
commit
63ea75d0f7
3 tập tin đã thay đổi với 43 bổ sung0 xóa
  1. 12 0
      js/Compiler-Tests.deploy.js
  2. 17 0
      js/Compiler-Tests.js
  3. 14 0
      st/Compiler-Tests.st

+ 12 - 0
js/Compiler-Tests.deploy.js

@@ -200,6 +200,18 @@ fn: function () {
 }),
 smalltalk.CodeGeneratorTest);
 
+smalltalk.addMethod(
+"_testSendReceiverAndArgumentsOrdered",
+smalltalk.method({
+selector: "testSendReceiverAndArgumentsOrdered",
+fn: function (){
+var self=this;
+smalltalk.send(self,"_should_return_",["foo\x0a  | x |\x0a  x := 1.\x0a  ^ Array with: x with: (true ifTrue: [ x := 2 ])\x0a",[(1), (2)]]);
+smalltalk.send(self,"_should_return_",["foo\x0a  | x |\x0a  x := Array.\x0a  ^ x with: x with: (true ifTrue: [ x := 2 ])\x0a",[(smalltalk.Array || Array),(2)]]);
+return self}
+}),
+smalltalk.CodeGeneratorTest);
+
 smalltalk.addMethod(
 "_testifFalse",
 smalltalk.method({

+ 17 - 0
js/Compiler-Tests.js

@@ -270,6 +270,23 @@ referencedClasses: []
 }),
 smalltalk.CodeGeneratorTest);
 
+smalltalk.addMethod(
+"_testSendReceiverAndArgumentsOrdered",
+smalltalk.method({
+selector: "testSendReceiverAndArgumentsOrdered",
+category: 'tests',
+fn: function (){
+var self=this;
+smalltalk.send(self,"_should_return_",["foo\x0a  | x |\x0a  x := 1.\x0a  ^ Array with: x with: (true ifTrue: [ x := 2 ])\x0a",[(1), (2)]]);
+smalltalk.send(self,"_should_return_",["foo\x0a  | x |\x0a  x := Array.\x0a  ^ x with: x with: (true ifTrue: [ x := 2 ])\x0a",[(smalltalk.Array || Array),(2)]]);
+return self},
+args: [],
+source: "testSendReceiverAndArgumentsOrdered\x0a\x09self should: 'foo\x0a  | x |\x0a  x := 1.\x0a  ^ Array with: x with: (true ifTrue: [ x := 2 ])\x0a' return: #(1 2).\x0a\x0a\x09self should: 'foo\x0a  | x |\x0a  x := Array.\x0a  ^ x with: x with: (true ifTrue: [ x := 2 ])\x0a' return: {Array. 2}.\x0a",
+messageSends: ["should:return:"],
+referencedClasses: ["Array"]
+}),
+smalltalk.CodeGeneratorTest);
+
 smalltalk.addMethod(
 "_testifFalse",
 smalltalk.method({

+ 14 - 0
st/Compiler-Tests.st

@@ -107,6 +107,20 @@ testNonLocalReturn
 	self should: 'foo [ :x | ^ x + x ] value: 4. ^ 2' return: 8
 !
 
+testSendReceiverAndArgumentsOrdered
+	self should: 'foo
+  | x |
+  x := 1.
+  ^ Array with: x with: (true ifTrue: [ x := 2 ])
+' return: #(1 2).
+
+	self should: 'foo
+  | x |
+  x := Array.
+  ^ x with: x with: (true ifTrue: [ x := 2 ])
+' return: {Array. 2}.
+!
+
 testifFalse
 	self should: 'foo true ifFalse: [ ^ 1 ]' return: receiver.
 	self should: 'foo false ifFalse: [ ^ 2 ]' return: 2.