1
0

Compiler-Tests.js 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153
  1. smalltalk.addPackage('Compiler-Tests', {});
  2. smalltalk.addClass('ASTInterpreterTest', smalltalk.TestCase, [], 'Compiler-Tests');
  3. smalltalk.addMethod(
  4. "_analyze_forClass_",
  5. smalltalk.method({
  6. selector: "analyze:forClass:",
  7. category: 'accessing',
  8. fn: function (aNode,aClass){
  9. var self=this;
  10. return smalltalk.withContext(function($ctx1) { var $1;
  11. _st(_st((smalltalk.SemanticAnalyzer || SemanticAnalyzer))._on_(aClass))._visit_(aNode);
  12. $1=aNode;
  13. return $1;
  14. }, function($ctx1) {$ctx1.fill(self,"analyze:forClass:",{aNode:aNode,aClass:aClass}, smalltalk.ASTInterpreterTest)})},
  15. args: ["aNode", "aClass"],
  16. source: "analyze: aNode forClass: aClass\x0a\x09(SemanticAnalyzer on: aClass) visit: aNode.\x0a ^ aNode",
  17. messageSends: ["visit:", "on:"],
  18. referencedClasses: ["SemanticAnalyzer"]
  19. }),
  20. smalltalk.ASTInterpreterTest);
  21. smalltalk.addMethod(
  22. "_interpret_",
  23. smalltalk.method({
  24. selector: "interpret:",
  25. category: 'accessing',
  26. fn: function (aString){
  27. var self=this;
  28. return smalltalk.withContext(function($ctx1) { var $1;
  29. $1=_st(self)._interpret_withArguments_(aString,_st((smalltalk.Dictionary || Dictionary))._new());
  30. return $1;
  31. }, function($ctx1) {$ctx1.fill(self,"interpret:",{aString:aString}, smalltalk.ASTInterpreterTest)})},
  32. args: ["aString"],
  33. source: "interpret: aString\x0a\x09^ self \x0a \x09interpret: aString \x0a withArguments: Dictionary new",
  34. messageSends: ["interpret:withArguments:", "new"],
  35. referencedClasses: ["Dictionary"]
  36. }),
  37. smalltalk.ASTInterpreterTest);
  38. smalltalk.addMethod(
  39. "_interpret_receiver_withArguments_",
  40. smalltalk.method({
  41. selector: "interpret:receiver:withArguments:",
  42. category: 'accessing',
  43. fn: function (aString,anObject,aDictionary){
  44. var self=this;
  45. var ctx;
  46. return smalltalk.withContext(function($ctx1) { var $2,$3,$1;
  47. ctx=_st((smalltalk.AIContext || AIContext))._new();
  48. _st(ctx)._receiver_(anObject);
  49. _st(aDictionary)._keysAndValuesDo_((function(key,value){
  50. return smalltalk.withContext(function($ctx2) { return _st(ctx)._localAt_put_(key,value);
  51. }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1)})}));
  52. $2=_st(self)._interpreter();
  53. _st($2)._context_(ctx);
  54. $3=_st($2)._interpret_(_st(_st(_st(self)._parse_forClass_(aString,_st(anObject)._class()))._nodes())._first());
  55. $1=$3;
  56. return $1;
  57. }, function($ctx1) {$ctx1.fill(self,"interpret:receiver:withArguments:",{aString:aString,anObject:anObject,aDictionary:aDictionary,ctx:ctx}, smalltalk.ASTInterpreterTest)})},
  58. args: ["aString", "anObject", "aDictionary"],
  59. source: "interpret: aString receiver: anObject withArguments: aDictionary\x0a\x09\x22The food is a methodNode. Interpret the sequenceNode only\x22\x0a \x0a | ctx |\x0a \x0a ctx := AIContext new.\x0a ctx receiver: anObject.\x0a aDictionary keysAndValuesDo: [ :key :value |\x0a \x09ctx localAt: key put: value ].\x0a \x0a ^ self interpreter\x0a \x09context: ctx;\x0a \x09interpret: (self parse: aString forClass: anObject class) \x0a \x09nodes first",
  60. messageSends: ["new", "receiver:", "keysAndValuesDo:", "localAt:put:", "context:", "interpreter", "interpret:", "first", "nodes", "parse:forClass:", "class"],
  61. referencedClasses: ["AIContext"]
  62. }),
  63. smalltalk.ASTInterpreterTest);
  64. smalltalk.addMethod(
  65. "_interpret_withArguments_",
  66. smalltalk.method({
  67. selector: "interpret:withArguments:",
  68. category: 'accessing',
  69. fn: function (aString,aDictionary){
  70. var self=this;
  71. return smalltalk.withContext(function($ctx1) { var $1;
  72. $1=_st(self)._interpret_receiver_withArguments_(aString,_st((smalltalk.Object || Object))._new(),aDictionary);
  73. return $1;
  74. }, function($ctx1) {$ctx1.fill(self,"interpret:withArguments:",{aString:aString,aDictionary:aDictionary}, smalltalk.ASTInterpreterTest)})},
  75. args: ["aString", "aDictionary"],
  76. source: "interpret: aString withArguments: aDictionary\x0a\x09^ self \x0a \x09interpret: aString \x0a receiver: Object new\x0a withArguments: aDictionary",
  77. messageSends: ["interpret:receiver:withArguments:", "new"],
  78. referencedClasses: ["Object"]
  79. }),
  80. smalltalk.ASTInterpreterTest);
  81. smalltalk.addMethod(
  82. "_interpreter",
  83. smalltalk.method({
  84. selector: "interpreter",
  85. category: 'accessing',
  86. fn: function (){
  87. var self=this;
  88. return smalltalk.withContext(function($ctx1) { var $1;
  89. $1=_st((smalltalk.ASTInterpreter || ASTInterpreter))._new();
  90. return $1;
  91. }, function($ctx1) {$ctx1.fill(self,"interpreter",{}, smalltalk.ASTInterpreterTest)})},
  92. args: [],
  93. source: "interpreter\x0a\x09^ ASTInterpreter new",
  94. messageSends: ["new"],
  95. referencedClasses: ["ASTInterpreter"]
  96. }),
  97. smalltalk.ASTInterpreterTest);
  98. smalltalk.addMethod(
  99. "_parse_",
  100. smalltalk.method({
  101. selector: "parse:",
  102. category: 'accessing',
  103. fn: function (aString){
  104. var self=this;
  105. return smalltalk.withContext(function($ctx1) { var $1;
  106. $1=_st(_st((smalltalk.Smalltalk || Smalltalk))._current())._parse_(aString);
  107. return $1;
  108. }, function($ctx1) {$ctx1.fill(self,"parse:",{aString:aString}, smalltalk.ASTInterpreterTest)})},
  109. args: ["aString"],
  110. source: "parse: aString\x0a\x09^ Smalltalk current parse: aString",
  111. messageSends: ["parse:", "current"],
  112. referencedClasses: ["Smalltalk"]
  113. }),
  114. smalltalk.ASTInterpreterTest);
  115. smalltalk.addMethod(
  116. "_parse_forClass_",
  117. smalltalk.method({
  118. selector: "parse:forClass:",
  119. category: 'accessing',
  120. fn: function (aString,aClass){
  121. var self=this;
  122. return smalltalk.withContext(function($ctx1) { var $1;
  123. $1=_st(self)._analyze_forClass_(_st(self)._parse_(aString),aClass);
  124. return $1;
  125. }, function($ctx1) {$ctx1.fill(self,"parse:forClass:",{aString:aString,aClass:aClass}, smalltalk.ASTInterpreterTest)})},
  126. args: ["aString", "aClass"],
  127. source: "parse: aString forClass: aClass\x0a\x09^ self analyze: (self parse: aString) forClass: aClass",
  128. messageSends: ["analyze:forClass:", "parse:"],
  129. referencedClasses: []
  130. }),
  131. smalltalk.ASTInterpreterTest);
  132. smalltalk.addMethod(
  133. "_testBinarySend",
  134. smalltalk.method({
  135. selector: "testBinarySend",
  136. category: 'tests',
  137. fn: function (){
  138. var self=this;
  139. return smalltalk.withContext(function($ctx1) { _st(self)._assert_equals_(_st(self)._interpret_("foo 2+3+4"),(9));
  140. return self}, function($ctx1) {$ctx1.fill(self,"testBinarySend",{}, smalltalk.ASTInterpreterTest)})},
  141. args: [],
  142. source: "testBinarySend\x0a\x09self assert: (self interpret: 'foo 2+3+4') equals: 9",
  143. messageSends: ["assert:equals:", "interpret:"],
  144. referencedClasses: []
  145. }),
  146. smalltalk.ASTInterpreterTest);
  147. smalltalk.addMethod(
  148. "_testBlockLiteral",
  149. smalltalk.method({
  150. selector: "testBlockLiteral",
  151. category: 'tests',
  152. fn: function (){
  153. var self=this;
  154. return smalltalk.withContext(function($ctx1) { _st(self)._assert_equals_(_st(self)._interpret_("foo ^ true ifTrue: [ 1 ] ifFalse: [ 2 ]"),(1));
  155. _st(self)._assert_equals_(_st(self)._interpret_("foo true ifTrue: [ ^ 1 ] ifFalse: [ 2 ]"),(1));
  156. _st(self)._assert_equals_(_st(self)._interpret_("foo ^ false ifTrue: [ 1 ] ifFalse: [ 2 ]"),(2));
  157. return self}, function($ctx1) {$ctx1.fill(self,"testBlockLiteral",{}, smalltalk.ASTInterpreterTest)})},
  158. args: [],
  159. source: "testBlockLiteral\x0a\x09self assert: (self interpret: 'foo ^ true ifTrue: [ 1 ] ifFalse: [ 2 ]') equals: 1.\x0a self assert: (self interpret: 'foo true ifTrue: [ ^ 1 ] ifFalse: [ 2 ]') equals: 1.\x0a self assert: (self interpret: 'foo ^ false ifTrue: [ 1 ] ifFalse: [ 2 ]') equals: 2",
  160. messageSends: ["assert:equals:", "interpret:"],
  161. referencedClasses: []
  162. }),
  163. smalltalk.ASTInterpreterTest);
  164. smalltalk.addMethod(
  165. "_testCascade",
  166. smalltalk.method({
  167. selector: "testCascade",
  168. category: 'tests',
  169. fn: function (){
  170. var self=this;
  171. return smalltalk.withContext(function($ctx1) { _st(self)._assert_equals_(_st(self)._interpret_("foo ^ OrderedCollection new add: 2; add: 3; yourself"),_st((smalltalk.OrderedCollection || OrderedCollection))._with_with_((2),(3)));
  172. return self}, function($ctx1) {$ctx1.fill(self,"testCascade",{}, smalltalk.ASTInterpreterTest)})},
  173. args: [],
  174. source: "testCascade\x0a\x09self assert: (self interpret: 'foo ^ OrderedCollection new add: 2; add: 3; yourself') equals: (OrderedCollection with: 2 with: 3)",
  175. messageSends: ["assert:equals:", "interpret:", "with:with:"],
  176. referencedClasses: ["OrderedCollection"]
  177. }),
  178. smalltalk.ASTInterpreterTest);
  179. smalltalk.addMethod(
  180. "_testInlinedJSStatement",
  181. smalltalk.method({
  182. selector: "testInlinedJSStatement",
  183. category: 'tests',
  184. fn: function (){
  185. var self=this;
  186. return smalltalk.withContext(function($ctx1) { _st(self)._assert_equals_(_st(self)._interpret_("foo <return 2+3>"),(5));
  187. _st(self)._assert_equals_(_st(self)._interpret_withArguments_("foo: anInteger <return 2 + anInteger>",smalltalk.HashedCollection._fromPairs_([_st("anInteger").__minus_gt((3))])),(5));
  188. return self}, function($ctx1) {$ctx1.fill(self,"testInlinedJSStatement",{}, smalltalk.ASTInterpreterTest)})},
  189. args: [],
  190. source: "testInlinedJSStatement\x0a\x09self assert: (self interpret: 'foo <return 2+3>') equals: 5.\x0a \x0a self \x0a \x09assert: (self \x0a \x09\x09interpret: 'foo: anInteger <return 2 + anInteger>' \x0a \x09withArguments: #{ 'anInteger' -> 3}) \x0a\x09\x09equals: 5",
  191. messageSends: ["assert:equals:", "interpret:", "interpret:withArguments:", "->"],
  192. referencedClasses: []
  193. }),
  194. smalltalk.ASTInterpreterTest);
  195. smalltalk.addMethod(
  196. "_testInstVarAssignment",
  197. smalltalk.method({
  198. selector: "testInstVarAssignment",
  199. category: 'tests',
  200. fn: function (){
  201. var self=this;
  202. return smalltalk.withContext(function($ctx1) { _st(self)._assert_equals_(_st(self)._interpret_receiver_withArguments_("foo: anInteger x := anInteger. ^ x",_st((smalltalk.Point || Point))._new(),smalltalk.HashedCollection._fromPairs_([_st("anInteger").__minus_gt((2))])),(2));
  203. return self}, function($ctx1) {$ctx1.fill(self,"testInstVarAssignment",{}, smalltalk.ASTInterpreterTest)})},
  204. args: [],
  205. source: "testInstVarAssignment\x0a\x09self \x0a \x09assert: (self \x0a \x09\x09interpret: 'foo: anInteger x := anInteger. ^ x'\x0a \x09receiver: Point new\x0a \x09withArguments: #{'anInteger' -> 2})\x0a equals: 2",
  206. messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "new", "->"],
  207. referencedClasses: ["Point"]
  208. }),
  209. smalltalk.ASTInterpreterTest);
  210. smalltalk.addMethod(
  211. "_testTempAssignment",
  212. smalltalk.method({
  213. selector: "testTempAssignment",
  214. category: 'tests',
  215. fn: function (){
  216. var self=this;
  217. return smalltalk.withContext(function($ctx1) { _st(self)._assert_equals_(_st(self)._interpret_("foo | a | a := 2. ^ a"),(2));
  218. return self}, function($ctx1) {$ctx1.fill(self,"testTempAssignment",{}, smalltalk.ASTInterpreterTest)})},
  219. args: [],
  220. source: "testTempAssignment\x0a\x09self assert: (self interpret: 'foo | a | a := 2. ^ a') equals: 2",
  221. messageSends: ["assert:equals:", "interpret:"],
  222. referencedClasses: []
  223. }),
  224. smalltalk.ASTInterpreterTest);
  225. smalltalk.addClass('CodeGeneratorTest', smalltalk.TestCase, ['receiver'], 'Compiler-Tests');
  226. smalltalk.addMethod(
  227. "_codeGeneratorClass",
  228. smalltalk.method({
  229. selector: "codeGeneratorClass",
  230. category: 'accessing',
  231. fn: function (){
  232. var self=this;
  233. return smalltalk.withContext(function($ctx1) { var $1;
  234. $1=(smalltalk.CodeGenerator || CodeGenerator);
  235. return $1;
  236. }, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{}, smalltalk.CodeGeneratorTest)})},
  237. args: [],
  238. source: "codeGeneratorClass\x0a\x09^ CodeGenerator",
  239. messageSends: [],
  240. referencedClasses: ["CodeGenerator"]
  241. }),
  242. smalltalk.CodeGeneratorTest);
  243. smalltalk.addMethod(
  244. "_compiler",
  245. smalltalk.method({
  246. selector: "compiler",
  247. category: 'factory',
  248. fn: function (){
  249. var self=this;
  250. return smalltalk.withContext(function($ctx1) { var $2,$3,$1;
  251. $2=_st((smalltalk.Compiler || Compiler))._new();
  252. _st($2)._codeGeneratorClass_(_st(self)._codeGeneratorClass());
  253. $3=_st($2)._yourself();
  254. $1=$3;
  255. return $1;
  256. }, function($ctx1) {$ctx1.fill(self,"compiler",{}, smalltalk.CodeGeneratorTest)})},
  257. args: [],
  258. source: "compiler\x0a\x09^ Compiler new\x0a\x09\x09codeGeneratorClass: self codeGeneratorClass;\x0a\x09\x09yourself",
  259. messageSends: ["codeGeneratorClass:", "codeGeneratorClass", "new", "yourself"],
  260. referencedClasses: ["Compiler"]
  261. }),
  262. smalltalk.CodeGeneratorTest);
  263. smalltalk.addMethod(
  264. "_setUp",
  265. smalltalk.method({
  266. selector: "setUp",
  267. category: 'initialization',
  268. fn: function (){
  269. var self=this;
  270. return smalltalk.withContext(function($ctx1) { self["@receiver"]=_st(_st(self)._targetClass())._new();
  271. return self}, function($ctx1) {$ctx1.fill(self,"setUp",{}, smalltalk.CodeGeneratorTest)})},
  272. args: [],
  273. source: "setUp\x0a\x09receiver := self targetClass new",
  274. messageSends: ["new", "targetClass"],
  275. referencedClasses: []
  276. }),
  277. smalltalk.CodeGeneratorTest);
  278. smalltalk.addMethod(
  279. "_should_return_",
  280. smalltalk.method({
  281. selector: "should:return:",
  282. category: 'testing',
  283. fn: function (aString,anObject){
  284. var self=this;
  285. var method,result;
  286. return smalltalk.withContext(function($ctx1) { method=_st(_st(self)._compiler())._install_forClass_category_(aString,_st(self)._targetClass(),"tests");
  287. result=_st(self["@receiver"])._perform_(_st(method)._selector());
  288. _st(_st(self)._targetClass())._removeCompiledMethod_(method);
  289. _st(self)._assert_equals_(anObject,result);
  290. return self}, function($ctx1) {$ctx1.fill(self,"should:return:",{aString:aString,anObject:anObject,method:method,result:result}, smalltalk.CodeGeneratorTest)})},
  291. args: ["aString", "anObject"],
  292. source: "should: aString return: anObject\x0a\x09| method result |\x0a\x0a\x09method := self compiler install: aString forClass: self targetClass category: 'tests'.\x0a\x09result := receiver perform: method selector.\x0a\x09self targetClass removeCompiledMethod: method.\x0a\x09self assert: anObject equals: result",
  293. messageSends: ["install:forClass:category:", "targetClass", "compiler", "perform:", "selector", "removeCompiledMethod:", "assert:equals:"],
  294. referencedClasses: []
  295. }),
  296. smalltalk.CodeGeneratorTest);
  297. smalltalk.addMethod(
  298. "_targetClass",
  299. smalltalk.method({
  300. selector: "targetClass",
  301. category: 'accessing',
  302. fn: function (){
  303. var self=this;
  304. return smalltalk.withContext(function($ctx1) { var $1;
  305. $1=(smalltalk.DoIt || DoIt);
  306. return $1;
  307. }, function($ctx1) {$ctx1.fill(self,"targetClass",{}, smalltalk.CodeGeneratorTest)})},
  308. args: [],
  309. source: "targetClass\x0a\x09^ DoIt",
  310. messageSends: [],
  311. referencedClasses: ["DoIt"]
  312. }),
  313. smalltalk.CodeGeneratorTest);
  314. smalltalk.addMethod(
  315. "_tearDown",
  316. smalltalk.method({
  317. selector: "tearDown",
  318. category: 'initialization',
  319. fn: function (){
  320. var self=this;
  321. return smalltalk.withContext(function($ctx1) { return self}, function($ctx1) {$ctx1.fill(self,"tearDown",{}, smalltalk.CodeGeneratorTest)})},
  322. args: [],
  323. source: "tearDown\x0a\x09\x22receiver := nil\x22",
  324. messageSends: [],
  325. referencedClasses: []
  326. }),
  327. smalltalk.CodeGeneratorTest);
  328. smalltalk.addMethod(
  329. "_testAssignment",
  330. smalltalk.method({
  331. selector: "testAssignment",
  332. category: 'tests',
  333. fn: function (){
  334. var self=this;
  335. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo | a | a := true ifTrue: [ 1 ]. ^ a",(1));
  336. _st(self)._should_return_("foo | a | a := false ifTrue: [ 1 ]. ^ a",nil);
  337. _st(self)._should_return_("foo | a | ^ a := true ifTrue: [ 1 ]",(1));
  338. return self}, function($ctx1) {$ctx1.fill(self,"testAssignment",{}, smalltalk.CodeGeneratorTest)})},
  339. args: [],
  340. source: "testAssignment\x0a\x09self should: 'foo | a | a := true ifTrue: [ 1 ]. ^ a' return: 1.\x0a\x09self should: 'foo | a | a := false ifTrue: [ 1 ]. ^ a' return: nil.\x0a\x0a\x09self should: 'foo | a | ^ a := true ifTrue: [ 1 ]' return: 1 ",
  341. messageSends: ["should:return:"],
  342. referencedClasses: []
  343. }),
  344. smalltalk.CodeGeneratorTest);
  345. smalltalk.addMethod(
  346. "_testBlockReturn",
  347. smalltalk.method({
  348. selector: "testBlockReturn",
  349. category: 'tests',
  350. fn: function (){
  351. var self=this;
  352. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ #(1 2 3) collect: [ :each | true ifTrue: [ each + 1 ] ]",[(2), (3), (4)]);
  353. _st(self)._should_return_("foo ^ #(1 2 3) collect: [ :each | false ifFalse: [ each + 1 ] ]",[(2), (3), (4)]);
  354. _st(self)._should_return_("foo ^ #(1 2 3) collect: [ :each | each odd ifTrue: [ each + 1 ] ifFalse: [ each - 1 ] ]",[(2), (1), (4)]);
  355. return self}, function($ctx1) {$ctx1.fill(self,"testBlockReturn",{}, smalltalk.CodeGeneratorTest)})},
  356. args: [],
  357. source: "testBlockReturn\x0a\x09self should: 'foo ^ #(1 2 3) collect: [ :each | true ifTrue: [ each + 1 ] ]' return: #(2 3 4).\x0a\x09self should: 'foo ^ #(1 2 3) collect: [ :each | false ifFalse: [ each + 1 ] ]' return: #(2 3 4).\x0a\x09self should: 'foo ^ #(1 2 3) collect: [ :each | each odd ifTrue: [ each + 1 ] ifFalse: [ each - 1 ] ]' return: #(2 1 4).",
  358. messageSends: ["should:return:"],
  359. referencedClasses: []
  360. }),
  361. smalltalk.CodeGeneratorTest);
  362. smalltalk.addMethod(
  363. "_testCascades",
  364. smalltalk.method({
  365. selector: "testCascades",
  366. category: 'tests',
  367. fn: function (){
  368. var self=this;
  369. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ Array new add: 3; add: 4; yourself",[(3), (4)]);
  370. return self}, function($ctx1) {$ctx1.fill(self,"testCascades",{}, smalltalk.CodeGeneratorTest)})},
  371. args: [],
  372. source: "testCascades\x0a\x09\x0a\x09self should: 'foo ^ Array new add: 3; add: 4; yourself' return: #(3 4)",
  373. messageSends: ["should:return:"],
  374. referencedClasses: []
  375. }),
  376. smalltalk.CodeGeneratorTest);
  377. smalltalk.addMethod(
  378. "_testDynamicArrayElementsOrdered",
  379. smalltalk.method({
  380. selector: "testDynamicArrayElementsOrdered",
  381. category: 'tests',
  382. fn: function (){
  383. var self=this;
  384. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo\x0a | x |\x0a x := 1.\x0a ^ { x. true ifTrue: [ x := 2 ] }\x0a",[(1), (2)]);
  385. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicArrayElementsOrdered",{}, smalltalk.CodeGeneratorTest)})},
  386. args: [],
  387. source: "testDynamicArrayElementsOrdered\x0a\x09self should: 'foo\x0a | x |\x0a x := 1.\x0a ^ { x. true ifTrue: [ x := 2 ] }\x0a' return: #(1 2).\x0a",
  388. messageSends: ["should:return:"],
  389. referencedClasses: []
  390. }),
  391. smalltalk.CodeGeneratorTest);
  392. smalltalk.addMethod(
  393. "_testDynamicDictionaryElementsOrdered",
  394. smalltalk.method({
  395. selector: "testDynamicDictionaryElementsOrdered",
  396. category: 'tests',
  397. fn: function (){
  398. var self=this;
  399. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo\x0a | x |\x0a x := 'foo'->1.\x0a ^ #{ x. (true ifTrue: [ x := 'bar'->2 ]) }\x0a",smalltalk.HashedCollection._fromPairs_([_st("foo").__minus_gt((1)),_st("bar").__minus_gt((2))]));
  400. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicDictionaryElementsOrdered",{}, smalltalk.CodeGeneratorTest)})},
  401. args: [],
  402. source: "testDynamicDictionaryElementsOrdered\x0a\x09self should: 'foo\x0a | x |\x0a x := ''foo''->1.\x0a ^ #{ x. (true ifTrue: [ x := ''bar''->2 ]) }\x0a' return: #{'foo'->1. 'bar'->2}.\x0a",
  403. messageSends: ["should:return:", "->"],
  404. referencedClasses: []
  405. }),
  406. smalltalk.CodeGeneratorTest);
  407. smalltalk.addMethod(
  408. "_testInnerTemporalDependentElementsOrdered",
  409. smalltalk.method({
  410. selector: "testInnerTemporalDependentElementsOrdered",
  411. category: 'tests',
  412. fn: function (){
  413. var self=this;
  414. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo\x0a | x |\x0a x := Array.\x0a ^ x with: 'foo'->x with: 'bar'->(true ifTrue: [ x := 2 ])\x0a",[_st("foo").__minus_gt((smalltalk.Array || Array)),_st("bar").__minus_gt((2))]);
  415. _st(self)._should_return_("foo\x0a | x |\x0a x := 1.\x0a ^ Array with: 'foo'->x with: 'bar'->(true ifTrue: [ x := 2 ])\x0a",[_st("foo").__minus_gt((1)),_st("bar").__minus_gt((2))]);
  416. _st(self)._should_return_("foo\x0a | x |\x0a x := 1.\x0a ^ { 'foo'->x. 'bar'->(true ifTrue: [ x := 2 ]) }\x0a",[_st("foo").__minus_gt((1)),_st("bar").__minus_gt((2))]);
  417. _st(self)._should_return_("foo\x0a | x |\x0a x := 1.\x0a ^ #{ 'foo'->x. 'bar'->(true ifTrue: [ x := 2 ]) }\x0a",smalltalk.HashedCollection._fromPairs_([_st("foo").__minus_gt((1)),_st("bar").__minus_gt((2))]));
  418. return self}, function($ctx1) {$ctx1.fill(self,"testInnerTemporalDependentElementsOrdered",{}, smalltalk.CodeGeneratorTest)})},
  419. args: [],
  420. source: "testInnerTemporalDependentElementsOrdered\x0a\x09self should: 'foo\x0a | x |\x0a x := Array.\x0a ^ x with: ''foo''->x with: ''bar''->(true ifTrue: [ x := 2 ])\x0a' return: {'foo'->Array. 'bar'->2}.\x0a\x09self should: 'foo\x0a | x |\x0a x := 1.\x0a ^ Array with: ''foo''->x with: ''bar''->(true ifTrue: [ x := 2 ])\x0a' return: {'foo'->1. 'bar'->2}.\x0a\x09self should: 'foo\x0a | x |\x0a x := 1.\x0a ^ { ''foo''->x. ''bar''->(true ifTrue: [ x := 2 ]) }\x0a' return: {'foo'->1. 'bar'->2}.\x0a\x09self should: 'foo\x0a | x |\x0a x := 1.\x0a ^ #{ ''foo''->x. ''bar''->(true ifTrue: [ x := 2 ]) }\x0a' return: #{'foo'->1. 'bar'->2}.\x0a",
  421. messageSends: ["should:return:", "->"],
  422. referencedClasses: ["Array"]
  423. }),
  424. smalltalk.CodeGeneratorTest);
  425. smalltalk.addMethod(
  426. "_testLiterals",
  427. smalltalk.method({
  428. selector: "testLiterals",
  429. category: 'tests',
  430. fn: function (){
  431. var self=this;
  432. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ 1",(1));
  433. _st(self)._should_return_("foo ^ 'hello'","hello");
  434. _st(self)._should_return_("foo ^ #(1 2 3 4)",[(1), (2), (3), (4)]);
  435. _st(self)._should_return_("foo ^ {1. [:x | x ] value: 2. 3. [4] value}",[(1), (2), (3), (4)]);
  436. _st(self)._should_return_("foo ^ true",true);
  437. _st(self)._should_return_("foo ^ false",false);
  438. _st(self)._should_return_("foo ^ #{1->2. 3->4}",smalltalk.HashedCollection._fromPairs_([_st((1)).__minus_gt((2)),_st((3)).__minus_gt((4))]));
  439. _st(self)._should_return_("foo ^ #hello",smalltalk.symbolFor("hello"));
  440. _st(self)._should_return_("foo ^ -123.456",(-123.456));
  441. return self}, function($ctx1) {$ctx1.fill(self,"testLiterals",{}, smalltalk.CodeGeneratorTest)})},
  442. args: [],
  443. source: "testLiterals\x0a\x09self should: 'foo ^ 1' return: 1.\x0a\x09self should: 'foo ^ ''hello''' return: 'hello'.\x0a\x09self should: 'foo ^ #(1 2 3 4)' return: #(1 2 3 4).\x0a\x09self should: 'foo ^ {1. [:x | x ] value: 2. 3. [4] value}' return: #(1 2 3 4).\x0a\x09self should: 'foo ^ true' return: true.\x0a\x09self should: 'foo ^ false' return: false.\x0a\x09self should: 'foo ^ #{1->2. 3->4}' return: #{1->2. 3->4}.\x0a\x09self should: 'foo ^ #hello' return: #hello.\x0a\x09self should: 'foo ^ -123.456' return: -123.456",
  444. messageSends: ["should:return:", "->"],
  445. referencedClasses: []
  446. }),
  447. smalltalk.CodeGeneratorTest);
  448. smalltalk.addMethod(
  449. "_testLocalReturn",
  450. smalltalk.method({
  451. selector: "testLocalReturn",
  452. category: 'tests',
  453. fn: function (){
  454. var self=this;
  455. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ 1",(1));
  456. _st(self)._should_return_("foo ^ 1 + 1",(2));
  457. _st(self)._should_return_("foo ",self["@receiver"]);
  458. _st(self)._should_return_("foo self asString",self["@receiver"]);
  459. _st(self)._should_return_("foo | a b | a := 1. b := 2. ^ a + b",(3));
  460. return self}, function($ctx1) {$ctx1.fill(self,"testLocalReturn",{}, smalltalk.CodeGeneratorTest)})},
  461. args: [],
  462. source: "testLocalReturn\x0a\x09self should: 'foo ^ 1' return: 1.\x0a\x09self should: 'foo ^ 1 + 1' return: 2.\x0a\x09self should: 'foo ' return: receiver.\x0a\x09self should: 'foo self asString' return: receiver.\x0a\x09self should: 'foo | a b | a := 1. b := 2. ^ a + b' return: 3",
  463. messageSends: ["should:return:"],
  464. referencedClasses: []
  465. }),
  466. smalltalk.CodeGeneratorTest);
  467. smalltalk.addMethod(
  468. "_testMessageSends",
  469. smalltalk.method({
  470. selector: "testMessageSends",
  471. category: 'tests',
  472. fn: function (){
  473. var self=this;
  474. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ 1 asString","1");
  475. _st(self)._should_return_("foo ^ 1 + 1",(2));
  476. _st(self)._should_return_("foo ^ 1 + 2 * 3",(9));
  477. _st(self)._should_return_("foo ^ 1 to: 3",[(1), (2), (3)]);
  478. _st(self)._should_return_("foo ^ 1 to: 5 by: 2",[(1), (3), (5)]);
  479. return self}, function($ctx1) {$ctx1.fill(self,"testMessageSends",{}, smalltalk.CodeGeneratorTest)})},
  480. args: [],
  481. source: "testMessageSends\x0a\x09self should: 'foo ^ 1 asString' return: '1'.\x0a\x0a\x09self should: 'foo ^ 1 + 1' return: 2.\x0a\x09self should: 'foo ^ 1 + 2 * 3' return: 9.\x0a\x0a\x09self should: 'foo ^ 1 to: 3' return: #(1 2 3).\x0a\x09self should: 'foo ^ 1 to: 5 by: 2' return: #(1 3 5)",
  482. messageSends: ["should:return:"],
  483. referencedClasses: []
  484. }),
  485. smalltalk.CodeGeneratorTest);
  486. smalltalk.addMethod(
  487. "_testNestedIfTrue",
  488. smalltalk.method({
  489. selector: "testNestedIfTrue",
  490. category: 'tests',
  491. fn: function (){
  492. var self=this;
  493. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ true ifTrue: [ false ifFalse: [ 1 ] ]",(1));
  494. _st(self)._should_return_("foo ^ true ifTrue: [ false ifTrue: [ 1 ] ]",nil);
  495. _st(self)._should_return_("foo true ifTrue: [ false ifFalse: [ ^ 1 ] ]",(1));
  496. _st(self)._should_return_("foo true ifTrue: [ false ifTrue: [ ^ 1 ] ]",self["@receiver"]);
  497. return self}, function($ctx1) {$ctx1.fill(self,"testNestedIfTrue",{}, smalltalk.CodeGeneratorTest)})},
  498. args: [],
  499. source: "testNestedIfTrue\x0a\x09self should: 'foo ^ true ifTrue: [ false ifFalse: [ 1 ] ]' return: 1.\x0a\x09self should: 'foo ^ true ifTrue: [ false ifTrue: [ 1 ] ]' return: nil.\x0a\x0a\x09self should: 'foo true ifTrue: [ false ifFalse: [ ^ 1 ] ]' return: 1.\x0a\x09self should: 'foo true ifTrue: [ false ifTrue: [ ^ 1 ] ]' return: receiver.",
  500. messageSends: ["should:return:"],
  501. referencedClasses: []
  502. }),
  503. smalltalk.CodeGeneratorTest);
  504. smalltalk.addMethod(
  505. "_testNonLocalReturn",
  506. smalltalk.method({
  507. selector: "testNonLocalReturn",
  508. category: 'tests',
  509. fn: function (){
  510. var self=this;
  511. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo [ ^ 1 ] value",(1));
  512. _st(self)._should_return_("foo [ ^ 1 + 1 ] value",(2));
  513. _st(self)._should_return_("foo | a b | a := 1. b := 2. [ ^ a + b ] value. self halt",(3));
  514. _st(self)._should_return_("foo [ :x | ^ x + x ] value: 4. ^ 2",(8));
  515. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn",{}, smalltalk.CodeGeneratorTest)})},
  516. args: [],
  517. source: "testNonLocalReturn\x0a\x09self should: 'foo [ ^ 1 ] value' return: 1.\x0a\x09self should: 'foo [ ^ 1 + 1 ] value' return: 2.\x0a\x09self should: 'foo | a b | a := 1. b := 2. [ ^ a + b ] value. self halt' return: 3.\x0a\x09self should: 'foo [ :x | ^ x + x ] value: 4. ^ 2' return: 8",
  518. messageSends: ["should:return:"],
  519. referencedClasses: []
  520. }),
  521. smalltalk.CodeGeneratorTest);
  522. smalltalk.addMethod(
  523. "_testSendReceiverAndArgumentsOrdered",
  524. smalltalk.method({
  525. selector: "testSendReceiverAndArgumentsOrdered",
  526. category: 'tests',
  527. fn: function (){
  528. var self=this;
  529. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo\x0a | x |\x0a x := 1.\x0a ^ Array with: x with: (true ifTrue: [ x := 2 ])\x0a",[(1), (2)]);
  530. _st(self)._should_return_("foo\x0a | x |\x0a x := Array.\x0a ^ x with: x with: (true ifTrue: [ x := 2 ])\x0a",[(smalltalk.Array || Array),(2)]);
  531. return self}, function($ctx1) {$ctx1.fill(self,"testSendReceiverAndArgumentsOrdered",{}, smalltalk.CodeGeneratorTest)})},
  532. args: [],
  533. 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",
  534. messageSends: ["should:return:"],
  535. referencedClasses: ["Array"]
  536. }),
  537. smalltalk.CodeGeneratorTest);
  538. smalltalk.addMethod(
  539. "_testifFalse",
  540. smalltalk.method({
  541. selector: "testifFalse",
  542. category: 'tests',
  543. fn: function (){
  544. var self=this;
  545. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo true ifFalse: [ ^ 1 ]",self["@receiver"]);
  546. _st(self)._should_return_("foo false ifFalse: [ ^ 2 ]",(2));
  547. _st(self)._should_return_("foo ^ true ifFalse: [ 1 ]",nil);
  548. _st(self)._should_return_("foo ^ false ifFalse: [ 2 ]",(2));
  549. return self}, function($ctx1) {$ctx1.fill(self,"testifFalse",{}, smalltalk.CodeGeneratorTest)})},
  550. args: [],
  551. source: "testifFalse\x0a\x09self should: 'foo true ifFalse: [ ^ 1 ]' return: receiver.\x0a\x09self should: 'foo false ifFalse: [ ^ 2 ]' return: 2.\x0a\x09\x0a\x09self should: 'foo ^ true ifFalse: [ 1 ]' return: nil.\x0a\x09self should: 'foo ^ false ifFalse: [ 2 ]' return: 2.",
  552. messageSends: ["should:return:"],
  553. referencedClasses: []
  554. }),
  555. smalltalk.CodeGeneratorTest);
  556. smalltalk.addMethod(
  557. "_testifFalseIfTrue",
  558. smalltalk.method({
  559. selector: "testifFalseIfTrue",
  560. category: 'tests',
  561. fn: function (){
  562. var self=this;
  563. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo true ifFalse: [ ^ 1 ] ifTrue: [ ^ 2 ]",(2));
  564. _st(self)._should_return_("foo false ifFalse: [ ^ 2 ] ifTrue: [ ^1 ]",(2));
  565. _st(self)._should_return_("foo ^ true ifFalse: [ 1 ] ifTrue: [ 2 ]",(2));
  566. _st(self)._should_return_("foo ^ false ifFalse: [ 2 ] ifTrue: [ 1 ]",(2));
  567. return self}, function($ctx1) {$ctx1.fill(self,"testifFalseIfTrue",{}, smalltalk.CodeGeneratorTest)})},
  568. args: [],
  569. source: "testifFalseIfTrue\x0a\x09self should: 'foo true ifFalse: [ ^ 1 ] ifTrue: [ ^ 2 ]' return: 2.\x0a\x09self should: 'foo false ifFalse: [ ^ 2 ] ifTrue: [ ^1 ]' return: 2.\x0a\x09\x0a\x09self should: 'foo ^ true ifFalse: [ 1 ] ifTrue: [ 2 ]' return: 2.\x0a\x09self should: 'foo ^ false ifFalse: [ 2 ] ifTrue: [ 1 ]' return: 2.",
  570. messageSends: ["should:return:"],
  571. referencedClasses: []
  572. }),
  573. smalltalk.CodeGeneratorTest);
  574. smalltalk.addMethod(
  575. "_testifNil",
  576. smalltalk.method({
  577. selector: "testifNil",
  578. category: 'tests',
  579. fn: function (){
  580. var self=this;
  581. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ 1 ifNil: [ 2 ]",(1));
  582. _st(self)._should_return_("foo ^ nil ifNil: [ 2 ]",(2));
  583. _st(self)._should_return_("foo 1 ifNil: [ ^ 2 ]",self["@receiver"]);
  584. _st(self)._should_return_("foo nil ifNil: [ ^ 2 ]",(2));
  585. return self}, function($ctx1) {$ctx1.fill(self,"testifNil",{}, smalltalk.CodeGeneratorTest)})},
  586. args: [],
  587. source: "testifNil\x0a\x09self should: 'foo ^ 1 ifNil: [ 2 ]' return: 1.\x0a\x09self should: 'foo ^ nil ifNil: [ 2 ]' return: 2.\x0a\x0a\x09self should: 'foo 1 ifNil: [ ^ 2 ]' return: receiver.\x0a\x09self should: 'foo nil ifNil: [ ^ 2 ]' return: 2.",
  588. messageSends: ["should:return:"],
  589. referencedClasses: []
  590. }),
  591. smalltalk.CodeGeneratorTest);
  592. smalltalk.addMethod(
  593. "_testifNilIfNotNil",
  594. smalltalk.method({
  595. selector: "testifNilIfNotNil",
  596. category: 'tests',
  597. fn: function (){
  598. var self=this;
  599. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ 1 ifNil: [ 2 ] ifNotNil: [ 3 ]",(3));
  600. _st(self)._should_return_("foo ^ nil ifNil: [ 2 ] ifNotNil: [ 3 ]",(2));
  601. _st(self)._should_return_("foo 1 ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]",(3));
  602. _st(self)._should_return_("foo nil ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]",(2));
  603. return self}, function($ctx1) {$ctx1.fill(self,"testifNilIfNotNil",{}, smalltalk.CodeGeneratorTest)})},
  604. args: [],
  605. source: "testifNilIfNotNil\x0a\x09self should: 'foo ^ 1 ifNil: [ 2 ] ifNotNil: [ 3 ]' return: 3.\x0a\x09self should: 'foo ^ nil ifNil: [ 2 ] ifNotNil: [ 3 ]' return: 2.\x0a\x0a\x09self should: 'foo 1 ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]' return: 3.\x0a\x09self should: 'foo nil ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]' return: 2.",
  606. messageSends: ["should:return:"],
  607. referencedClasses: []
  608. }),
  609. smalltalk.CodeGeneratorTest);
  610. smalltalk.addMethod(
  611. "_testifNotNil",
  612. smalltalk.method({
  613. selector: "testifNotNil",
  614. category: 'tests',
  615. fn: function (){
  616. var self=this;
  617. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ 1 ifNotNil: [ 2 ]",(2));
  618. _st(self)._should_return_("foo ^ nil ifNotNil: [ 2 ]",nil);
  619. _st(self)._should_return_("foo 1 ifNotNil: [ ^ 2 ]",(2));
  620. _st(self)._should_return_("foo nil ifNotNil: [ ^ 2 ]",self["@receiver"]);
  621. return self}, function($ctx1) {$ctx1.fill(self,"testifNotNil",{}, smalltalk.CodeGeneratorTest)})},
  622. args: [],
  623. source: "testifNotNil\x0a\x09self should: 'foo ^ 1 ifNotNil: [ 2 ]' return: 2.\x0a\x09self should: 'foo ^ nil ifNotNil: [ 2 ]' return: nil.\x0a\x0a\x09self should: 'foo 1 ifNotNil: [ ^ 2 ]' return: 2.\x0a\x09self should: 'foo nil ifNotNil: [ ^ 2 ]' return: receiver.",
  624. messageSends: ["should:return:"],
  625. referencedClasses: []
  626. }),
  627. smalltalk.CodeGeneratorTest);
  628. smalltalk.addMethod(
  629. "_testifTrue",
  630. smalltalk.method({
  631. selector: "testifTrue",
  632. category: 'tests',
  633. fn: function (){
  634. var self=this;
  635. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo false ifTrue: [ ^ 1 ]",self["@receiver"]);
  636. _st(self)._should_return_("foo true ifTrue: [ ^ 2 ]",(2));
  637. _st(self)._should_return_("foo ^ false ifTrue: [ 1 ]",nil);
  638. _st(self)._should_return_("foo ^ true ifTrue: [ 2 ]",(2));
  639. return self}, function($ctx1) {$ctx1.fill(self,"testifTrue",{}, smalltalk.CodeGeneratorTest)})},
  640. args: [],
  641. source: "testifTrue\x0a\x09self should: 'foo false ifTrue: [ ^ 1 ]' return: receiver.\x0a\x09self should: 'foo true ifTrue: [ ^ 2 ]' return: 2.\x0a\x09\x0a\x09self should: 'foo ^ false ifTrue: [ 1 ]' return: nil.\x0a\x09self should: 'foo ^ true ifTrue: [ 2 ]' return: 2.",
  642. messageSends: ["should:return:"],
  643. referencedClasses: []
  644. }),
  645. smalltalk.CodeGeneratorTest);
  646. smalltalk.addMethod(
  647. "_testifTrueIfFalse",
  648. smalltalk.method({
  649. selector: "testifTrueIfFalse",
  650. category: 'tests',
  651. fn: function (){
  652. var self=this;
  653. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo false ifTrue: [ ^ 1 ] ifFalse: [ ^2 ]",(2));
  654. _st(self)._should_return_("foo true ifTrue: [ ^ 1 ] ifFalse: [ ^ 2 ]",(1));
  655. _st(self)._should_return_("foo ^ false ifTrue: [ 2 ] ifFalse: [ 1 ]",(1));
  656. _st(self)._should_return_("foo ^ true ifTrue: [ 2 ] ifFalse: [ 1 ]",(2));
  657. return self}, function($ctx1) {$ctx1.fill(self,"testifTrueIfFalse",{}, smalltalk.CodeGeneratorTest)})},
  658. args: [],
  659. source: "testifTrueIfFalse\x0a\x09self should: 'foo false ifTrue: [ ^ 1 ] ifFalse: [ ^2 ]' return: 2.\x0a\x09self should: 'foo true ifTrue: [ ^ 1 ] ifFalse: [ ^ 2 ]' return: 1.\x0a\x09\x0a\x09self should: 'foo ^ false ifTrue: [ 2 ] ifFalse: [ 1 ]' return: 1.\x0a\x09self should: 'foo ^ true ifTrue: [ 2 ] ifFalse: [ 1 ]' return: 2.",
  660. messageSends: ["should:return:"],
  661. referencedClasses: []
  662. }),
  663. smalltalk.CodeGeneratorTest);
  664. smalltalk.addClass('InliningCodeGeneratorTest', smalltalk.CodeGeneratorTest, [], 'Compiler-Tests');
  665. smalltalk.addMethod(
  666. "_codeGeneratorClass",
  667. smalltalk.method({
  668. selector: "codeGeneratorClass",
  669. category: 'accessing',
  670. fn: function (){
  671. var self=this;
  672. return smalltalk.withContext(function($ctx1) { var $1;
  673. $1=(smalltalk.InliningCodeGenerator || InliningCodeGenerator);
  674. return $1;
  675. }, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{}, smalltalk.InliningCodeGeneratorTest)})},
  676. args: [],
  677. source: "codeGeneratorClass\x0a\x09^ InliningCodeGenerator",
  678. messageSends: [],
  679. referencedClasses: ["InliningCodeGenerator"]
  680. }),
  681. smalltalk.InliningCodeGeneratorTest);
  682. smalltalk.addClass('ScopeVarTest', smalltalk.TestCase, [], 'Compiler-Tests');
  683. smalltalk.addMethod(
  684. "_testClassRefVar",
  685. smalltalk.method({
  686. selector: "testClassRefVar",
  687. category: 'tests',
  688. fn: function (){
  689. var self=this;
  690. var node;
  691. return smalltalk.withContext(function($ctx1) { var $1,$2;
  692. $1=_st((smalltalk.ClassReferenceNode || ClassReferenceNode))._new();
  693. _st($1)._value_("Object");
  694. $2=_st($1)._yourself();
  695. node=$2;
  696. _st(_st((smalltalk.SemanticAnalyzer || SemanticAnalyzer))._new())._visit_(node);
  697. _st(self)._assert_(_st(_st(node)._binding())._isClassRefVar());
  698. return self}, function($ctx1) {$ctx1.fill(self,"testClassRefVar",{node:node}, smalltalk.ScopeVarTest)})},
  699. args: [],
  700. source: "testClassRefVar\x0a\x09| node |\x0a\x09node := ClassReferenceNode new\x0a\x09\x09value: 'Object';\x0a\x09\x09yourself.\x0a\x09SemanticAnalyzer new visit: node.\x0a\x09self assert: node binding isClassRefVar",
  701. messageSends: ["value:", "new", "yourself", "visit:", "assert:", "isClassRefVar", "binding"],
  702. referencedClasses: ["ClassReferenceNode", "SemanticAnalyzer"]
  703. }),
  704. smalltalk.ScopeVarTest);
  705. smalltalk.addMethod(
  706. "_testInstanceVar",
  707. smalltalk.method({
  708. selector: "testInstanceVar",
  709. category: 'tests',
  710. fn: function (){
  711. var self=this;
  712. var node,scope;
  713. return smalltalk.withContext(function($ctx1) { var $1,$2;
  714. $1=_st((smalltalk.VariableNode || VariableNode))._new();
  715. _st($1)._value_("bzzz");
  716. $2=_st($1)._yourself();
  717. node=$2;
  718. scope=_st((smalltalk.MethodLexicalScope || MethodLexicalScope))._new();
  719. _st(scope)._addIVar_("bzzz");
  720. _st(self)._assert_(_st(_st(scope)._bindingFor_(node))._isInstanceVar());
  721. return self}, function($ctx1) {$ctx1.fill(self,"testInstanceVar",{node:node,scope:scope}, smalltalk.ScopeVarTest)})},
  722. args: [],
  723. source: "testInstanceVar\x0a\x09| node scope |\x0a\x09node := VariableNode new\x0a\x09\x09value: 'bzzz';\x0a\x09\x09yourself.\x0a\x09scope := MethodLexicalScope new.\x0a\x09scope addIVar: 'bzzz'.\x0a\x09self assert: (scope bindingFor: node) isInstanceVar",
  724. messageSends: ["value:", "new", "yourself", "addIVar:", "assert:", "isInstanceVar", "bindingFor:"],
  725. referencedClasses: ["VariableNode", "MethodLexicalScope"]
  726. }),
  727. smalltalk.ScopeVarTest);
  728. smalltalk.addMethod(
  729. "_testPseudoVar",
  730. smalltalk.method({
  731. selector: "testPseudoVar",
  732. category: 'tests',
  733. fn: function (){
  734. var self=this;
  735. var node,pseudoVars;
  736. return smalltalk.withContext(function($ctx1) { var $1,$2;
  737. pseudoVars=["self", "super", "true", "false", "nil"];
  738. _st(pseudoVars)._do_((function(each){
  739. return smalltalk.withContext(function($ctx2) { $1=_st((smalltalk.VariableNode || VariableNode))._new();
  740. _st($1)._value_(each);
  741. $2=_st($1)._yourself();
  742. node=$2;
  743. node;
  744. return _st(self)._assert_(_st(_st(_st((smalltalk.MethodLexicalScope || MethodLexicalScope))._new())._bindingFor_(node))._isPseudoVar());
  745. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  746. return self}, function($ctx1) {$ctx1.fill(self,"testPseudoVar",{node:node,pseudoVars:pseudoVars}, smalltalk.ScopeVarTest)})},
  747. args: [],
  748. source: "testPseudoVar\x0a\x09| node pseudoVars |\x0a\x09pseudoVars := #('self' 'super' 'true' 'false' 'nil').\x0a\x09pseudoVars do: [:each |\x0a\x09\x09node := VariableNode new\x0a\x09\x09value: each;\x0a\x09\x09yourself.\x0a\x09\x09self assert: (MethodLexicalScope new bindingFor: node) isPseudoVar ]",
  749. messageSends: ["do:", "value:", "new", "yourself", "assert:", "isPseudoVar", "bindingFor:"],
  750. referencedClasses: ["VariableNode", "MethodLexicalScope"]
  751. }),
  752. smalltalk.ScopeVarTest);
  753. smalltalk.addMethod(
  754. "_testTempVar",
  755. smalltalk.method({
  756. selector: "testTempVar",
  757. category: 'tests',
  758. fn: function (){
  759. var self=this;
  760. var node,scope;
  761. return smalltalk.withContext(function($ctx1) { var $1,$2;
  762. $1=_st((smalltalk.VariableNode || VariableNode))._new();
  763. _st($1)._value_("bzzz");
  764. $2=_st($1)._yourself();
  765. node=$2;
  766. scope=_st((smalltalk.MethodLexicalScope || MethodLexicalScope))._new();
  767. _st(scope)._addTemp_("bzzz");
  768. _st(self)._assert_(_st(_st(scope)._bindingFor_(node))._isTempVar());
  769. return self}, function($ctx1) {$ctx1.fill(self,"testTempVar",{node:node,scope:scope}, smalltalk.ScopeVarTest)})},
  770. args: [],
  771. source: "testTempVar\x0a\x09| node scope |\x0a\x09node := VariableNode new\x0a\x09\x09value: 'bzzz';\x0a\x09\x09yourself.\x0a\x09scope := MethodLexicalScope new.\x0a\x09scope addTemp: 'bzzz'.\x0a\x09self assert: (scope bindingFor: node) isTempVar",
  772. messageSends: ["value:", "new", "yourself", "addTemp:", "assert:", "isTempVar", "bindingFor:"],
  773. referencedClasses: ["VariableNode", "MethodLexicalScope"]
  774. }),
  775. smalltalk.ScopeVarTest);
  776. smalltalk.addMethod(
  777. "_testUnknownVar",
  778. smalltalk.method({
  779. selector: "testUnknownVar",
  780. category: 'tests',
  781. fn: function (){
  782. var self=this;
  783. var node;
  784. return smalltalk.withContext(function($ctx1) { var $1,$2;
  785. $1=_st((smalltalk.VariableNode || VariableNode))._new();
  786. _st($1)._value_("bzzz");
  787. $2=_st($1)._yourself();
  788. node=$2;
  789. _st(self)._assert_(_st(_st(_st((smalltalk.MethodLexicalScope || MethodLexicalScope))._new())._bindingFor_(node))._isNil());
  790. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVar",{node:node}, smalltalk.ScopeVarTest)})},
  791. args: [],
  792. source: "testUnknownVar\x0a\x09| node |\x0a\x09node := VariableNode new\x0a\x09\x09value: 'bzzz';\x0a\x09\x09yourself.\x0a\x09self assert: (MethodLexicalScope new bindingFor: node) isNil",
  793. messageSends: ["value:", "new", "yourself", "assert:", "isNil", "bindingFor:"],
  794. referencedClasses: ["VariableNode", "MethodLexicalScope"]
  795. }),
  796. smalltalk.ScopeVarTest);
  797. smalltalk.addClass('SemanticAnalyzerTest', smalltalk.TestCase, ['analyzer'], 'Compiler-Tests');
  798. smalltalk.addMethod(
  799. "_setUp",
  800. smalltalk.method({
  801. selector: "setUp",
  802. category: 'running',
  803. fn: function (){
  804. var self=this;
  805. return smalltalk.withContext(function($ctx1) { self["@analyzer"]=_st((smalltalk.SemanticAnalyzer || SemanticAnalyzer))._on_((smalltalk.Object || Object));
  806. return self}, function($ctx1) {$ctx1.fill(self,"setUp",{}, smalltalk.SemanticAnalyzerTest)})},
  807. args: [],
  808. source: "setUp\x0a\x09analyzer := SemanticAnalyzer on: Object",
  809. messageSends: ["on:"],
  810. referencedClasses: ["Object", "SemanticAnalyzer"]
  811. }),
  812. smalltalk.SemanticAnalyzerTest);
  813. smalltalk.addMethod(
  814. "_testAssignment",
  815. smalltalk.method({
  816. selector: "testAssignment",
  817. category: 'tests',
  818. fn: function (){
  819. var self=this;
  820. var src,ast;
  821. return smalltalk.withContext(function($ctx1) { src="foo self := 1";
  822. ast=_st(smalltalk)._parse_(src);
  823. _st(self)._should_raise_((function(){
  824. return smalltalk.withContext(function($ctx2) { return _st(self["@analyzer"])._visit_(ast);
  825. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.InvalidAssignmentError || InvalidAssignmentError));
  826. return self}, function($ctx1) {$ctx1.fill(self,"testAssignment",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})},
  827. args: [],
  828. source: "testAssignment\x0a\x09| src ast |\x0a\x0a\x09src := 'foo self := 1'.\x0a\x09ast := smalltalk parse: src.\x0a\x09self should: [analyzer visit: ast] raise: InvalidAssignmentError",
  829. messageSends: ["parse:", "should:raise:", "visit:"],
  830. referencedClasses: ["InvalidAssignmentError"]
  831. }),
  832. smalltalk.SemanticAnalyzerTest);
  833. smalltalk.addMethod(
  834. "_testNonLocalReturn",
  835. smalltalk.method({
  836. selector: "testNonLocalReturn",
  837. category: 'tests',
  838. fn: function (){
  839. var self=this;
  840. var src,ast;
  841. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. ^ a";
  842. ast=_st(smalltalk)._parse_(src);
  843. _st(self["@analyzer"])._visit_(ast);
  844. _st(self)._deny_(_st(_st(ast)._scope())._hasNonLocalReturn());
  845. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})},
  846. args: [],
  847. source: "testNonLocalReturn\x0a\x09| src ast |\x0a\x0a\x09src := 'foo | a | a + 1. ^ a'.\x0a\x09ast := smalltalk parse: src.\x0a\x09analyzer visit: ast.\x0a\x0a\x09self deny: ast scope hasNonLocalReturn",
  848. messageSends: ["parse:", "visit:", "deny:", "hasNonLocalReturn", "scope"],
  849. referencedClasses: []
  850. }),
  851. smalltalk.SemanticAnalyzerTest);
  852. smalltalk.addMethod(
  853. "_testNonLocalReturn2",
  854. smalltalk.method({
  855. selector: "testNonLocalReturn2",
  856. category: 'tests',
  857. fn: function (){
  858. var self=this;
  859. var src,ast;
  860. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ [ ^ a] ]";
  861. ast=_st(smalltalk)._parse_(src);
  862. _st(self["@analyzer"])._visit_(ast);
  863. _st(self)._assert_(_st(_st(ast)._scope())._hasNonLocalReturn());
  864. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn2",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})},
  865. args: [],
  866. source: "testNonLocalReturn2\x0a\x09| src ast |\x0a\x0a\x09src := 'foo | a | a + 1. [ [ ^ a] ]'.\x0a\x09ast := smalltalk parse: src.\x0a\x09analyzer visit: ast.\x0a\x0a\x09self assert: ast scope hasNonLocalReturn",
  867. messageSends: ["parse:", "visit:", "assert:", "hasNonLocalReturn", "scope"],
  868. referencedClasses: []
  869. }),
  870. smalltalk.SemanticAnalyzerTest);
  871. smalltalk.addMethod(
  872. "_testScope",
  873. smalltalk.method({
  874. selector: "testScope",
  875. category: 'tests',
  876. fn: function (){
  877. var self=this;
  878. var src,ast;
  879. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ | b | b := a ]";
  880. ast=_st(smalltalk)._parse_(src);
  881. _st(self["@analyzer"])._visit_(ast);
  882. _st(self)._deny_(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._scope()).__eq_eq(_st(ast)._scope()));
  883. return self}, function($ctx1) {$ctx1.fill(self,"testScope",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})},
  884. args: [],
  885. source: "testScope\x0a\x09| src ast |\x0a\x0a\x09src := 'foo | a | a + 1. [ | b | b := a ]'.\x0a\x09ast := smalltalk parse: src.\x0a\x09analyzer visit: ast.\x0a\x0a\x09self deny: ast nodes first nodes last scope == ast scope.",
  886. messageSends: ["parse:", "visit:", "deny:", "==", "scope", "last", "nodes", "first"],
  887. referencedClasses: []
  888. }),
  889. smalltalk.SemanticAnalyzerTest);
  890. smalltalk.addMethod(
  891. "_testScope2",
  892. smalltalk.method({
  893. selector: "testScope2",
  894. category: 'tests',
  895. fn: function (){
  896. var self=this;
  897. var src,ast;
  898. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ [ | b | b := a ] ]";
  899. ast=_st(smalltalk)._parse_(src);
  900. _st(self["@analyzer"])._visit_(ast);
  901. _st(self)._deny_(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._nodes())._first())._nodes())._first())._scope()).__eq_eq(_st(ast)._scope()));
  902. return self}, function($ctx1) {$ctx1.fill(self,"testScope2",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})},
  903. args: [],
  904. source: "testScope2\x0a\x09| src ast |\x0a\x0a\x09src := 'foo | a | a + 1. [ [ | b | b := a ] ]'.\x0a\x09ast := smalltalk parse: src.\x0a\x09analyzer visit: ast.\x0a\x0a\x09self deny: ast nodes first nodes last nodes first nodes first scope == ast scope.",
  905. messageSends: ["parse:", "visit:", "deny:", "==", "scope", "first", "nodes", "last"],
  906. referencedClasses: []
  907. }),
  908. smalltalk.SemanticAnalyzerTest);
  909. smalltalk.addMethod(
  910. "_testScopeLevel",
  911. smalltalk.method({
  912. selector: "testScopeLevel",
  913. category: 'tests',
  914. fn: function (){
  915. var self=this;
  916. var src,ast;
  917. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ [ | b | b := a ] ]";
  918. ast=_st(smalltalk)._parse_(src);
  919. _st(self["@analyzer"])._visit_(ast);
  920. _st(self)._assert_(_st(_st(_st(ast)._scope())._scopeLevel()).__eq((1)));
  921. _st(self)._assert_(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._nodes())._first())._nodes())._first())._scope())._scopeLevel()).__eq((3)));
  922. return self}, function($ctx1) {$ctx1.fill(self,"testScopeLevel",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})},
  923. args: [],
  924. source: "testScopeLevel\x0a\x09| src ast |\x0a\x0a\x09src := 'foo | a | a + 1. [ [ | b | b := a ] ]'.\x0a\x09ast := smalltalk parse: src.\x0a\x09analyzer visit: ast.\x0a\x0a\x09self assert: ast scope scopeLevel = 1.\x0a\x09self assert: ast nodes first nodes last nodes first nodes first scope scopeLevel = 3",
  925. messageSends: ["parse:", "visit:", "assert:", "=", "scopeLevel", "scope", "first", "nodes", "last"],
  926. referencedClasses: []
  927. }),
  928. smalltalk.SemanticAnalyzerTest);
  929. smalltalk.addMethod(
  930. "_testUnknownVariables",
  931. smalltalk.method({
  932. selector: "testUnknownVariables",
  933. category: 'tests',
  934. fn: function (){
  935. var self=this;
  936. var src,ast;
  937. return smalltalk.withContext(function($ctx1) { src="foo | a | b + a";
  938. ast=_st(smalltalk)._parse_(src);
  939. _st(self)._should_raise_((function(){
  940. return smalltalk.withContext(function($ctx2) { return _st(self["@analyzer"])._visit_(ast);
  941. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.UnknownVariableError || UnknownVariableError));
  942. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVariables",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})},
  943. args: [],
  944. source: "testUnknownVariables\x0a\x09| src ast |\x0a\x0a\x09src := 'foo | a | b + a'.\x0a\x09ast := smalltalk parse: src.\x0a\x0a\x09self should: [ analyzer visit: ast ] raise: UnknownVariableError",
  945. messageSends: ["parse:", "should:raise:", "visit:"],
  946. referencedClasses: ["UnknownVariableError"]
  947. }),
  948. smalltalk.SemanticAnalyzerTest);
  949. smalltalk.addMethod(
  950. "_testUnknownVariablesWithScope",
  951. smalltalk.method({
  952. selector: "testUnknownVariablesWithScope",
  953. category: 'tests',
  954. fn: function (){
  955. var self=this;
  956. var src,ast;
  957. return smalltalk.withContext(function($ctx1) { src="foo | a b | [ c + 1. [ a + 1. d + 1 ]]";
  958. ast=_st(smalltalk)._parse_(src);
  959. _st(self)._should_raise_((function(){
  960. return smalltalk.withContext(function($ctx2) { return _st(self["@analyzer"])._visit_(ast);
  961. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.UnknownVariableError || UnknownVariableError));
  962. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVariablesWithScope",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})},
  963. args: [],
  964. source: "testUnknownVariablesWithScope\x0a\x09| src ast |\x0a\x0a\x09src := 'foo | a b | [ c + 1. [ a + 1. d + 1 ]]'.\x0a\x09ast := smalltalk parse: src.\x0a\x09\x0a\x09self should: [ analyzer visit: ast ] raise: UnknownVariableError",
  965. messageSends: ["parse:", "should:raise:", "visit:"],
  966. referencedClasses: ["UnknownVariableError"]
  967. }),
  968. smalltalk.SemanticAnalyzerTest);
  969. smalltalk.addMethod(
  970. "_testVariableShadowing",
  971. smalltalk.method({
  972. selector: "testVariableShadowing",
  973. category: 'tests',
  974. fn: function (){
  975. var self=this;
  976. var src,ast;
  977. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1";
  978. ast=_st(smalltalk)._parse_(src);
  979. _st(self["@analyzer"])._visit_(ast);
  980. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})},
  981. args: [],
  982. source: "testVariableShadowing\x0a\x09| src ast |\x0a\x09src := 'foo | a | a + 1'.\x0a\x09ast := smalltalk parse: src.\x0a\x09analyzer visit: ast",
  983. messageSends: ["parse:", "visit:"],
  984. referencedClasses: []
  985. }),
  986. smalltalk.SemanticAnalyzerTest);
  987. smalltalk.addMethod(
  988. "_testVariableShadowing2",
  989. smalltalk.method({
  990. selector: "testVariableShadowing2",
  991. category: 'tests',
  992. fn: function (){
  993. var self=this;
  994. var src,ast;
  995. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ | a | a := 2 ]";
  996. ast=_st(smalltalk)._parse_(src);
  997. _st(self)._should_raise_((function(){
  998. return smalltalk.withContext(function($ctx2) { return _st(self["@analyzer"])._visit_(ast);
  999. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.ShadowingVariableError || ShadowingVariableError));
  1000. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing2",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})},
  1001. args: [],
  1002. source: "testVariableShadowing2\x0a\x09| src ast |\x0a\x09src := 'foo | a | a + 1. [ | a | a := 2 ]'.\x0a\x09ast := smalltalk parse: src.\x0a\x09self should: [analyzer visit: ast] raise: ShadowingVariableError",
  1003. messageSends: ["parse:", "should:raise:", "visit:"],
  1004. referencedClasses: ["ShadowingVariableError"]
  1005. }),
  1006. smalltalk.SemanticAnalyzerTest);
  1007. smalltalk.addMethod(
  1008. "_testVariableShadowing3",
  1009. smalltalk.method({
  1010. selector: "testVariableShadowing3",
  1011. category: 'tests',
  1012. fn: function (){
  1013. var self=this;
  1014. var src,ast;
  1015. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ | b | b := 2 ]";
  1016. ast=_st(smalltalk)._parse_(src);
  1017. _st(self["@analyzer"])._visit_(ast);
  1018. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing3",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})},
  1019. args: [],
  1020. source: "testVariableShadowing3\x0a\x09| src ast |\x0a\x09src := 'foo | a | a + 1. [ | b | b := 2 ]'.\x0a\x09ast := smalltalk parse: src.\x0a\x09analyzer visit: ast",
  1021. messageSends: ["parse:", "visit:"],
  1022. referencedClasses: []
  1023. }),
  1024. smalltalk.SemanticAnalyzerTest);
  1025. smalltalk.addMethod(
  1026. "_testVariableShadowing4",
  1027. smalltalk.method({
  1028. selector: "testVariableShadowing4",
  1029. category: 'tests',
  1030. fn: function (){
  1031. var self=this;
  1032. var src,ast;
  1033. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ [ [ | b | b := 2 ] ] ]";
  1034. ast=_st(smalltalk)._parse_(src);
  1035. _st(self["@analyzer"])._visit_(ast);
  1036. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing4",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})},
  1037. args: [],
  1038. source: "testVariableShadowing4\x0a\x09| src ast |\x0a\x09src := 'foo | a | a + 1. [ [ [ | b | b := 2 ] ] ]'.\x0a\x09ast := smalltalk parse: src.\x0a\x09analyzer visit: ast",
  1039. messageSends: ["parse:", "visit:"],
  1040. referencedClasses: []
  1041. }),
  1042. smalltalk.SemanticAnalyzerTest);
  1043. smalltalk.addMethod(
  1044. "_testVariableShadowing5",
  1045. smalltalk.method({
  1046. selector: "testVariableShadowing5",
  1047. category: 'tests',
  1048. fn: function (){
  1049. var self=this;
  1050. var src,ast;
  1051. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ [ [ | a | a := 2 ] ] ]";
  1052. ast=_st(smalltalk)._parse_(src);
  1053. _st(self)._should_raise_((function(){
  1054. return smalltalk.withContext(function($ctx2) { return _st(self["@analyzer"])._visit_(ast);
  1055. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.ShadowingVariableError || ShadowingVariableError));
  1056. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing5",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})},
  1057. args: [],
  1058. source: "testVariableShadowing5\x0a\x09| src ast |\x0a\x09src := 'foo | a | a + 1. [ [ [ | a | a := 2 ] ] ]'.\x0a\x09ast := smalltalk parse: src.\x0a\x09self should: [analyzer visit: ast] raise: ShadowingVariableError",
  1059. messageSends: ["parse:", "should:raise:", "visit:"],
  1060. referencedClasses: ["ShadowingVariableError"]
  1061. }),
  1062. smalltalk.SemanticAnalyzerTest);
  1063. smalltalk.addMethod(
  1064. "_testVariablesLookup",
  1065. smalltalk.method({
  1066. selector: "testVariablesLookup",
  1067. category: 'tests',
  1068. fn: function (){
  1069. var self=this;
  1070. var src,ast;
  1071. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ | b | b := a ]";
  1072. ast=_st(smalltalk)._parse_(src);
  1073. _st(self["@analyzer"])._visit_(ast);
  1074. _st(self)._assert_(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._first())._receiver())._binding())._isTempVar());
  1075. _st(self)._assert_(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._first())._receiver())._binding())._scope()).__eq_eq(_st(ast)._scope()));
  1076. _st(self)._assert_(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._nodes())._first())._nodes())._first())._left())._binding())._isTempVar());
  1077. _st(self)._assert_(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._nodes())._first())._nodes())._first())._left())._binding())._scope()).__eq_eq(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._scope()));
  1078. return self}, function($ctx1) {$ctx1.fill(self,"testVariablesLookup",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})},
  1079. args: [],
  1080. source: "testVariablesLookup\x0a\x09| src ast |\x0a\x0a\x09src := 'foo | a | a + 1. [ | b | b := a ]'.\x0a\x09ast := smalltalk parse: src.\x0a\x09analyzer visit: ast.\x0a\x0a\x09\x22Binding for `a` in the message send\x22\x0a\x09self assert: ast nodes first nodes first receiver binding isTempVar.\x0a\x09self assert: ast nodes first nodes first receiver binding scope == ast scope.\x0a\x0a\x09\x22Binding for `b`\x22\x0a\x09self assert: ast nodes first nodes last nodes first nodes first left binding isTempVar.\x0a\x09self assert: ast nodes first nodes last nodes first nodes first left binding scope == ast nodes first nodes last scope.",
  1081. messageSends: ["parse:", "visit:", "assert:", "isTempVar", "binding", "receiver", "first", "nodes", "==", "scope", "left", "last"],
  1082. referencedClasses: []
  1083. }),
  1084. smalltalk.SemanticAnalyzerTest);