1
0

Compiler-Tests.deploy.js 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967
  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. }),
  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. }),
  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. }),
  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. }),
  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. }),
  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. }),
  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. }),
  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. }),
  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. }),
  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. }),
  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. }),
  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. }),
  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. }),
  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. }),
  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. }),
  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. }),
  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. }),
  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. }),
  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. }),
  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. }),
  242. smalltalk.ASTSteppingInterpreterTest);
  243. smalltalk.addMethod(
  244. "_testSimpleStepping",
  245. smalltalk.method({
  246. selector: "testSimpleStepping",
  247. fn: function (){
  248. var self=this;
  249. return smalltalk.withContext(function($ctx1) { _st(self)._interpret_("foo 1");
  250. _st(_st(self)._interpreter())._step();
  251. _st(self)._assert_(_st(_st(_st(self)._interpreter())._result())._isNil());
  252. _st(_st(self)._interpreter())._step();
  253. _st(self)._assert_equals_(_st(_st(self)._interpreter())._result(),(1));
  254. return self}, function($ctx1) {$ctx1.fill(self,"testSimpleStepping",{}, smalltalk.ASTSteppingInterpreterTest)})}
  255. }),
  256. smalltalk.ASTSteppingInterpreterTest);
  257. smalltalk.addClass('CodeGeneratorTest', smalltalk.TestCase, ['receiver'], 'Compiler-Tests');
  258. smalltalk.addMethod(
  259. "_codeGeneratorClass",
  260. smalltalk.method({
  261. selector: "codeGeneratorClass",
  262. fn: function (){
  263. var self=this;
  264. return smalltalk.withContext(function($ctx1) { var $1;
  265. $1=(smalltalk.CodeGenerator || CodeGenerator);
  266. return $1;
  267. }, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{}, smalltalk.CodeGeneratorTest)})}
  268. }),
  269. smalltalk.CodeGeneratorTest);
  270. smalltalk.addMethod(
  271. "_compiler",
  272. smalltalk.method({
  273. selector: "compiler",
  274. fn: function (){
  275. var self=this;
  276. return smalltalk.withContext(function($ctx1) { var $2,$3,$1;
  277. $2=_st((smalltalk.Compiler || Compiler))._new();
  278. _st($2)._codeGeneratorClass_(_st(self)._codeGeneratorClass());
  279. $3=_st($2)._yourself();
  280. $1=$3;
  281. return $1;
  282. }, function($ctx1) {$ctx1.fill(self,"compiler",{}, smalltalk.CodeGeneratorTest)})}
  283. }),
  284. smalltalk.CodeGeneratorTest);
  285. smalltalk.addMethod(
  286. "_setUp",
  287. smalltalk.method({
  288. selector: "setUp",
  289. fn: function (){
  290. var self=this;
  291. return smalltalk.withContext(function($ctx1) { self["@receiver"]=_st(_st(self)._targetClass())._new();
  292. return self}, function($ctx1) {$ctx1.fill(self,"setUp",{}, smalltalk.CodeGeneratorTest)})}
  293. }),
  294. smalltalk.CodeGeneratorTest);
  295. smalltalk.addMethod(
  296. "_should_return_",
  297. smalltalk.method({
  298. selector: "should:return:",
  299. fn: function (aString,anObject){
  300. var self=this;
  301. var method,result;
  302. return smalltalk.withContext(function($ctx1) { method=_st(_st(self)._compiler())._install_forClass_category_(aString,_st(self)._targetClass(),"tests");
  303. result=_st(self["@receiver"])._perform_(_st(method)._selector());
  304. _st(_st(self)._targetClass())._removeCompiledMethod_(method);
  305. _st(self)._assert_equals_(anObject,result);
  306. return self}, function($ctx1) {$ctx1.fill(self,"should:return:",{aString:aString,anObject:anObject,method:method,result:result}, smalltalk.CodeGeneratorTest)})}
  307. }),
  308. smalltalk.CodeGeneratorTest);
  309. smalltalk.addMethod(
  310. "_targetClass",
  311. smalltalk.method({
  312. selector: "targetClass",
  313. fn: function (){
  314. var self=this;
  315. return smalltalk.withContext(function($ctx1) { var $1;
  316. $1=(smalltalk.DoIt || DoIt);
  317. return $1;
  318. }, function($ctx1) {$ctx1.fill(self,"targetClass",{}, smalltalk.CodeGeneratorTest)})}
  319. }),
  320. smalltalk.CodeGeneratorTest);
  321. smalltalk.addMethod(
  322. "_tearDown",
  323. smalltalk.method({
  324. selector: "tearDown",
  325. fn: function (){
  326. var self=this;
  327. return smalltalk.withContext(function($ctx1) { return self}, function($ctx1) {$ctx1.fill(self,"tearDown",{}, smalltalk.CodeGeneratorTest)})}
  328. }),
  329. smalltalk.CodeGeneratorTest);
  330. smalltalk.addMethod(
  331. "_testAssignment",
  332. smalltalk.method({
  333. selector: "testAssignment",
  334. fn: function (){
  335. var self=this;
  336. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo | a | a := true ifTrue: [ 1 ]. ^ a",(1));
  337. _st(self)._should_return_("foo | a | a := false ifTrue: [ 1 ]. ^ a",nil);
  338. _st(self)._should_return_("foo | a | ^ a := true ifTrue: [ 1 ]",(1));
  339. return self}, function($ctx1) {$ctx1.fill(self,"testAssignment",{}, smalltalk.CodeGeneratorTest)})}
  340. }),
  341. smalltalk.CodeGeneratorTest);
  342. smalltalk.addMethod(
  343. "_testBlockReturn",
  344. smalltalk.method({
  345. selector: "testBlockReturn",
  346. fn: function (){
  347. var self=this;
  348. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ #(1 2 3) collect: [ :each | true ifTrue: [ each + 1 ] ]",[(2), (3), (4)]);
  349. _st(self)._should_return_("foo ^ #(1 2 3) collect: [ :each | false ifFalse: [ each + 1 ] ]",[(2), (3), (4)]);
  350. _st(self)._should_return_("foo ^ #(1 2 3) collect: [ :each | each odd ifTrue: [ each + 1 ] ifFalse: [ each - 1 ] ]",[(2), (1), (4)]);
  351. return self}, function($ctx1) {$ctx1.fill(self,"testBlockReturn",{}, smalltalk.CodeGeneratorTest)})}
  352. }),
  353. smalltalk.CodeGeneratorTest);
  354. smalltalk.addMethod(
  355. "_testCascades",
  356. smalltalk.method({
  357. selector: "testCascades",
  358. fn: function (){
  359. var self=this;
  360. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ Array new add: 3; add: 4; yourself",[(3), (4)]);
  361. return self}, function($ctx1) {$ctx1.fill(self,"testCascades",{}, smalltalk.CodeGeneratorTest)})}
  362. }),
  363. smalltalk.CodeGeneratorTest);
  364. smalltalk.addMethod(
  365. "_testDynamicArrayElementsOrdered",
  366. smalltalk.method({
  367. selector: "testDynamicArrayElementsOrdered",
  368. fn: function (){
  369. var self=this;
  370. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo\x0a | x |\x0a x := 1.\x0a ^ { x. true ifTrue: [ x := 2 ] }\x0a",[(1), (2)]);
  371. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicArrayElementsOrdered",{}, smalltalk.CodeGeneratorTest)})}
  372. }),
  373. smalltalk.CodeGeneratorTest);
  374. smalltalk.addMethod(
  375. "_testDynamicDictionaryElementsOrdered",
  376. smalltalk.method({
  377. selector: "testDynamicDictionaryElementsOrdered",
  378. fn: function (){
  379. var self=this;
  380. 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))]));
  381. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicDictionaryElementsOrdered",{}, smalltalk.CodeGeneratorTest)})}
  382. }),
  383. smalltalk.CodeGeneratorTest);
  384. smalltalk.addMethod(
  385. "_testInnerTemporalDependentElementsOrdered",
  386. smalltalk.method({
  387. selector: "testInnerTemporalDependentElementsOrdered",
  388. fn: function (){
  389. var self=this;
  390. 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))]);
  391. _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))]);
  392. _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))]);
  393. _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))]));
  394. return self}, function($ctx1) {$ctx1.fill(self,"testInnerTemporalDependentElementsOrdered",{}, smalltalk.CodeGeneratorTest)})}
  395. }),
  396. smalltalk.CodeGeneratorTest);
  397. smalltalk.addMethod(
  398. "_testLiterals",
  399. smalltalk.method({
  400. selector: "testLiterals",
  401. fn: function (){
  402. var self=this;
  403. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ 1",(1));
  404. _st(self)._should_return_("foo ^ 'hello'","hello");
  405. _st(self)._should_return_("foo ^ #(1 2 3 4)",[(1), (2), (3), (4)]);
  406. _st(self)._should_return_("foo ^ {1. [:x | x ] value: 2. 3. [4] value}",[(1), (2), (3), (4)]);
  407. _st(self)._should_return_("foo ^ true",true);
  408. _st(self)._should_return_("foo ^ false",false);
  409. _st(self)._should_return_("foo ^ #{1->2. 3->4}",smalltalk.HashedCollection._fromPairs_([_st((1)).__minus_gt((2)),_st((3)).__minus_gt((4))]));
  410. _st(self)._should_return_("foo ^ #hello",smalltalk.symbolFor("hello"));
  411. _st(self)._should_return_("foo ^ -123.456",(-123.456));
  412. return self}, function($ctx1) {$ctx1.fill(self,"testLiterals",{}, smalltalk.CodeGeneratorTest)})}
  413. }),
  414. smalltalk.CodeGeneratorTest);
  415. smalltalk.addMethod(
  416. "_testLocalReturn",
  417. smalltalk.method({
  418. selector: "testLocalReturn",
  419. fn: function (){
  420. var self=this;
  421. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ 1",(1));
  422. _st(self)._should_return_("foo ^ 1 + 1",(2));
  423. _st(self)._should_return_("foo ",self["@receiver"]);
  424. _st(self)._should_return_("foo self asString",self["@receiver"]);
  425. _st(self)._should_return_("foo | a b | a := 1. b := 2. ^ a + b",(3));
  426. return self}, function($ctx1) {$ctx1.fill(self,"testLocalReturn",{}, smalltalk.CodeGeneratorTest)})}
  427. }),
  428. smalltalk.CodeGeneratorTest);
  429. smalltalk.addMethod(
  430. "_testMessageSends",
  431. smalltalk.method({
  432. selector: "testMessageSends",
  433. fn: function (){
  434. var self=this;
  435. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ 1 asString","1");
  436. _st(self)._should_return_("foo ^ 1 + 1",(2));
  437. _st(self)._should_return_("foo ^ 1 + 2 * 3",(9));
  438. _st(self)._should_return_("foo ^ 1 to: 3",[(1), (2), (3)]);
  439. _st(self)._should_return_("foo ^ 1 to: 5 by: 2",[(1), (3), (5)]);
  440. return self}, function($ctx1) {$ctx1.fill(self,"testMessageSends",{}, smalltalk.CodeGeneratorTest)})}
  441. }),
  442. smalltalk.CodeGeneratorTest);
  443. smalltalk.addMethod(
  444. "_testNestedIfTrue",
  445. smalltalk.method({
  446. selector: "testNestedIfTrue",
  447. fn: function (){
  448. var self=this;
  449. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ true ifTrue: [ false ifFalse: [ 1 ] ]",(1));
  450. _st(self)._should_return_("foo ^ true ifTrue: [ false ifTrue: [ 1 ] ]",nil);
  451. _st(self)._should_return_("foo true ifTrue: [ false ifFalse: [ ^ 1 ] ]",(1));
  452. _st(self)._should_return_("foo true ifTrue: [ false ifTrue: [ ^ 1 ] ]",self["@receiver"]);
  453. return self}, function($ctx1) {$ctx1.fill(self,"testNestedIfTrue",{}, smalltalk.CodeGeneratorTest)})}
  454. }),
  455. smalltalk.CodeGeneratorTest);
  456. smalltalk.addMethod(
  457. "_testNonLocalReturn",
  458. smalltalk.method({
  459. selector: "testNonLocalReturn",
  460. fn: function (){
  461. var self=this;
  462. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo [ ^ 1 ] value",(1));
  463. _st(self)._should_return_("foo [ ^ 1 + 1 ] value",(2));
  464. _st(self)._should_return_("foo | a b | a := 1. b := 2. [ ^ a + b ] value. self halt",(3));
  465. _st(self)._should_return_("foo [ :x | ^ x + x ] value: 4. ^ 2",(8));
  466. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn",{}, smalltalk.CodeGeneratorTest)})}
  467. }),
  468. smalltalk.CodeGeneratorTest);
  469. smalltalk.addMethod(
  470. "_testSendReceiverAndArgumentsOrdered",
  471. smalltalk.method({
  472. selector: "testSendReceiverAndArgumentsOrdered",
  473. fn: function (){
  474. var self=this;
  475. 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)]);
  476. _st(self)._should_return_("foo\x0a | x |\x0a x := Array.\x0a ^ x with: x with: (true ifTrue: [ x := 2 ])\x0a",[(smalltalk.Array || Array),(2)]);
  477. return self}, function($ctx1) {$ctx1.fill(self,"testSendReceiverAndArgumentsOrdered",{}, smalltalk.CodeGeneratorTest)})}
  478. }),
  479. smalltalk.CodeGeneratorTest);
  480. smalltalk.addMethod(
  481. "_testifFalse",
  482. smalltalk.method({
  483. selector: "testifFalse",
  484. fn: function (){
  485. var self=this;
  486. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo true ifFalse: [ ^ 1 ]",self["@receiver"]);
  487. _st(self)._should_return_("foo false ifFalse: [ ^ 2 ]",(2));
  488. _st(self)._should_return_("foo ^ true ifFalse: [ 1 ]",nil);
  489. _st(self)._should_return_("foo ^ false ifFalse: [ 2 ]",(2));
  490. return self}, function($ctx1) {$ctx1.fill(self,"testifFalse",{}, smalltalk.CodeGeneratorTest)})}
  491. }),
  492. smalltalk.CodeGeneratorTest);
  493. smalltalk.addMethod(
  494. "_testifFalseIfTrue",
  495. smalltalk.method({
  496. selector: "testifFalseIfTrue",
  497. fn: function (){
  498. var self=this;
  499. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo true ifFalse: [ ^ 1 ] ifTrue: [ ^ 2 ]",(2));
  500. _st(self)._should_return_("foo false ifFalse: [ ^ 2 ] ifTrue: [ ^1 ]",(2));
  501. _st(self)._should_return_("foo ^ true ifFalse: [ 1 ] ifTrue: [ 2 ]",(2));
  502. _st(self)._should_return_("foo ^ false ifFalse: [ 2 ] ifTrue: [ 1 ]",(2));
  503. return self}, function($ctx1) {$ctx1.fill(self,"testifFalseIfTrue",{}, smalltalk.CodeGeneratorTest)})}
  504. }),
  505. smalltalk.CodeGeneratorTest);
  506. smalltalk.addMethod(
  507. "_testifNil",
  508. smalltalk.method({
  509. selector: "testifNil",
  510. fn: function (){
  511. var self=this;
  512. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ 1 ifNil: [ 2 ]",(1));
  513. _st(self)._should_return_("foo ^ nil ifNil: [ 2 ]",(2));
  514. _st(self)._should_return_("foo 1 ifNil: [ ^ 2 ]",self["@receiver"]);
  515. _st(self)._should_return_("foo nil ifNil: [ ^ 2 ]",(2));
  516. return self}, function($ctx1) {$ctx1.fill(self,"testifNil",{}, smalltalk.CodeGeneratorTest)})}
  517. }),
  518. smalltalk.CodeGeneratorTest);
  519. smalltalk.addMethod(
  520. "_testifNilIfNotNil",
  521. smalltalk.method({
  522. selector: "testifNilIfNotNil",
  523. fn: function (){
  524. var self=this;
  525. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ 1 ifNil: [ 2 ] ifNotNil: [ 3 ]",(3));
  526. _st(self)._should_return_("foo ^ nil ifNil: [ 2 ] ifNotNil: [ 3 ]",(2));
  527. _st(self)._should_return_("foo 1 ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]",(3));
  528. _st(self)._should_return_("foo nil ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]",(2));
  529. return self}, function($ctx1) {$ctx1.fill(self,"testifNilIfNotNil",{}, smalltalk.CodeGeneratorTest)})}
  530. }),
  531. smalltalk.CodeGeneratorTest);
  532. smalltalk.addMethod(
  533. "_testifNotNil",
  534. smalltalk.method({
  535. selector: "testifNotNil",
  536. fn: function (){
  537. var self=this;
  538. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ 1 ifNotNil: [ 2 ]",(2));
  539. _st(self)._should_return_("foo ^ nil ifNotNil: [ 2 ]",nil);
  540. _st(self)._should_return_("foo 1 ifNotNil: [ ^ 2 ]",(2));
  541. _st(self)._should_return_("foo nil ifNotNil: [ ^ 2 ]",self["@receiver"]);
  542. return self}, function($ctx1) {$ctx1.fill(self,"testifNotNil",{}, smalltalk.CodeGeneratorTest)})}
  543. }),
  544. smalltalk.CodeGeneratorTest);
  545. smalltalk.addMethod(
  546. "_testifTrue",
  547. smalltalk.method({
  548. selector: "testifTrue",
  549. fn: function (){
  550. var self=this;
  551. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo false ifTrue: [ ^ 1 ]",self["@receiver"]);
  552. _st(self)._should_return_("foo true ifTrue: [ ^ 2 ]",(2));
  553. _st(self)._should_return_("foo ^ false ifTrue: [ 1 ]",nil);
  554. _st(self)._should_return_("foo ^ true ifTrue: [ 2 ]",(2));
  555. return self}, function($ctx1) {$ctx1.fill(self,"testifTrue",{}, smalltalk.CodeGeneratorTest)})}
  556. }),
  557. smalltalk.CodeGeneratorTest);
  558. smalltalk.addMethod(
  559. "_testifTrueIfFalse",
  560. smalltalk.method({
  561. selector: "testifTrueIfFalse",
  562. fn: function (){
  563. var self=this;
  564. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo false ifTrue: [ ^ 1 ] ifFalse: [ ^2 ]",(2));
  565. _st(self)._should_return_("foo true ifTrue: [ ^ 1 ] ifFalse: [ ^ 2 ]",(1));
  566. _st(self)._should_return_("foo ^ false ifTrue: [ 2 ] ifFalse: [ 1 ]",(1));
  567. _st(self)._should_return_("foo ^ true ifTrue: [ 2 ] ifFalse: [ 1 ]",(2));
  568. return self}, function($ctx1) {$ctx1.fill(self,"testifTrueIfFalse",{}, smalltalk.CodeGeneratorTest)})}
  569. }),
  570. smalltalk.CodeGeneratorTest);
  571. smalltalk.addClass('InliningCodeGeneratorTest', smalltalk.CodeGeneratorTest, [], 'Compiler-Tests');
  572. smalltalk.addMethod(
  573. "_codeGeneratorClass",
  574. smalltalk.method({
  575. selector: "codeGeneratorClass",
  576. fn: function (){
  577. var self=this;
  578. return smalltalk.withContext(function($ctx1) { var $1;
  579. $1=(smalltalk.InliningCodeGenerator || InliningCodeGenerator);
  580. return $1;
  581. }, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{}, smalltalk.InliningCodeGeneratorTest)})}
  582. }),
  583. smalltalk.InliningCodeGeneratorTest);
  584. smalltalk.addClass('ScopeVarTest', smalltalk.TestCase, [], 'Compiler-Tests');
  585. smalltalk.addMethod(
  586. "_testClassRefVar",
  587. smalltalk.method({
  588. selector: "testClassRefVar",
  589. fn: function (){
  590. var self=this;
  591. var node;
  592. return smalltalk.withContext(function($ctx1) { var $1,$2;
  593. $1=_st((smalltalk.ClassReferenceNode || ClassReferenceNode))._new();
  594. _st($1)._value_("Object");
  595. $2=_st($1)._yourself();
  596. node=$2;
  597. _st(_st((smalltalk.SemanticAnalyzer || SemanticAnalyzer))._new())._visit_(node);
  598. _st(self)._assert_(_st(_st(node)._binding())._isClassRefVar());
  599. return self}, function($ctx1) {$ctx1.fill(self,"testClassRefVar",{node:node}, smalltalk.ScopeVarTest)})}
  600. }),
  601. smalltalk.ScopeVarTest);
  602. smalltalk.addMethod(
  603. "_testInstanceVar",
  604. smalltalk.method({
  605. selector: "testInstanceVar",
  606. fn: function (){
  607. var self=this;
  608. var node,scope;
  609. return smalltalk.withContext(function($ctx1) { var $1,$2;
  610. $1=_st((smalltalk.VariableNode || VariableNode))._new();
  611. _st($1)._value_("bzzz");
  612. $2=_st($1)._yourself();
  613. node=$2;
  614. scope=_st((smalltalk.MethodLexicalScope || MethodLexicalScope))._new();
  615. _st(scope)._addIVar_("bzzz");
  616. _st(self)._assert_(_st(_st(scope)._bindingFor_(node))._isInstanceVar());
  617. return self}, function($ctx1) {$ctx1.fill(self,"testInstanceVar",{node:node,scope:scope}, smalltalk.ScopeVarTest)})}
  618. }),
  619. smalltalk.ScopeVarTest);
  620. smalltalk.addMethod(
  621. "_testPseudoVar",
  622. smalltalk.method({
  623. selector: "testPseudoVar",
  624. fn: function (){
  625. var self=this;
  626. var node,pseudoVars;
  627. return smalltalk.withContext(function($ctx1) { var $1,$2;
  628. pseudoVars=["self", "super", "true", "false", "nil"];
  629. _st(pseudoVars)._do_((function(each){
  630. return smalltalk.withContext(function($ctx2) { $1=_st((smalltalk.VariableNode || VariableNode))._new();
  631. _st($1)._value_(each);
  632. $2=_st($1)._yourself();
  633. node=$2;
  634. node;
  635. return _st(self)._assert_(_st(_st(_st((smalltalk.MethodLexicalScope || MethodLexicalScope))._new())._bindingFor_(node))._isPseudoVar());
  636. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  637. return self}, function($ctx1) {$ctx1.fill(self,"testPseudoVar",{node:node,pseudoVars:pseudoVars}, smalltalk.ScopeVarTest)})}
  638. }),
  639. smalltalk.ScopeVarTest);
  640. smalltalk.addMethod(
  641. "_testTempVar",
  642. smalltalk.method({
  643. selector: "testTempVar",
  644. fn: function (){
  645. var self=this;
  646. var node,scope;
  647. return smalltalk.withContext(function($ctx1) { var $1,$2;
  648. $1=_st((smalltalk.VariableNode || VariableNode))._new();
  649. _st($1)._value_("bzzz");
  650. $2=_st($1)._yourself();
  651. node=$2;
  652. scope=_st((smalltalk.MethodLexicalScope || MethodLexicalScope))._new();
  653. _st(scope)._addTemp_("bzzz");
  654. _st(self)._assert_(_st(_st(scope)._bindingFor_(node))._isTempVar());
  655. return self}, function($ctx1) {$ctx1.fill(self,"testTempVar",{node:node,scope:scope}, smalltalk.ScopeVarTest)})}
  656. }),
  657. smalltalk.ScopeVarTest);
  658. smalltalk.addMethod(
  659. "_testUnknownVar",
  660. smalltalk.method({
  661. selector: "testUnknownVar",
  662. fn: function (){
  663. var self=this;
  664. var node;
  665. return smalltalk.withContext(function($ctx1) { var $1,$2;
  666. $1=_st((smalltalk.VariableNode || VariableNode))._new();
  667. _st($1)._value_("bzzz");
  668. $2=_st($1)._yourself();
  669. node=$2;
  670. _st(self)._assert_(_st(_st(_st((smalltalk.MethodLexicalScope || MethodLexicalScope))._new())._bindingFor_(node))._isNil());
  671. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVar",{node:node}, smalltalk.ScopeVarTest)})}
  672. }),
  673. smalltalk.ScopeVarTest);
  674. smalltalk.addClass('SemanticAnalyzerTest', smalltalk.TestCase, ['analyzer'], 'Compiler-Tests');
  675. smalltalk.addMethod(
  676. "_setUp",
  677. smalltalk.method({
  678. selector: "setUp",
  679. fn: function (){
  680. var self=this;
  681. return smalltalk.withContext(function($ctx1) { self["@analyzer"]=_st((smalltalk.SemanticAnalyzer || SemanticAnalyzer))._on_((smalltalk.Object || Object));
  682. return self}, function($ctx1) {$ctx1.fill(self,"setUp",{}, smalltalk.SemanticAnalyzerTest)})}
  683. }),
  684. smalltalk.SemanticAnalyzerTest);
  685. smalltalk.addMethod(
  686. "_testAssignment",
  687. smalltalk.method({
  688. selector: "testAssignment",
  689. fn: function (){
  690. var self=this;
  691. var src,ast;
  692. return smalltalk.withContext(function($ctx1) { src="foo self := 1";
  693. ast=_st(smalltalk)._parse_(src);
  694. _st(self)._should_raise_((function(){
  695. return smalltalk.withContext(function($ctx2) { return _st(self["@analyzer"])._visit_(ast);
  696. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.InvalidAssignmentError || InvalidAssignmentError));
  697. return self}, function($ctx1) {$ctx1.fill(self,"testAssignment",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})}
  698. }),
  699. smalltalk.SemanticAnalyzerTest);
  700. smalltalk.addMethod(
  701. "_testNonLocalReturn",
  702. smalltalk.method({
  703. selector: "testNonLocalReturn",
  704. fn: function (){
  705. var self=this;
  706. var src,ast;
  707. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. ^ a";
  708. ast=_st(smalltalk)._parse_(src);
  709. _st(self["@analyzer"])._visit_(ast);
  710. _st(self)._deny_(_st(_st(ast)._scope())._hasNonLocalReturn());
  711. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})}
  712. }),
  713. smalltalk.SemanticAnalyzerTest);
  714. smalltalk.addMethod(
  715. "_testNonLocalReturn2",
  716. smalltalk.method({
  717. selector: "testNonLocalReturn2",
  718. fn: function (){
  719. var self=this;
  720. var src,ast;
  721. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ [ ^ a] ]";
  722. ast=_st(smalltalk)._parse_(src);
  723. _st(self["@analyzer"])._visit_(ast);
  724. _st(self)._assert_(_st(_st(ast)._scope())._hasNonLocalReturn());
  725. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn2",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})}
  726. }),
  727. smalltalk.SemanticAnalyzerTest);
  728. smalltalk.addMethod(
  729. "_testScope",
  730. smalltalk.method({
  731. selector: "testScope",
  732. fn: function (){
  733. var self=this;
  734. var src,ast;
  735. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ | b | b := a ]";
  736. ast=_st(smalltalk)._parse_(src);
  737. _st(self["@analyzer"])._visit_(ast);
  738. _st(self)._deny_(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._scope()).__eq_eq(_st(ast)._scope()));
  739. return self}, function($ctx1) {$ctx1.fill(self,"testScope",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})}
  740. }),
  741. smalltalk.SemanticAnalyzerTest);
  742. smalltalk.addMethod(
  743. "_testScope2",
  744. smalltalk.method({
  745. selector: "testScope2",
  746. fn: function (){
  747. var self=this;
  748. var src,ast;
  749. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ [ | b | b := a ] ]";
  750. ast=_st(smalltalk)._parse_(src);
  751. _st(self["@analyzer"])._visit_(ast);
  752. _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()));
  753. return self}, function($ctx1) {$ctx1.fill(self,"testScope2",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})}
  754. }),
  755. smalltalk.SemanticAnalyzerTest);
  756. smalltalk.addMethod(
  757. "_testScopeLevel",
  758. smalltalk.method({
  759. selector: "testScopeLevel",
  760. fn: function (){
  761. var self=this;
  762. var src,ast;
  763. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ [ | b | b := a ] ]";
  764. ast=_st(smalltalk)._parse_(src);
  765. _st(self["@analyzer"])._visit_(ast);
  766. _st(self)._assert_(_st(_st(_st(ast)._scope())._scopeLevel()).__eq((1)));
  767. _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)));
  768. return self}, function($ctx1) {$ctx1.fill(self,"testScopeLevel",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})}
  769. }),
  770. smalltalk.SemanticAnalyzerTest);
  771. smalltalk.addMethod(
  772. "_testUnknownVariables",
  773. smalltalk.method({
  774. selector: "testUnknownVariables",
  775. fn: function (){
  776. var self=this;
  777. var src,ast;
  778. return smalltalk.withContext(function($ctx1) { src="foo | a | b + a";
  779. ast=_st(smalltalk)._parse_(src);
  780. _st(self)._should_raise_((function(){
  781. return smalltalk.withContext(function($ctx2) { return _st(self["@analyzer"])._visit_(ast);
  782. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.UnknownVariableError || UnknownVariableError));
  783. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVariables",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})}
  784. }),
  785. smalltalk.SemanticAnalyzerTest);
  786. smalltalk.addMethod(
  787. "_testUnknownVariablesWithScope",
  788. smalltalk.method({
  789. selector: "testUnknownVariablesWithScope",
  790. fn: function (){
  791. var self=this;
  792. var src,ast;
  793. return smalltalk.withContext(function($ctx1) { src="foo | a b | [ c + 1. [ a + 1. d + 1 ]]";
  794. ast=_st(smalltalk)._parse_(src);
  795. _st(self)._should_raise_((function(){
  796. return smalltalk.withContext(function($ctx2) { return _st(self["@analyzer"])._visit_(ast);
  797. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.UnknownVariableError || UnknownVariableError));
  798. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVariablesWithScope",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})}
  799. }),
  800. smalltalk.SemanticAnalyzerTest);
  801. smalltalk.addMethod(
  802. "_testVariableShadowing",
  803. smalltalk.method({
  804. selector: "testVariableShadowing",
  805. fn: function (){
  806. var self=this;
  807. var src,ast;
  808. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1";
  809. ast=_st(smalltalk)._parse_(src);
  810. _st(self["@analyzer"])._visit_(ast);
  811. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})}
  812. }),
  813. smalltalk.SemanticAnalyzerTest);
  814. smalltalk.addMethod(
  815. "_testVariableShadowing2",
  816. smalltalk.method({
  817. selector: "testVariableShadowing2",
  818. fn: function (){
  819. var self=this;
  820. var src,ast;
  821. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ | a | a := 2 ]";
  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.ShadowingVariableError || ShadowingVariableError));
  826. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing2",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})}
  827. }),
  828. smalltalk.SemanticAnalyzerTest);
  829. smalltalk.addMethod(
  830. "_testVariableShadowing3",
  831. smalltalk.method({
  832. selector: "testVariableShadowing3",
  833. fn: function (){
  834. var self=this;
  835. var src,ast;
  836. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ | b | b := 2 ]";
  837. ast=_st(smalltalk)._parse_(src);
  838. _st(self["@analyzer"])._visit_(ast);
  839. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing3",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})}
  840. }),
  841. smalltalk.SemanticAnalyzerTest);
  842. smalltalk.addMethod(
  843. "_testVariableShadowing4",
  844. smalltalk.method({
  845. selector: "testVariableShadowing4",
  846. fn: function (){
  847. var self=this;
  848. var src,ast;
  849. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ [ [ | b | b := 2 ] ] ]";
  850. ast=_st(smalltalk)._parse_(src);
  851. _st(self["@analyzer"])._visit_(ast);
  852. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing4",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})}
  853. }),
  854. smalltalk.SemanticAnalyzerTest);
  855. smalltalk.addMethod(
  856. "_testVariableShadowing5",
  857. smalltalk.method({
  858. selector: "testVariableShadowing5",
  859. fn: function (){
  860. var self=this;
  861. var src,ast;
  862. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ [ [ | a | a := 2 ] ] ]";
  863. ast=_st(smalltalk)._parse_(src);
  864. _st(self)._should_raise_((function(){
  865. return smalltalk.withContext(function($ctx2) { return _st(self["@analyzer"])._visit_(ast);
  866. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.ShadowingVariableError || ShadowingVariableError));
  867. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing5",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})}
  868. }),
  869. smalltalk.SemanticAnalyzerTest);
  870. smalltalk.addMethod(
  871. "_testVariablesLookup",
  872. smalltalk.method({
  873. selector: "testVariablesLookup",
  874. fn: function (){
  875. var self=this;
  876. var src,ast;
  877. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ | b | b := a ]";
  878. ast=_st(smalltalk)._parse_(src);
  879. _st(self["@analyzer"])._visit_(ast);
  880. _st(self)._assert_(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._first())._receiver())._binding())._isTempVar());
  881. _st(self)._assert_(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._first())._receiver())._binding())._scope()).__eq_eq(_st(ast)._scope()));
  882. _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());
  883. _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()));
  884. return self}, function($ctx1) {$ctx1.fill(self,"testVariablesLookup",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})}
  885. }),
  886. smalltalk.SemanticAnalyzerTest);