Trapped-Tests.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. "_testNontrivialModelReturnsAppropriateValue",
  28. smalltalk.method({
  29. selector: "testNontrivialModelReturnsAppropriateValue",
  30. category: 'tests',
  31. fn: function (){
  32. var self=this;
  33. var bb;
  34. var model;
  35. var result;
  36. bb=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"])])]);
  37. model=smalltalk.send(smalltalk.send((smalltalk.EavModel || EavModel),"_new",[]),"_getBlock_",[(function(x){
  38. return smalltalk.send(smalltalk.send(smalltalk.send(x,"_root",[]),"_at_",["foo"]),"_at_",[(2)]);
  39. })]);
  40. smalltalk.send(bb,"_model_read_",[model,(function(r){
  41. result=r;
  42. return result;
  43. })]);
  44. smalltalk.send(self,"_assert_equals_",[[(1), [(2), (3)]],result]);
  45. return self},
  46. args: [],
  47. source: "testNontrivialModelReturnsAppropriateValue\x0a| bb model result |\x0abb := Isolator on: #{ 'foo' -> #('bar' #(1 #(2 3)) 'baz'). 'moo' -> 'zoo' }.\x0amodel := EavModel new getBlock: [ :x | (x root at: 'foo') at: 2 ].\x0abb model: model read: [:r|result := r].\x0aself assert: #(1 #(2 3)) equals: result\x0a",
  48. messageSends: ["on:", "->", "getBlock:", "at:", "root", "new", "model:read:", "assert:equals:"],
  49. referencedClasses: ["Isolator", "EavModel"]
  50. }),
  51. smalltalk.IsolatorTest);
  52. smalltalk.addMethod(
  53. "_testRootModelReturnsDeeplyIsolatedRoot",
  54. smalltalk.method({
  55. selector: "testRootModelReturnsDeeplyIsolatedRoot",
  56. category: 'tests',
  57. fn: function (){
  58. var self=this;
  59. var bb;
  60. var result;
  61. bb=smalltalk.send((smalltalk.Isolator || Isolator),"_on_",[[(1), [(2), (3)]]]);
  62. smalltalk.send(bb,"_model_read_",[self["@rootModel"],(function(r){
  63. return smalltalk.send(smalltalk.send(r,"_at_",[(2)]),"_at_put_",[(1),(0)]);
  64. })]);
  65. smalltalk.send(bb,"_model_read_",[self["@rootModel"],(function(r){
  66. result=r;
  67. return result;
  68. })]);
  69. smalltalk.send(self,"_assert_equals_",[[(1), [(2), (3)]],result]);
  70. return self},
  71. args: [],
  72. source: "testRootModelReturnsDeeplyIsolatedRoot\x0a| bb result |\x0abb := Isolator on: #(1 #(2 3)).\x0abb model: rootModel read: [:r|(r at: 2) at: 1 put: 0].\x0abb model: rootModel read: [:r|result := r].\x0aself assert: #(1 #(2 3)) equals: result\x0a",
  73. messageSends: ["on:", "model:read:", "at:put:", "at:", "assert:equals:"],
  74. referencedClasses: ["Isolator"]
  75. }),
  76. smalltalk.IsolatorTest);
  77. smalltalk.addMethod(
  78. "_testRootModelReturnsIsolatedRoot",
  79. smalltalk.method({
  80. selector: "testRootModelReturnsIsolatedRoot",
  81. category: 'tests',
  82. fn: function (){
  83. var self=this;
  84. var bb;
  85. var result;
  86. bb=smalltalk.send((smalltalk.Isolator || Isolator),"_on_",[[(1), [(2), (4)]]]);
  87. smalltalk.send(bb,"_model_read_",[self["@rootModel"],(function(r){
  88. return smalltalk.send(r,"_at_put_",[(2),nil]);
  89. })]);
  90. smalltalk.send(bb,"_model_read_",[self["@rootModel"],(function(r){
  91. result=r;
  92. return result;
  93. })]);
  94. smalltalk.send(self,"_assert_equals_",[[(1), [(2), (4)]],result]);
  95. return self},
  96. args: [],
  97. source: "testRootModelReturnsIsolatedRoot\x0a| bb result |\x0abb := Isolator on: #(1 #(2 4)).\x0abb model: rootModel read: [:r|r at: 2 put: nil].\x0abb model: rootModel read: [:r|result := r].\x0aself assert: #(1 #(2 4)) equals: result\x0a",
  98. messageSends: ["on:", "model:read:", "at:put:", "assert:equals:"],
  99. referencedClasses: ["Isolator"]
  100. }),
  101. smalltalk.IsolatorTest);
  102. smalltalk.addMethod(
  103. "_testRootModelReturnsRoot",
  104. smalltalk.method({
  105. selector: "testRootModelReturnsRoot",
  106. category: 'tests',
  107. fn: function (){
  108. var self=this;
  109. var bb;
  110. var result;
  111. bb=smalltalk.send((smalltalk.Isolator || Isolator),"_on_",[[(1), [(2), (3)]]]);
  112. smalltalk.send(bb,"_model_read_",[self["@rootModel"],(function(r){
  113. result=r;
  114. return result;
  115. })]);
  116. smalltalk.send(self,"_assert_equals_",[[(1), [(2), (3)]],result]);
  117. return self},
  118. args: [],
  119. source: "testRootModelReturnsRoot\x0a| bb result |\x0abb := Isolator on: #(1 #(2 3)).\x0abb model: rootModel read: [:r|result := r].\x0aself assert: #(1 #(2 3)) equals: result\x0a",
  120. messageSends: ["on:", "model:read:", "assert:equals:"],
  121. referencedClasses: ["Isolator"]
  122. }),
  123. smalltalk.IsolatorTest);