Compiler-Tests.deploy.js 34 KB

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