Trapped-Tests.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. smalltalk.addPackage('Trapped-Tests', {});
  2. smalltalk.addClass('IsolatorTest', smalltalk.TestCase, ['rootModel'], 'Trapped-Tests');
  3. smalltalk.addMethod(
  4. "_setUp",
  5. smalltalk.method({
  6. selector: "setUp",
  7. category: 'running',
  8. fn: function (){
  9. var self=this;
  10. var $1,$2;
  11. $1=smalltalk.send((smalltalk.EavModel || EavModel),"_new",[]);
  12. smalltalk.send($1,"_getBlock_",[(function(x){
  13. return smalltalk.send(x,"_root",[]);
  14. })]);
  15. $2=smalltalk.send($1,"_putBlock_",[(function(x,y){
  16. return smalltalk.send(x,"_root_",[y]);
  17. })]);
  18. self["@rootModel"]=$2;
  19. return self},
  20. args: [],
  21. source: "setUp\x0a\x0arootModel := EavModel new\x0a\x09getBlock: [:x | x root];\x0a putBlock: [:x :y | x root: y].\x0a",
  22. messageSends: ["getBlock:", "root", "new", "putBlock:", "root:"],
  23. referencedClasses: ["EavModel"]
  24. }),
  25. smalltalk.IsolatorTest);
  26. smalltalk.addMethod(
  27. "_testNontrivialModelGetsAppropriateValueForModification",
  28. smalltalk.method({
  29. selector: "testNontrivialModelGetsAppropriateValueForModification",
  30. category: 'tests',
  31. fn: function (){
  32. var self=this;
  33. var $1,$2;
  34. var isolator;
  35. var model;
  36. var result;
  37. result=nil;
  38. isolator=smalltalk.send((smalltalk.Isolator || Isolator),"_on_",[smalltalk.HashedCollection._fromPairs_([smalltalk.send("foo","__minus_gt",[["bar", [(1), [(2), (5)]], "baz"]]),smalltalk.send("moo","__minus_gt",["zoo"])])]);
  39. $1=smalltalk.send((smalltalk.EavModel || EavModel),"_new",[]);
  40. smalltalk.send($1,"_getBlock_",[(function(x){
  41. return smalltalk.send(smalltalk.send(smalltalk.send(x,"_root",[]),"_at_",["foo"]),"_at_",[(2)]);
  42. })]);
  43. $2=smalltalk.send($1,"_putBlock_",[(function(x,y){
  44. return smalltalk.send(smalltalk.send(smalltalk.send(x,"_root",[]),"_at_",["foo"]),"_at_put_",[(2),y]);
  45. })]);
  46. model=$2;
  47. smalltalk.send(isolator,"_model_modify_",[model,(function(r){
  48. result=r;
  49. return result;
  50. })]);
  51. smalltalk.send(self,"_assert_equals_",[[(1), [(2), (5)]],result]);
  52. return self},
  53. args: [],
  54. source: "testNontrivialModelGetsAppropriateValueForModification\x0a| isolator model result |\x0aresult := nil.\x0aisolator := Isolator on: #{ 'foo' -> #('bar' #(1 #(2 5)) 'baz'). 'moo' -> 'zoo' }.\x0amodel := EavModel new\x0a\x09getBlock: [ :x | (x root at: 'foo') at: 2 ];\x0a\x09putBlock: [ :x :y | (x root at: 'foo') at: 2 put: y].\x0aisolator model: model modify: [:r|result := r].\x0aself assert: #(1 #(2 5)) equals: result\x0a",
  55. messageSends: ["on:", "->", "getBlock:", "at:", "root", "new", "putBlock:", "at:put:", "model:modify:", "assert:equals:"],
  56. referencedClasses: ["Isolator", "EavModel"]
  57. }),
  58. smalltalk.IsolatorTest);
  59. smalltalk.addMethod(
  60. "_testNontrivialModelModifiesAppropriateValue",
  61. smalltalk.method({
  62. selector: "testNontrivialModelModifiesAppropriateValue",
  63. category: 'tests',
  64. fn: function (){
  65. var self=this;
  66. var $1,$2;
  67. var isolator;
  68. var model;
  69. var result;
  70. result=nil;
  71. isolator=smalltalk.send((smalltalk.Isolator || Isolator),"_on_",[smalltalk.HashedCollection._fromPairs_([smalltalk.send("foo","__minus_gt",[["bar", [(1), [(2), (3)]], "baz"]]),smalltalk.send("moo","__minus_gt",["zoo"])])]);
  72. $1=smalltalk.send((smalltalk.EavModel || EavModel),"_new",[]);
  73. smalltalk.send($1,"_getBlock_",[(function(x){
  74. return smalltalk.send(smalltalk.send(smalltalk.send(x,"_root",[]),"_at_",["foo"]),"_at_",[(2)]);
  75. })]);
  76. $2=smalltalk.send($1,"_putBlock_",[(function(x,y){
  77. return smalltalk.send(smalltalk.send(smalltalk.send(x,"_root",[]),"_at_",["foo"]),"_at_put_",[(2),y]);
  78. })]);
  79. model=$2;
  80. smalltalk.send(isolator,"_model_modify_",[model,(function(r){
  81. return smalltalk.symbolFor("new");
  82. })]);
  83. smalltalk.send(isolator,"_model_read_",[model,(function(r){
  84. result=r;
  85. return result;
  86. })]);
  87. smalltalk.send(self,"_assert_equals_",[smalltalk.symbolFor("new"),result]);
  88. smalltalk.send(isolator,"_model_read_",[self["@rootModel"],(function(r){
  89. result=r;
  90. return result;
  91. })]);
  92. smalltalk.send(self,"_assert_equals_",[smalltalk.HashedCollection._fromPairs_([smalltalk.send("foo","__minus_gt",[["bar", smalltalk.symbolFor("new"), "baz"]]),smalltalk.send("moo","__minus_gt",["zoo"])]),result]);
  93. return self},
  94. args: [],
  95. source: "testNontrivialModelModifiesAppropriateValue\x0a| isolator model result |\x0aresult := nil.\x0aisolator := Isolator on: #{ 'foo' -> #('bar' #(1 #(2 3)) 'baz'). 'moo' -> 'zoo' }.\x0amodel := EavModel new\x0a\x09getBlock: [ :x | (x root at: 'foo') at: 2 ];\x0a\x09putBlock: [ :x :y | (x root at: 'foo') at: 2 put: y].\x0aisolator model: model modify: [:r|#new].\x0aisolator model: model read: [:r|result := r].\x0aself assert: #new equals: result.\x0aisolator model: rootModel read: [:r|result := r].\x0aself assert: #{ 'foo' -> #('bar' #new 'baz'). 'moo' -> 'zoo' } equals: result\x0a",
  96. messageSends: ["on:", "->", "getBlock:", "at:", "root", "new", "putBlock:", "at:put:", "model:modify:", "model:read:", "assert:equals:"],
  97. referencedClasses: ["Isolator", "EavModel"]
  98. }),
  99. smalltalk.IsolatorTest);
  100. smalltalk.addMethod(
  101. "_testNontrivialModelReturnsAppropriateValue",
  102. smalltalk.method({
  103. selector: "testNontrivialModelReturnsAppropriateValue",
  104. category: 'tests',
  105. fn: function (){
  106. var self=this;
  107. var isolator;
  108. var model;
  109. var result;
  110. result=nil;
  111. isolator=smalltalk.send((smalltalk.Isolator || Isolator),"_on_",[smalltalk.HashedCollection._fromPairs_([smalltalk.send("foo","__minus_gt",[["bar", [(1), [(2), (3)]], "baz"]]),smalltalk.send("moo","__minus_gt",["zoo"])])]);
  112. model=smalltalk.send(smalltalk.send((smalltalk.EavModel || EavModel),"_new",[]),"_getBlock_",[(function(x){
  113. return smalltalk.send(smalltalk.send(smalltalk.send(x,"_root",[]),"_at_",["foo"]),"_at_",[(2)]);
  114. })]);
  115. smalltalk.send(isolator,"_model_read_",[model,(function(r){
  116. result=r;
  117. return result;
  118. })]);
  119. smalltalk.send(self,"_assert_equals_",[[(1), [(2), (3)]],result]);
  120. return self},
  121. args: [],
  122. source: "testNontrivialModelReturnsAppropriateValue\x0a| isolator model result |\x0aresult := nil.\x0aisolator := Isolator on: #{ 'foo' -> #('bar' #(1 #(2 3)) 'baz'). 'moo' -> 'zoo' }.\x0amodel := EavModel new getBlock: [ :x | (x root at: 'foo') at: 2 ].\x0aisolator model: model read: [:r|result := r].\x0aself assert: #(1 #(2 3)) equals: result\x0a",
  123. messageSends: ["on:", "->", "getBlock:", "at:", "root", "new", "model:read:", "assert:equals:"],
  124. referencedClasses: ["Isolator", "EavModel"]
  125. }),
  126. smalltalk.IsolatorTest);
  127. smalltalk.addMethod(
  128. "_testRootModelExaminesThenModifiesRoot",
  129. smalltalk.method({
  130. selector: "testRootModelExaminesThenModifiesRoot",
  131. category: 'tests',
  132. fn: function (){
  133. var self=this;
  134. var isolator;
  135. var result;
  136. result=nil;
  137. isolator=smalltalk.send((smalltalk.Isolator || Isolator),"_on_",[[(1), [(2), (3)]]]);
  138. smalltalk.send(isolator,"_model_modify_",[self["@rootModel"],(function(r){
  139. return smalltalk.send(r,"_second",[]);
  140. })]);
  141. smalltalk.send(isolator,"_model_read_",[self["@rootModel"],(function(r){
  142. result=r;
  143. return result;
  144. })]);
  145. smalltalk.send(self,"_assert_equals_",[[(2), (3)],result]);
  146. return self},
  147. args: [],
  148. source: "testRootModelExaminesThenModifiesRoot\x0a| isolator result |\x0aresult := nil.\x0aisolator := Isolator on: #(1 #(2 3)).\x0aisolator model: rootModel modify: [:r|r second].\x0aisolator model: rootModel read: [:r|result := r].\x0aself assert: #(2 3) equals: result\x0a",
  149. messageSends: ["on:", "model:modify:", "second", "model:read:", "assert:equals:"],
  150. referencedClasses: ["Isolator"]
  151. }),
  152. smalltalk.IsolatorTest);
  153. smalltalk.addMethod(
  154. "_testRootModelGetsRootForModification",
  155. smalltalk.method({
  156. selector: "testRootModelGetsRootForModification",
  157. category: 'tests',
  158. fn: function (){
  159. var self=this;
  160. var isolator;
  161. var result;
  162. result=nil;
  163. isolator=smalltalk.send((smalltalk.Isolator || Isolator),"_on_",[[(2), [(1), (0)]]]);
  164. smalltalk.send(isolator,"_model_modify_",[self["@rootModel"],(function(r){
  165. result=r;
  166. return result;
  167. })]);
  168. smalltalk.send(self,"_assert_equals_",[[(2), [(1), (0)]],result]);
  169. return self},
  170. args: [],
  171. source: "testRootModelGetsRootForModification\x0a| isolator result |\x0aresult := nil.\x0aisolator := Isolator on: #(2 #(1 0)).\x0aisolator model: rootModel modify: [:r|result := r].\x0aself assert: #(2 #(1 0)) equals: result\x0a",
  172. messageSends: ["on:", "model:modify:", "assert:equals:"],
  173. referencedClasses: ["Isolator"]
  174. }),
  175. smalltalk.IsolatorTest);
  176. smalltalk.addMethod(
  177. "_testRootModelModifiesAndDeeplyIsolatesInPlaceModifiedRoot",
  178. smalltalk.method({
  179. selector: "testRootModelModifiesAndDeeplyIsolatesInPlaceModifiedRoot",
  180. category: 'tests',
  181. fn: function (){
  182. var self=this;
  183. var isolator;
  184. var result;
  185. var newValue;
  186. result=nil;
  187. newValue=nil;
  188. isolator=smalltalk.send((smalltalk.Isolator || Isolator),"_on_",[[(1), [(2), (3)]]]);
  189. smalltalk.send(isolator,"_model_modify_",[self["@rootModel"],(function(r){
  190. newValue=r;
  191. newValue;
  192. smalltalk.send(r,"_at_put_",[(1),(4)]);
  193. return r;
  194. })]);
  195. smalltalk.send(newValue,"_at_put_",[(2),"bar"]);
  196. smalltalk.send(isolator,"_model_read_",[self["@rootModel"],(function(r){
  197. result=r;
  198. return result;
  199. })]);
  200. smalltalk.send(newValue,"_at_put_",[(2),"baz"]);
  201. smalltalk.send(self,"_assert_equals_",[[(4), [(2), (3)]],result]);
  202. return self},
  203. args: [],
  204. source: "testRootModelModifiesAndDeeplyIsolatesInPlaceModifiedRoot\x0a| isolator result newValue |\x0aresult := nil. newValue := nil.\x0aisolator := Isolator on: #(1 #(2 3)).\x0aisolator model: rootModel modify: [:r|newValue := r. r at: 1 put: 4. r].\x0anewValue at: 2 put: 'bar'.\x0aisolator model: rootModel read: [:r|result := r].\x0anewValue at: 2 put: 'baz'.\x0aself assert: #(4 #(2 3)) equals: result\x0a",
  205. messageSends: ["on:", "model:modify:", "at:put:", "model:read:", "assert:equals:"],
  206. referencedClasses: ["Isolator"]
  207. }),
  208. smalltalk.IsolatorTest);
  209. smalltalk.addMethod(
  210. "_testRootModelModifiesAndDeeplyIsolatesRoot",
  211. smalltalk.method({
  212. selector: "testRootModelModifiesAndDeeplyIsolatesRoot",
  213. category: 'tests',
  214. fn: function (){
  215. var self=this;
  216. var isolator;
  217. var result;
  218. var newValue;
  219. result=nil;
  220. isolator=smalltalk.send((smalltalk.Isolator || Isolator),"_on_",[[(1), [(2), (3)]]]);
  221. newValue=smalltalk.HashedCollection._fromPairs_([smalltalk.send("foo","__minus_gt",[[(4), (5), (6)]])]);
  222. smalltalk.send(isolator,"_model_modify_",[self["@rootModel"],(function(r){
  223. return newValue;
  224. })]);
  225. smalltalk.send(smalltalk.send(newValue,"_at_",["foo"]),"_at_put_",[(1),"bar"]);
  226. smalltalk.send(isolator,"_model_read_",[self["@rootModel"],(function(r){
  227. result=r;
  228. return result;
  229. })]);
  230. smalltalk.send(smalltalk.send(newValue,"_at_",["foo"]),"_at_put_",[(3),"baz"]);
  231. smalltalk.send(self,"_assert_equals_",[smalltalk.HashedCollection._fromPairs_([smalltalk.send("foo","__minus_gt",[[(4), (5), (6)]])]),result]);
  232. return self},
  233. args: [],
  234. source: "testRootModelModifiesAndDeeplyIsolatesRoot\x0a| isolator result newValue |\x0aresult := nil.\x0aisolator := Isolator on: #(1 #(2 3)).\x0anewValue := #{'foo'->#(4 5 6)}.\x0aisolator model: rootModel modify: [:r|newValue].\x0a(newValue at: 'foo') at: 1 put: 'bar'.\x0aisolator model: rootModel read: [:r|result := r].\x0a(newValue at: 'foo') at: 3 put: 'baz'.\x0aself assert: #{'foo'->#(4 5 6)} equals: result\x0a",
  235. messageSends: ["on:", "->", "model:modify:", "at:put:", "at:", "model:read:", "assert:equals:"],
  236. referencedClasses: ["Isolator"]
  237. }),
  238. smalltalk.IsolatorTest);
  239. smalltalk.addMethod(
  240. "_testRootModelModifiesAndIsolatesRoot",
  241. smalltalk.method({
  242. selector: "testRootModelModifiesAndIsolatesRoot",
  243. category: 'tests',
  244. fn: function (){
  245. var self=this;
  246. var isolator;
  247. var result;
  248. var newValue;
  249. result=nil;
  250. isolator=smalltalk.send((smalltalk.Isolator || Isolator),"_on_",[[(1), [(2), (3)]]]);
  251. newValue=smalltalk.HashedCollection._fromPairs_([smalltalk.send("foo","__minus_gt",[[(4), (5), (6)]])]);
  252. smalltalk.send(isolator,"_model_modify_",[self["@rootModel"],(function(r){
  253. return newValue;
  254. })]);
  255. smalltalk.send(newValue,"_at_put_",["foo","bar"]);
  256. smalltalk.send(isolator,"_model_read_",[self["@rootModel"],(function(r){
  257. result=r;
  258. return result;
  259. })]);
  260. smalltalk.send(newValue,"_at_put_",["foo","baz"]);
  261. smalltalk.send(self,"_assert_equals_",[smalltalk.HashedCollection._fromPairs_([smalltalk.send("foo","__minus_gt",[[(4), (5), (6)]])]),result]);
  262. return self},
  263. args: [],
  264. source: "testRootModelModifiesAndIsolatesRoot\x0a| isolator result newValue |\x0aresult := nil.\x0aisolator := Isolator on: #(1 #(2 3)).\x0anewValue := #{'foo'->#(4 5 6)}.\x0aisolator model: rootModel modify: [:r|newValue].\x0anewValue at: 'foo' put: 'bar'.\x0aisolator model: rootModel read: [:r|result := r].\x0anewValue at: 'foo' put: 'baz'.\x0aself assert: #{'foo'->#(4 5 6)} equals: result\x0a",
  265. messageSends: ["on:", "->", "model:modify:", "at:put:", "model:read:", "assert:equals:"],
  266. referencedClasses: ["Isolator"]
  267. }),
  268. smalltalk.IsolatorTest);
  269. smalltalk.addMethod(
  270. "_testRootModelModifiesRoot",
  271. smalltalk.method({
  272. selector: "testRootModelModifiesRoot",
  273. category: 'tests',
  274. fn: function (){
  275. var self=this;
  276. var isolator;
  277. var result;
  278. result=nil;
  279. isolator=smalltalk.send((smalltalk.Isolator || Isolator),"_on_",[[(1), [(2), (3)]]]);
  280. smalltalk.send(isolator,"_model_modify_",[self["@rootModel"],(function(r){
  281. return smalltalk.HashedCollection._fromPairs_([smalltalk.send("foo","__minus_gt",[[(4), (5), (6)]])]);
  282. })]);
  283. smalltalk.send(isolator,"_model_read_",[self["@rootModel"],(function(r){
  284. result=r;
  285. return result;
  286. })]);
  287. smalltalk.send(self,"_assert_equals_",[smalltalk.HashedCollection._fromPairs_([smalltalk.send("foo","__minus_gt",[[(4), (5), (6)]])]),result]);
  288. return self},
  289. args: [],
  290. source: "testRootModelModifiesRoot\x0a| isolator result |\x0aresult := nil.\x0aisolator := Isolator on: #(1 #(2 3)).\x0aisolator model: rootModel modify: [:r|#{'foo'->#(4 5 6)}].\x0aisolator model: rootModel read: [:r|result := r].\x0aself assert: #{'foo'->#(4 5 6)} equals: result\x0a",
  291. messageSends: ["on:", "model:modify:", "->", "model:read:", "assert:equals:"],
  292. referencedClasses: ["Isolator"]
  293. }),
  294. smalltalk.IsolatorTest);
  295. smalltalk.addMethod(
  296. "_testRootModelReturnsDeeplyIsolatedRoot",
  297. smalltalk.method({
  298. selector: "testRootModelReturnsDeeplyIsolatedRoot",
  299. category: 'tests',
  300. fn: function (){
  301. var self=this;
  302. var isolator;
  303. var result;
  304. result=nil;
  305. isolator=smalltalk.send((smalltalk.Isolator || Isolator),"_on_",[[(1), [(2), (3)]]]);
  306. smalltalk.send(isolator,"_model_read_",[self["@rootModel"],(function(r){
  307. return smalltalk.send(smalltalk.send(r,"_at_",[(2)]),"_at_put_",[(1),(0)]);
  308. })]);
  309. smalltalk.send(isolator,"_model_read_",[self["@rootModel"],(function(r){
  310. result=r;
  311. return result;
  312. })]);
  313. smalltalk.send(self,"_assert_equals_",[[(1), [(2), (3)]],result]);
  314. return self},
  315. args: [],
  316. source: "testRootModelReturnsDeeplyIsolatedRoot\x0a| isolator result |\x0aresult := nil.\x0aisolator := Isolator on: #(1 #(2 3)).\x0aisolator model: rootModel read: [:r|(r at: 2) at: 1 put: 0].\x0aisolator model: rootModel read: [:r|result := r].\x0aself assert: #(1 #(2 3)) equals: result\x0a",
  317. messageSends: ["on:", "model:read:", "at:put:", "at:", "assert:equals:"],
  318. referencedClasses: ["Isolator"]
  319. }),
  320. smalltalk.IsolatorTest);
  321. smalltalk.addMethod(
  322. "_testRootModelReturnsIsolatedRoot",
  323. smalltalk.method({
  324. selector: "testRootModelReturnsIsolatedRoot",
  325. category: 'tests',
  326. fn: function (){
  327. var self=this;
  328. var isolator;
  329. var result;
  330. result=nil;
  331. isolator=smalltalk.send((smalltalk.Isolator || Isolator),"_on_",[[(1), [(2), (4)]]]);
  332. smalltalk.send(isolator,"_model_read_",[self["@rootModel"],(function(r){
  333. return smalltalk.send(r,"_at_put_",[(2),nil]);
  334. })]);
  335. smalltalk.send(isolator,"_model_read_",[self["@rootModel"],(function(r){
  336. result=r;
  337. return result;
  338. })]);
  339. smalltalk.send(self,"_assert_equals_",[[(1), [(2), (4)]],result]);
  340. return self},
  341. args: [],
  342. source: "testRootModelReturnsIsolatedRoot\x0a| isolator result |\x0aresult := nil.\x0aisolator := Isolator on: #(1 #(2 4)).\x0aisolator model: rootModel read: [:r|r at: 2 put: nil].\x0aisolator model: rootModel read: [:r|result := r].\x0aself assert: #(1 #(2 4)) equals: result\x0a",
  343. messageSends: ["on:", "model:read:", "at:put:", "assert:equals:"],
  344. referencedClasses: ["Isolator"]
  345. }),
  346. smalltalk.IsolatorTest);
  347. smalltalk.addMethod(
  348. "_testRootModelReturnsRoot",
  349. smalltalk.method({
  350. selector: "testRootModelReturnsRoot",
  351. category: 'tests',
  352. fn: function (){
  353. var self=this;
  354. var isolator;
  355. var result;
  356. result=nil;
  357. isolator=smalltalk.send((smalltalk.Isolator || Isolator),"_on_",[[(1), [(2), (3)]]]);
  358. smalltalk.send(isolator,"_model_read_",[self["@rootModel"],(function(r){
  359. result=r;
  360. return result;
  361. })]);
  362. smalltalk.send(self,"_assert_equals_",[[(1), [(2), (3)]],result]);
  363. return self},
  364. args: [],
  365. source: "testRootModelReturnsRoot\x0a| isolator result |\x0aresult := nil.\x0aisolator := Isolator on: #(1 #(2 3)).\x0aisolator model: rootModel read: [:r|result := r].\x0aself assert: #(1 #(2 3)) equals: result\x0a",
  366. messageSends: ["on:", "model:read:", "assert:equals:"],
  367. referencedClasses: ["Isolator"]
  368. }),
  369. smalltalk.IsolatorTest);