1
0

Compiler-Tests.deploy.js 42 KB

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