Compiler-Tests.deploy.js 38 KB

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