1
0

Compiler-Tests.deploy.js 35 KB

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