nudge 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (584) hide show
  1. data/.gitignore +5 -0
  2. data/LICENSE.txt +21 -0
  3. data/Rakefile +23 -0
  4. data/VERSION +1 -0
  5. data/_spikes/couch_document_spike.rb +24 -0
  6. data/_spikes/nested_parsing/nested.rb +0 -0
  7. data/_spikes/nested_parsing/nested.treetop +6 -0
  8. data/_spikes/nudgeview/init.rb +19 -0
  9. data/_spikes/nudgeview/public/javascripts/app.js +12 -0
  10. data/_spikes/nudgeview/public/javascripts/jquery.js +4376 -0
  11. data/_spikes/nudgeview/public/javascripts/jquery.svg.js +1325 -0
  12. data/_spikes/nudgeview/views/index.erb +18 -0
  13. data/_spikes/nudgeview/views/index.haml +8 -0
  14. data/_spikes/simplestWeb/simplest.rb +44 -0
  15. data/_spikes/simplestWeb/views/main.erb +19 -0
  16. data/_spikes/sketches/nudgecode_spike.rb +146 -0
  17. data/_spikes/sketches/searchDSL_spike.rb +25 -0
  18. data/_spikes/sketches/search_operator_sketch_spike.txt +287 -0
  19. data/_spikes/sketches/searchspace_spike.rb +96 -0
  20. data/_spikes/symbolic_regression/activate.rb +35 -0
  21. data/_spikes/symbolic_regression/config/environment.rb +340 -0
  22. data/_spikes/symbolic_regression/config/environments/deployment.rb +0 -0
  23. data/_spikes/symbolic_regression/config/environments/development.rb +0 -0
  24. data/_spikes/symbolic_regression/experiment/objectives/programLength.rb +2 -0
  25. data/_spikes/symbolic_regression/experiment/objectives/summedSquaredError.rb +2 -0
  26. data/_spikes/symbolic_regression/lib/tasks/run.rake +0 -0
  27. data/doc/classes/BlockNode.html +146 -0
  28. data/doc/classes/BlockNode.src/M000246.html +18 -0
  29. data/doc/classes/BoolAndInstruction.html +218 -0
  30. data/doc/classes/BoolAndInstruction.src/M000003.html +15 -0
  31. data/doc/classes/BoolAndInstruction.src/M000004.html +16 -0
  32. data/doc/classes/BoolAndInstruction.src/M000005.html +15 -0
  33. data/doc/classes/BoolAndInstruction.src/M000006.html +15 -0
  34. data/doc/classes/BoolEqualQInstruction.html +218 -0
  35. data/doc/classes/BoolEqualQInstruction.src/M000015.html +15 -0
  36. data/doc/classes/BoolEqualQInstruction.src/M000016.html +16 -0
  37. data/doc/classes/BoolEqualQInstruction.src/M000017.html +15 -0
  38. data/doc/classes/BoolEqualQInstruction.src/M000018.html +15 -0
  39. data/doc/classes/BoolFromFloatInstruction.html +218 -0
  40. data/doc/classes/BoolFromFloatInstruction.src/M000071.html +15 -0
  41. data/doc/classes/BoolFromFloatInstruction.src/M000072.html +15 -0
  42. data/doc/classes/BoolFromFloatInstruction.src/M000073.html +15 -0
  43. data/doc/classes/BoolFromFloatInstruction.src/M000074.html +15 -0
  44. data/doc/classes/BoolFromIntInstruction.html +218 -0
  45. data/doc/classes/BoolFromIntInstruction.src/M000067.html +15 -0
  46. data/doc/classes/BoolFromIntInstruction.src/M000068.html +15 -0
  47. data/doc/classes/BoolFromIntInstruction.src/M000069.html +15 -0
  48. data/doc/classes/BoolFromIntInstruction.src/M000070.html +15 -0
  49. data/doc/classes/BoolNotInstruction.html +218 -0
  50. data/doc/classes/BoolNotInstruction.src/M000019.html +15 -0
  51. data/doc/classes/BoolNotInstruction.src/M000020.html +15 -0
  52. data/doc/classes/BoolNotInstruction.src/M000021.html +15 -0
  53. data/doc/classes/BoolNotInstruction.src/M000022.html +15 -0
  54. data/doc/classes/BoolOrInstruction.html +218 -0
  55. data/doc/classes/BoolOrInstruction.src/M000007.html +15 -0
  56. data/doc/classes/BoolOrInstruction.src/M000008.html +16 -0
  57. data/doc/classes/BoolOrInstruction.src/M000009.html +15 -0
  58. data/doc/classes/BoolOrInstruction.src/M000010.html +15 -0
  59. data/doc/classes/BoolRandomInstruction.html +218 -0
  60. data/doc/classes/BoolRandomInstruction.src/M000187.html +15 -0
  61. data/doc/classes/BoolRandomInstruction.src/M000188.html +14 -0
  62. data/doc/classes/BoolRandomInstruction.src/M000189.html +15 -0
  63. data/doc/classes/BoolRandomInstruction.src/M000190.html +15 -0
  64. data/doc/classes/BoolType.html +196 -0
  65. data/doc/classes/BoolType.src/M000240.html +16 -0
  66. data/doc/classes/BoolType.src/M000241.html +15 -0
  67. data/doc/classes/BoolType.src/M000242.html +15 -0
  68. data/doc/classes/BoolXorInstruction.html +218 -0
  69. data/doc/classes/BoolXorInstruction.src/M000011.html +15 -0
  70. data/doc/classes/BoolXorInstruction.src/M000012.html +16 -0
  71. data/doc/classes/BoolXorInstruction.src/M000013.html +15 -0
  72. data/doc/classes/BoolXorInstruction.src/M000014.html +15 -0
  73. data/doc/classes/ChannelNode.html +161 -0
  74. data/doc/classes/ChannelNode.src/M000249.html +15 -0
  75. data/doc/classes/ChannelNode.src/M000250.html +16 -0
  76. data/doc/classes/CodeType.html +269 -0
  77. data/doc/classes/CodeType.src/M000219.html +38 -0
  78. data/doc/classes/CodeType.src/M000220.html +16 -0
  79. data/doc/classes/CodeType.src/M000221.html +16 -0
  80. data/doc/classes/CodeType.src/M000222.html +16 -0
  81. data/doc/classes/CodeType.src/M000223.html +24 -0
  82. data/doc/classes/CodeType.src/M000224.html +42 -0
  83. data/doc/classes/ERCNode.html +183 -0
  84. data/doc/classes/ERCNode.src/M000254.html +15 -0
  85. data/doc/classes/ERCNode.src/M000255.html +16 -0
  86. data/doc/classes/ERCNode.src/M000256.html +16 -0
  87. data/doc/classes/ExecPopInstruction.html +218 -0
  88. data/doc/classes/ExecPopInstruction.src/M000075.html +15 -0
  89. data/doc/classes/ExecPopInstruction.src/M000076.html +14 -0
  90. data/doc/classes/ExecPopInstruction.src/M000077.html +15 -0
  91. data/doc/classes/ExecPopInstruction.src/M000078.html +14 -0
  92. data/doc/classes/FloatAbsInstruction.html +218 -0
  93. data/doc/classes/FloatAbsInstruction.src/M000107.html +15 -0
  94. data/doc/classes/FloatAbsInstruction.src/M000108.html +15 -0
  95. data/doc/classes/FloatAbsInstruction.src/M000109.html +15 -0
  96. data/doc/classes/FloatAbsInstruction.src/M000110.html +15 -0
  97. data/doc/classes/FloatAddInstruction.html +218 -0
  98. data/doc/classes/FloatAddInstruction.src/M000079.html +15 -0
  99. data/doc/classes/FloatAddInstruction.src/M000080.html +16 -0
  100. data/doc/classes/FloatAddInstruction.src/M000081.html +15 -0
  101. data/doc/classes/FloatAddInstruction.src/M000082.html +15 -0
  102. data/doc/classes/FloatCosineInstruction.html +218 -0
  103. data/doc/classes/FloatCosineInstruction.src/M000123.html +15 -0
  104. data/doc/classes/FloatCosineInstruction.src/M000124.html +15 -0
  105. data/doc/classes/FloatCosineInstruction.src/M000125.html +15 -0
  106. data/doc/classes/FloatCosineInstruction.src/M000126.html +15 -0
  107. data/doc/classes/FloatDivideInstruction.html +218 -0
  108. data/doc/classes/FloatDivideInstruction.src/M000091.html +15 -0
  109. data/doc/classes/FloatDivideInstruction.src/M000092.html +16 -0
  110. data/doc/classes/FloatDivideInstruction.src/M000093.html +20 -0
  111. data/doc/classes/FloatDivideInstruction.src/M000094.html +15 -0
  112. data/doc/classes/FloatFromBoolInstruction.html +218 -0
  113. data/doc/classes/FloatFromBoolInstruction.src/M000055.html +15 -0
  114. data/doc/classes/FloatFromBoolInstruction.src/M000056.html +15 -0
  115. data/doc/classes/FloatFromBoolInstruction.src/M000057.html +15 -0
  116. data/doc/classes/FloatFromBoolInstruction.src/M000058.html +15 -0
  117. data/doc/classes/FloatFromIntInstruction.html +218 -0
  118. data/doc/classes/FloatFromIntInstruction.src/M000063.html +15 -0
  119. data/doc/classes/FloatFromIntInstruction.src/M000064.html +15 -0
  120. data/doc/classes/FloatFromIntInstruction.src/M000065.html +15 -0
  121. data/doc/classes/FloatFromIntInstruction.src/M000066.html +15 -0
  122. data/doc/classes/FloatGreaterThanQInstruction.html +218 -0
  123. data/doc/classes/FloatGreaterThanQInstruction.src/M000035.html +15 -0
  124. data/doc/classes/FloatGreaterThanQInstruction.src/M000036.html +16 -0
  125. data/doc/classes/FloatGreaterThanQInstruction.src/M000037.html +15 -0
  126. data/doc/classes/FloatGreaterThanQInstruction.src/M000038.html +15 -0
  127. data/doc/classes/FloatIfInstruction.html +218 -0
  128. data/doc/classes/FloatIfInstruction.src/M000047.html +16 -0
  129. data/doc/classes/FloatIfInstruction.src/M000048.html +15 -0
  130. data/doc/classes/FloatIfInstruction.src/M000049.html +14 -0
  131. data/doc/classes/FloatIfInstruction.src/M000050.html +17 -0
  132. data/doc/classes/FloatLessThanQInstruction.html +218 -0
  133. data/doc/classes/FloatLessThanQInstruction.src/M000039.html +15 -0
  134. data/doc/classes/FloatLessThanQInstruction.src/M000040.html +16 -0
  135. data/doc/classes/FloatLessThanQInstruction.src/M000041.html +15 -0
  136. data/doc/classes/FloatLessThanQInstruction.src/M000042.html +15 -0
  137. data/doc/classes/FloatMaxInstruction.html +218 -0
  138. data/doc/classes/FloatMaxInstruction.src/M000095.html +15 -0
  139. data/doc/classes/FloatMaxInstruction.src/M000096.html +16 -0
  140. data/doc/classes/FloatMaxInstruction.src/M000097.html +15 -0
  141. data/doc/classes/FloatMaxInstruction.src/M000098.html +15 -0
  142. data/doc/classes/FloatMinInstruction.html +218 -0
  143. data/doc/classes/FloatMinInstruction.src/M000099.html +15 -0
  144. data/doc/classes/FloatMinInstruction.src/M000100.html +16 -0
  145. data/doc/classes/FloatMinInstruction.src/M000101.html +15 -0
  146. data/doc/classes/FloatMinInstruction.src/M000102.html +15 -0
  147. data/doc/classes/FloatMultiplyInstruction.html +218 -0
  148. data/doc/classes/FloatMultiplyInstruction.src/M000083.html +15 -0
  149. data/doc/classes/FloatMultiplyInstruction.src/M000084.html +16 -0
  150. data/doc/classes/FloatMultiplyInstruction.src/M000085.html +15 -0
  151. data/doc/classes/FloatMultiplyInstruction.src/M000086.html +15 -0
  152. data/doc/classes/FloatNegativeInstruction.html +218 -0
  153. data/doc/classes/FloatNegativeInstruction.src/M000103.html +15 -0
  154. data/doc/classes/FloatNegativeInstruction.src/M000104.html +15 -0
  155. data/doc/classes/FloatNegativeInstruction.src/M000105.html +15 -0
  156. data/doc/classes/FloatNegativeInstruction.src/M000106.html +15 -0
  157. data/doc/classes/FloatPowerInstruction.html +218 -0
  158. data/doc/classes/FloatPowerInstruction.src/M000111.html +15 -0
  159. data/doc/classes/FloatPowerInstruction.src/M000112.html +16 -0
  160. data/doc/classes/FloatPowerInstruction.src/M000113.html +20 -0
  161. data/doc/classes/FloatPowerInstruction.src/M000114.html +15 -0
  162. data/doc/classes/FloatRandomInstruction.html +218 -0
  163. data/doc/classes/FloatRandomInstruction.src/M000191.html +15 -0
  164. data/doc/classes/FloatRandomInstruction.src/M000192.html +14 -0
  165. data/doc/classes/FloatRandomInstruction.src/M000193.html +15 -0
  166. data/doc/classes/FloatRandomInstruction.src/M000194.html +15 -0
  167. data/doc/classes/FloatSineInstruction.html +218 -0
  168. data/doc/classes/FloatSineInstruction.src/M000119.html +15 -0
  169. data/doc/classes/FloatSineInstruction.src/M000120.html +15 -0
  170. data/doc/classes/FloatSineInstruction.src/M000121.html +15 -0
  171. data/doc/classes/FloatSineInstruction.src/M000122.html +15 -0
  172. data/doc/classes/FloatSqrtInstruction.html +218 -0
  173. data/doc/classes/FloatSqrtInstruction.src/M000115.html +15 -0
  174. data/doc/classes/FloatSqrtInstruction.src/M000116.html +15 -0
  175. data/doc/classes/FloatSqrtInstruction.src/M000117.html +19 -0
  176. data/doc/classes/FloatSqrtInstruction.src/M000118.html +15 -0
  177. data/doc/classes/FloatSubtractInstruction.html +218 -0
  178. data/doc/classes/FloatSubtractInstruction.src/M000087.html +15 -0
  179. data/doc/classes/FloatSubtractInstruction.src/M000088.html +16 -0
  180. data/doc/classes/FloatSubtractInstruction.src/M000089.html +15 -0
  181. data/doc/classes/FloatSubtractInstruction.src/M000090.html +15 -0
  182. data/doc/classes/FloatTangentInstruction.html +218 -0
  183. data/doc/classes/FloatTangentInstruction.src/M000127.html +15 -0
  184. data/doc/classes/FloatTangentInstruction.src/M000128.html +15 -0
  185. data/doc/classes/FloatTangentInstruction.src/M000129.html +15 -0
  186. data/doc/classes/FloatTangentInstruction.src/M000130.html +15 -0
  187. data/doc/classes/FloatType.html +196 -0
  188. data/doc/classes/FloatType.src/M000243.html +19 -0
  189. data/doc/classes/FloatType.src/M000244.html +15 -0
  190. data/doc/classes/FloatType.src/M000245.html +15 -0
  191. data/doc/classes/Helpers.html +161 -0
  192. data/doc/classes/Helpers.src/M000343.html +21 -0
  193. data/doc/classes/Helpers.src/M000344.html +24 -0
  194. data/doc/classes/Instruction/InstructionMethodError.html +110 -0
  195. data/doc/classes/Instruction/NaNResultError.html +110 -0
  196. data/doc/classes/Instruction/NotEnoughStackItems.html +110 -0
  197. data/doc/classes/Instruction.html +500 -0
  198. data/doc/classes/Instruction.src/M000131.html +17 -0
  199. data/doc/classes/Instruction.src/M000132.html +15 -0
  200. data/doc/classes/Instruction.src/M000133.html +15 -0
  201. data/doc/classes/Instruction.src/M000134.html +15 -0
  202. data/doc/classes/Instruction.src/M000135.html +15 -0
  203. data/doc/classes/Instruction.src/M000136.html +15 -0
  204. data/doc/classes/Instruction.src/M000137.html +15 -0
  205. data/doc/classes/Instruction.src/M000138.html +15 -0
  206. data/doc/classes/Instruction.src/M000139.html +22 -0
  207. data/doc/classes/Instruction.src/M000140.html +15 -0
  208. data/doc/classes/Instruction.src/M000141.html +25 -0
  209. data/doc/classes/Instruction.src/M000142.html +15 -0
  210. data/doc/classes/Instruction.src/M000143.html +15 -0
  211. data/doc/classes/Instruction.src/M000144.html +15 -0
  212. data/doc/classes/Instruction.src/M000145.html +15 -0
  213. data/doc/classes/Instruction.src/M000146.html +15 -0
  214. data/doc/classes/InstructionNode.html +161 -0
  215. data/doc/classes/InstructionNode.src/M000247.html +15 -0
  216. data/doc/classes/InstructionNode.src/M000248.html +16 -0
  217. data/doc/classes/IntAbsInstruction.html +218 -0
  218. data/doc/classes/IntAbsInstruction.src/M000175.html +15 -0
  219. data/doc/classes/IntAbsInstruction.src/M000176.html +15 -0
  220. data/doc/classes/IntAbsInstruction.src/M000177.html +15 -0
  221. data/doc/classes/IntAbsInstruction.src/M000178.html +15 -0
  222. data/doc/classes/IntAddInstruction.html +218 -0
  223. data/doc/classes/IntAddInstruction.src/M000147.html +15 -0
  224. data/doc/classes/IntAddInstruction.src/M000148.html +16 -0
  225. data/doc/classes/IntAddInstruction.src/M000149.html +15 -0
  226. data/doc/classes/IntAddInstruction.src/M000150.html +15 -0
  227. data/doc/classes/IntDepthInstruction.html +218 -0
  228. data/doc/classes/IntDepthInstruction.src/M000211.html +15 -0
  229. data/doc/classes/IntDepthInstruction.src/M000212.html +14 -0
  230. data/doc/classes/IntDepthInstruction.src/M000213.html +15 -0
  231. data/doc/classes/IntDepthInstruction.src/M000214.html +15 -0
  232. data/doc/classes/IntDivideInstruction.html +218 -0
  233. data/doc/classes/IntDivideInstruction.src/M000155.html +15 -0
  234. data/doc/classes/IntDivideInstruction.src/M000156.html +16 -0
  235. data/doc/classes/IntDivideInstruction.src/M000157.html +20 -0
  236. data/doc/classes/IntDivideInstruction.src/M000158.html +15 -0
  237. data/doc/classes/IntDuplicateInstruction.html +218 -0
  238. data/doc/classes/IntDuplicateInstruction.src/M000203.html +15 -0
  239. data/doc/classes/IntDuplicateInstruction.src/M000204.html +15 -0
  240. data/doc/classes/IntDuplicateInstruction.src/M000205.html +15 -0
  241. data/doc/classes/IntDuplicateInstruction.src/M000206.html +15 -0
  242. data/doc/classes/IntEqualQInstruction.html +218 -0
  243. data/doc/classes/IntEqualQInstruction.src/M000023.html +15 -0
  244. data/doc/classes/IntEqualQInstruction.src/M000024.html +16 -0
  245. data/doc/classes/IntEqualQInstruction.src/M000025.html +15 -0
  246. data/doc/classes/IntEqualQInstruction.src/M000026.html +15 -0
  247. data/doc/classes/IntFlushInstruction.html +218 -0
  248. data/doc/classes/IntFlushInstruction.src/M000215.html +15 -0
  249. data/doc/classes/IntFlushInstruction.src/M000216.html +14 -0
  250. data/doc/classes/IntFlushInstruction.src/M000217.html +14 -0
  251. data/doc/classes/IntFlushInstruction.src/M000218.html +15 -0
  252. data/doc/classes/IntFromBoolInstruction.html +218 -0
  253. data/doc/classes/IntFromBoolInstruction.src/M000051.html +15 -0
  254. data/doc/classes/IntFromBoolInstruction.src/M000052.html +15 -0
  255. data/doc/classes/IntFromBoolInstruction.src/M000053.html +15 -0
  256. data/doc/classes/IntFromBoolInstruction.src/M000054.html +15 -0
  257. data/doc/classes/IntFromFloatInstruction.html +218 -0
  258. data/doc/classes/IntFromFloatInstruction.src/M000059.html +15 -0
  259. data/doc/classes/IntFromFloatInstruction.src/M000060.html +15 -0
  260. data/doc/classes/IntFromFloatInstruction.src/M000061.html +15 -0
  261. data/doc/classes/IntFromFloatInstruction.src/M000062.html +15 -0
  262. data/doc/classes/IntGreaterThanQInstruction.html +218 -0
  263. data/doc/classes/IntGreaterThanQInstruction.src/M000031.html +15 -0
  264. data/doc/classes/IntGreaterThanQInstruction.src/M000032.html +16 -0
  265. data/doc/classes/IntGreaterThanQInstruction.src/M000033.html +15 -0
  266. data/doc/classes/IntGreaterThanQInstruction.src/M000034.html +15 -0
  267. data/doc/classes/IntIfInstruction.html +218 -0
  268. data/doc/classes/IntIfInstruction.src/M000043.html +16 -0
  269. data/doc/classes/IntIfInstruction.src/M000044.html +15 -0
  270. data/doc/classes/IntIfInstruction.src/M000045.html +14 -0
  271. data/doc/classes/IntIfInstruction.src/M000046.html +17 -0
  272. data/doc/classes/IntLessThanQInstruction.html +218 -0
  273. data/doc/classes/IntLessThanQInstruction.src/M000027.html +15 -0
  274. data/doc/classes/IntLessThanQInstruction.src/M000028.html +16 -0
  275. data/doc/classes/IntLessThanQInstruction.src/M000029.html +15 -0
  276. data/doc/classes/IntLessThanQInstruction.src/M000030.html +15 -0
  277. data/doc/classes/IntMaxInstruction.html +218 -0
  278. data/doc/classes/IntMaxInstruction.src/M000167.html +15 -0
  279. data/doc/classes/IntMaxInstruction.src/M000168.html +16 -0
  280. data/doc/classes/IntMaxInstruction.src/M000169.html +16 -0
  281. data/doc/classes/IntMaxInstruction.src/M000170.html +15 -0
  282. data/doc/classes/IntMinInstruction.html +218 -0
  283. data/doc/classes/IntMinInstruction.src/M000171.html +15 -0
  284. data/doc/classes/IntMinInstruction.src/M000172.html +16 -0
  285. data/doc/classes/IntMinInstruction.src/M000173.html +16 -0
  286. data/doc/classes/IntMinInstruction.src/M000174.html +15 -0
  287. data/doc/classes/IntModuloInstruction.html +218 -0
  288. data/doc/classes/IntModuloInstruction.src/M000163.html +15 -0
  289. data/doc/classes/IntModuloInstruction.src/M000164.html +16 -0
  290. data/doc/classes/IntModuloInstruction.src/M000165.html +20 -0
  291. data/doc/classes/IntModuloInstruction.src/M000166.html +15 -0
  292. data/doc/classes/IntMultiplyInstruction.html +218 -0
  293. data/doc/classes/IntMultiplyInstruction.src/M000151.html +15 -0
  294. data/doc/classes/IntMultiplyInstruction.src/M000152.html +16 -0
  295. data/doc/classes/IntMultiplyInstruction.src/M000153.html +15 -0
  296. data/doc/classes/IntMultiplyInstruction.src/M000154.html +15 -0
  297. data/doc/classes/IntNegativeInstruction.html +218 -0
  298. data/doc/classes/IntNegativeInstruction.src/M000179.html +15 -0
  299. data/doc/classes/IntNegativeInstruction.src/M000180.html +15 -0
  300. data/doc/classes/IntNegativeInstruction.src/M000181.html +15 -0
  301. data/doc/classes/IntNegativeInstruction.src/M000182.html +15 -0
  302. data/doc/classes/IntPopInstruction.html +218 -0
  303. data/doc/classes/IntPopInstruction.src/M000195.html +15 -0
  304. data/doc/classes/IntPopInstruction.src/M000196.html +15 -0
  305. data/doc/classes/IntPopInstruction.src/M000197.html +14 -0
  306. data/doc/classes/IntPopInstruction.src/M000198.html +14 -0
  307. data/doc/classes/IntRandomInstruction.html +218 -0
  308. data/doc/classes/IntRandomInstruction.src/M000183.html +15 -0
  309. data/doc/classes/IntRandomInstruction.src/M000184.html +14 -0
  310. data/doc/classes/IntRandomInstruction.src/M000185.html +15 -0
  311. data/doc/classes/IntRandomInstruction.src/M000186.html +15 -0
  312. data/doc/classes/IntRotateInstruction.html +218 -0
  313. data/doc/classes/IntRotateInstruction.src/M000207.html +15 -0
  314. data/doc/classes/IntRotateInstruction.src/M000208.html +17 -0
  315. data/doc/classes/IntRotateInstruction.src/M000209.html +14 -0
  316. data/doc/classes/IntRotateInstruction.src/M000210.html +17 -0
  317. data/doc/classes/IntSubtractInstruction.html +218 -0
  318. data/doc/classes/IntSubtractInstruction.src/M000159.html +15 -0
  319. data/doc/classes/IntSubtractInstruction.src/M000160.html +16 -0
  320. data/doc/classes/IntSubtractInstruction.src/M000161.html +16 -0
  321. data/doc/classes/IntSubtractInstruction.src/M000162.html +15 -0
  322. data/doc/classes/IntSwapInstruction.html +218 -0
  323. data/doc/classes/IntSwapInstruction.src/M000199.html +15 -0
  324. data/doc/classes/IntSwapInstruction.src/M000200.html +16 -0
  325. data/doc/classes/IntSwapInstruction.src/M000201.html +14 -0
  326. data/doc/classes/IntSwapInstruction.src/M000202.html +16 -0
  327. data/doc/classes/IntType.html +240 -0
  328. data/doc/classes/IntType.src/M000235.html +15 -0
  329. data/doc/classes/IntType.src/M000236.html +15 -0
  330. data/doc/classes/IntType.src/M000237.html +18 -0
  331. data/doc/classes/IntType.src/M000238.html +15 -0
  332. data/doc/classes/IntType.src/M000239.html +15 -0
  333. data/doc/classes/LiteralNode.html +183 -0
  334. data/doc/classes/LiteralNode.src/M000251.html +15 -0
  335. data/doc/classes/LiteralNode.src/M000252.html +16 -0
  336. data/doc/classes/LiteralNode.src/M000253.html +16 -0
  337. data/doc/classes/Nudge/Channel.html +437 -0
  338. data/doc/classes/Nudge/Channel.src/M000286.html +15 -0
  339. data/doc/classes/Nudge/Channel.src/M000287.html +19 -0
  340. data/doc/classes/Nudge/Channel.src/M000288.html +15 -0
  341. data/doc/classes/Nudge/Channel.src/M000289.html +15 -0
  342. data/doc/classes/Nudge/Channel.src/M000290.html +15 -0
  343. data/doc/classes/Nudge/Channel.src/M000291.html +19 -0
  344. data/doc/classes/Nudge/Channel.src/M000292.html +19 -0
  345. data/doc/classes/Nudge/Channel.src/M000293.html +17 -0
  346. data/doc/classes/Nudge/Channel.src/M000294.html +15 -0
  347. data/doc/classes/Nudge/Channel.src/M000295.html +20 -0
  348. data/doc/classes/Nudge/Channel.src/M000296.html +15 -0
  349. data/doc/classes/Nudge/Channel.src/M000297.html +17 -0
  350. data/doc/classes/Nudge/Channel.src/M000298.html +15 -0
  351. data/doc/classes/Nudge/CodeBlock.html +331 -0
  352. data/doc/classes/Nudge/CodeBlock.src/M000263.html +15 -0
  353. data/doc/classes/Nudge/CodeBlock.src/M000264.html +15 -0
  354. data/doc/classes/Nudge/CodeBlock.src/M000265.html +15 -0
  355. data/doc/classes/Nudge/CodeBlock.src/M000266.html +15 -0
  356. data/doc/classes/Nudge/CodeBlock.src/M000267.html +15 -0
  357. data/doc/classes/Nudge/CodeBlock.src/M000268.html +17 -0
  358. data/doc/classes/Nudge/CodeBlock.src/M000269.html +20 -0
  359. data/doc/classes/Nudge/CodeBlock.src/M000270.html +15 -0
  360. data/doc/classes/Nudge/CodeBlock.src/M000271.html +19 -0
  361. data/doc/classes/Nudge/DeadLocation.html +152 -0
  362. data/doc/classes/Nudge/DeadLocation.src/M000334.html +17 -0
  363. data/doc/classes/Nudge/Erc.html +335 -0
  364. data/doc/classes/Nudge/Erc.src/M000278.html +16 -0
  365. data/doc/classes/Nudge/Erc.src/M000279.html +15 -0
  366. data/doc/classes/Nudge/Erc.src/M000280.html +15 -0
  367. data/doc/classes/Nudge/Erc.src/M000281.html +15 -0
  368. data/doc/classes/Nudge/Erc.src/M000282.html +18 -0
  369. data/doc/classes/Nudge/Erc.src/M000283.html +15 -0
  370. data/doc/classes/Nudge/Erc.src/M000284.html +17 -0
  371. data/doc/classes/Nudge/Erc.src/M000285.html +15 -0
  372. data/doc/classes/Nudge/Individual.html +313 -0
  373. data/doc/classes/Nudge/Individual.src/M000314.html +21 -0
  374. data/doc/classes/Nudge/Individual.src/M000315.html +15 -0
  375. data/doc/classes/Nudge/Individual.src/M000316.html +15 -0
  376. data/doc/classes/Nudge/Individual.src/M000317.html +17 -0
  377. data/doc/classes/Nudge/Individual.src/M000318.html +25 -0
  378. data/doc/classes/Nudge/InstructionPoint/InstructionNotFoundError.html +110 -0
  379. data/doc/classes/Nudge/InstructionPoint.html +350 -0
  380. data/doc/classes/Nudge/InstructionPoint.src/M000299.html +15 -0
  381. data/doc/classes/Nudge/InstructionPoint.src/M000300.html +15 -0
  382. data/doc/classes/Nudge/InstructionPoint.src/M000301.html +17 -0
  383. data/doc/classes/Nudge/InstructionPoint.src/M000302.html +15 -0
  384. data/doc/classes/Nudge/InstructionPoint.src/M000303.html +17 -0
  385. data/doc/classes/Nudge/InstructionPoint.src/M000304.html +17 -0
  386. data/doc/classes/Nudge/InstructionPoint.src/M000305.html +17 -0
  387. data/doc/classes/Nudge/InstructionPoint.src/M000306.html +15 -0
  388. data/doc/classes/Nudge/Interpreter.html +369 -0
  389. data/doc/classes/Nudge/Interpreter.src/M000257.html +20 -0
  390. data/doc/classes/Nudge/Interpreter.src/M000258.html +19 -0
  391. data/doc/classes/Nudge/Interpreter.src/M000259.html +15 -0
  392. data/doc/classes/Nudge/Interpreter.src/M000260.html +19 -0
  393. data/doc/classes/Nudge/Interpreter.src/M000261.html +17 -0
  394. data/doc/classes/Nudge/LiteralPoint.html +291 -0
  395. data/doc/classes/Nudge/LiteralPoint.src/M000272.html +16 -0
  396. data/doc/classes/Nudge/LiteralPoint.src/M000273.html +15 -0
  397. data/doc/classes/Nudge/LiteralPoint.src/M000274.html +15 -0
  398. data/doc/classes/Nudge/LiteralPoint.src/M000275.html +18 -0
  399. data/doc/classes/Nudge/LiteralPoint.src/M000276.html +17 -0
  400. data/doc/classes/Nudge/LiteralPoint.src/M000277.html +15 -0
  401. data/doc/classes/Nudge/Location.html +525 -0
  402. data/doc/classes/Nudge/Location.src/M000319.html +19 -0
  403. data/doc/classes/Nudge/Location.src/M000320.html +15 -0
  404. data/doc/classes/Nudge/Location.src/M000321.html +26 -0
  405. data/doc/classes/Nudge/Location.src/M000322.html +15 -0
  406. data/doc/classes/Nudge/Location.src/M000323.html +20 -0
  407. data/doc/classes/Nudge/Location.src/M000324.html +16 -0
  408. data/doc/classes/Nudge/Location.src/M000325.html +25 -0
  409. data/doc/classes/Nudge/Location.src/M000326.html +15 -0
  410. data/doc/classes/Nudge/Location.src/M000327.html +21 -0
  411. data/doc/classes/Nudge/Location.src/M000328.html +16 -0
  412. data/doc/classes/Nudge/Location.src/M000329.html +15 -0
  413. data/doc/classes/Nudge/Location.src/M000330.html +16 -0
  414. data/doc/classes/Nudge/Location.src/M000331.html +20 -0
  415. data/doc/classes/Nudge/Location.src/M000332.html +17 -0
  416. data/doc/classes/Nudge/Location.src/M000333.html +17 -0
  417. data/doc/classes/Nudge/NondominatedSubset.html +196 -0
  418. data/doc/classes/Nudge/NondominatedSubset.src/M000005.html +19 -0
  419. data/doc/classes/Nudge/NondominatedSubset.src/M000006.html +19 -0
  420. data/doc/classes/Nudge/NondominatedSubset.src/M000007.html +25 -0
  421. data/doc/classes/Nudge/NondominatedSubset.src/M000339.html +19 -0
  422. data/doc/classes/Nudge/NondominatedSubset.src/M000340.html +19 -0
  423. data/doc/classes/Nudge/NondominatedSubset.src/M000341.html +25 -0
  424. data/doc/classes/Nudge/PopulationResample.html +175 -0
  425. data/doc/classes/Nudge/PopulationResample.src/M000003.html +22 -0
  426. data/doc/classes/Nudge/PopulationResample.src/M000337.html +22 -0
  427. data/doc/classes/Nudge/ProgramPoint.html +148 -0
  428. data/doc/classes/Nudge/ProgramPoint.src/M000262.html +15 -0
  429. data/doc/classes/Nudge/RandomGuess.html +176 -0
  430. data/doc/classes/Nudge/RandomGuess.src/M000002.html +21 -0
  431. data/doc/classes/Nudge/RandomGuess.src/M000336.html +21 -0
  432. data/doc/classes/Nudge/ResampleValues.html +169 -0
  433. data/doc/classes/Nudge/ResampleValues.src/M000004.html +36 -0
  434. data/doc/classes/Nudge/ResampleValues.src/M000338.html +36 -0
  435. data/doc/classes/Nudge/SearchOperator.html +175 -0
  436. data/doc/classes/Nudge/SearchOperator.src/M000001.html +15 -0
  437. data/doc/classes/Nudge/SearchOperator.src/M000335.html +15 -0
  438. data/doc/classes/Nudge/Stack.html +350 -0
  439. data/doc/classes/Nudge/Stack.src/M000307.html +15 -0
  440. data/doc/classes/Nudge/Stack.src/M000308.html +15 -0
  441. data/doc/classes/Nudge/Stack.src/M000309.html +18 -0
  442. data/doc/classes/Nudge/Stack.src/M000310.html +15 -0
  443. data/doc/classes/Nudge/Stack.src/M000311.html +15 -0
  444. data/doc/classes/Nudge/Stack.src/M000312.html +15 -0
  445. data/doc/classes/Nudge/Stack.src/M000313.html +15 -0
  446. data/doc/classes/Nudge/UniformBackboneCrossover.html +152 -0
  447. data/doc/classes/Nudge/UniformBackboneCrossover.src/M000008.html +35 -0
  448. data/doc/classes/Nudge/UniformBackboneCrossover.src/M000342.html +35 -0
  449. data/doc/classes/Nudge.html +174 -0
  450. data/doc/classes/NudgeType.html +363 -0
  451. data/doc/classes/NudgeType.src/M000225.html +17 -0
  452. data/doc/classes/NudgeType.src/M000226.html +15 -0
  453. data/doc/classes/NudgeType.src/M000227.html +15 -0
  454. data/doc/classes/NudgeType.src/M000228.html +15 -0
  455. data/doc/classes/NudgeType.src/M000229.html +15 -0
  456. data/doc/classes/NudgeType.src/M000230.html +15 -0
  457. data/doc/classes/NudgeType.src/M000231.html +15 -0
  458. data/doc/classes/NudgeType.src/M000232.html +15 -0
  459. data/doc/classes/NudgeType.src/M000233.html +15 -0
  460. data/doc/classes/NudgeType.src/M000234.html +15 -0
  461. data/doc/created.rid +1 -0
  462. data/doc/files/lib/instructions/bool_basics_rb.html +90 -0
  463. data/doc/files/lib/instructions/comparisons_rb.html +90 -0
  464. data/doc/files/lib/instructions/conditionals_rb.html +90 -0
  465. data/doc/files/lib/instructions/conversions_rb.html +90 -0
  466. data/doc/files/lib/instructions/exec_rb.html +90 -0
  467. data/doc/files/lib/instructions/float_arithmetic_rb.html +90 -0
  468. data/doc/files/lib/instructions/float_transcendental_rb.html +90 -0
  469. data/doc/files/lib/instructions/infrastructure_rb.html +100 -0
  470. data/doc/files/lib/instructions/int_arithmetic_rb.html +90 -0
  471. data/doc/files/lib/instructions/random_value_rb.html +90 -0
  472. data/doc/files/lib/instructions/stack_manipulation_rb.html +90 -0
  473. data/doc/files/lib/interpreter/grammars/nudge_language_helpers_rb.html +97 -0
  474. data/doc/files/lib/interpreter/grammars/nudge_language_treetop.html +180 -0
  475. data/doc/files/lib/interpreter/interpreter_rb.html +90 -0
  476. data/doc/files/lib/interpreter/programPoints_rb.html +90 -0
  477. data/doc/files/lib/interpreter/stack_rb.html +90 -0
  478. data/doc/files/lib/interpreter/types/codeType_rb.html +157 -0
  479. data/doc/files/lib/interpreter/types/codeType_rb.src/M000001.html +15 -0
  480. data/doc/files/lib/interpreter/types/codeType_rb.src/M000002.html +15 -0
  481. data/doc/files/lib/interpreter/types/pushTypes_rb.html +107 -0
  482. data/doc/files/lib/nudge_rb.html +152 -0
  483. data/doc/files/lib/search/evaluators/structural_complexity_rb.html +90 -0
  484. data/doc/files/lib/search/helpers_rb.html +90 -0
  485. data/doc/files/lib/search/individual/individual_rb.html +90 -0
  486. data/doc/files/lib/search/locations/location_rb.html +100 -0
  487. data/doc/files/lib/search/operators/basic_operators_rb.html +90 -0
  488. data/doc/fr_class_index.html +191 -0
  489. data/doc/fr_file_index.html +71 -0
  490. data/doc/fr_method_index.html +711 -0
  491. data/doc/index.html +21 -0
  492. data/doc/rdoc-style.css +299 -0
  493. data/features/parser_recognizes_nudge_language.feature +9 -0
  494. data/lib/instructions/bool_basics.rb +85 -0
  495. data/lib/instructions/code_basics.rb +14 -0
  496. data/lib/instructions/comparisons.rb +152 -0
  497. data/lib/instructions/conditionals.rb +44 -0
  498. data/lib/instructions/conversions.rb +94 -0
  499. data/lib/instructions/exec.rb +154 -0
  500. data/lib/instructions/float_arithmetic.rb +201 -0
  501. data/lib/instructions/float_transcendental.rb +47 -0
  502. data/lib/instructions/infrastructure.rb +84 -0
  503. data/lib/instructions/int_arithmetic.rb +160 -0
  504. data/lib/instructions/name_basics.rb +44 -0
  505. data/lib/instructions/name_bindings.rb +65 -0
  506. data/lib/instructions/random_value.rb +43 -0
  507. data/lib/instructions/stack_manipulation.rb +739 -0
  508. data/lib/interpreter/grammars/nudge_language.treetop +83 -0
  509. data/lib/interpreter/grammars/nudge_language_helpers.rb +64 -0
  510. data/lib/interpreter/interpreter.rb +176 -0
  511. data/lib/interpreter/programPoints.rb +236 -0
  512. data/lib/interpreter/stack.rb +39 -0
  513. data/lib/interpreter/types/codeType.rb +108 -0
  514. data/lib/interpreter/types/pushTypes.rb +102 -0
  515. data/lib/nudge.rb +38 -0
  516. data/lib/search/experiments/experiment.rb +53 -0
  517. data/lib/search/helpers.rb +22 -0
  518. data/lib/search/individual/batch.rb +25 -0
  519. data/lib/search/individual/individual.rb +147 -0
  520. data/lib/search/operators/basic_operators.rb +230 -0
  521. data/lib/search/operators/evaluators.rb +107 -0
  522. data/lib/search/operators/samplers_and_selectors.rb +123 -0
  523. data/lib/search/stations/station.rb +147 -0
  524. data/push_language_coverage.md +177 -0
  525. data/readme.md +19 -0
  526. data/spec/data/couchdb_spec.rb +2 -0
  527. data/spec/fixtures/just_block.example +1 -0
  528. data/spec/fixtures/just_block_with_newline.example +1 -0
  529. data/spec/fixtures/long_arithmetic.example +7 -0
  530. data/spec/fixtures/one_line_instr.example +1 -0
  531. data/spec/fixtures/untidy1.example +20 -0
  532. data/spec/fixtures/untidy1fixed.example +12 -0
  533. data/spec/instructions/bool_basics_spec.rb +97 -0
  534. data/spec/instructions/bool_stack_spec.rb +391 -0
  535. data/spec/instructions/code_basics_spec.rb +43 -0
  536. data/spec/instructions/code_stack_spec.rb +382 -0
  537. data/spec/instructions/comparisons_spec.rb +486 -0
  538. data/spec/instructions/conditionals_spec.rb +162 -0
  539. data/spec/instructions/conversions_spec.rb +92 -0
  540. data/spec/instructions/exec_spec.rb +883 -0
  541. data/spec/instructions/float_calculations_spec.rb +148 -0
  542. data/spec/instructions/float_stack_spec.rb +382 -0
  543. data/spec/instructions/float_transcendental_spec.rb +89 -0
  544. data/spec/instructions/instruction_class_spec.rb +9 -0
  545. data/spec/instructions/int_calculations_spec.rb +125 -0
  546. data/spec/instructions/int_stack_spec.rb +398 -0
  547. data/spec/instructions/name_basics_spec.rb +158 -0
  548. data/spec/instructions/name_bindings_spec.rb +257 -0
  549. data/spec/instructions/name_stack_spec.rb +382 -0
  550. data/spec/instructions/random_values_spec.rb +68 -0
  551. data/spec/integration/search_integration.rb +67 -0
  552. data/spec/interpreter/channel_spec.rb +92 -0
  553. data/spec/interpreter/codeblock_spec.rb +135 -0
  554. data/spec/interpreter/codetype_spec.rb +257 -0
  555. data/spec/interpreter/erc_spec.rb +130 -0
  556. data/spec/interpreter/instruction_spec.rb +97 -0
  557. data/spec/interpreter/interpreter_spec.rb +266 -0
  558. data/spec/interpreter/literal_spec.rb +94 -0
  559. data/spec/interpreter/parser_spec.rb +324 -0
  560. data/spec/interpreter/stack_spec.rb +81 -0
  561. data/spec/interpreter/types_spec.rb +102 -0
  562. data/spec/search/batch_spec.rb +30 -0
  563. data/spec/search/experiments/experiment_spec.rb +101 -0
  564. data/spec/search/helpers_spec.rb +59 -0
  565. data/spec/search/individual_spec.rb +356 -0
  566. data/spec/search/operators/any_one_sampler_spec.rb +40 -0
  567. data/spec/search/operators/dominated_quantile_spec.rb +111 -0
  568. data/spec/search/operators/duplicate_genomes_spec.rb +35 -0
  569. data/spec/search/operators/evaluators/program_point_evaluator_spec.rb +43 -0
  570. data/spec/search/operators/evaluators/test_case_evaluator_spec.rb +133 -0
  571. data/spec/search/operators/infrastructure_spec.rb +47 -0
  572. data/spec/search/operators/most_dominated_subset_spec.rb +47 -0
  573. data/spec/search/operators/nondominated_subset_spec.rb +97 -0
  574. data/spec/search/operators/pointCrossover_spec.rb +55 -0
  575. data/spec/search/operators/pointDeletion_spec.rb +57 -0
  576. data/spec/search/operators/pointMutation_spec.rb +71 -0
  577. data/spec/search/operators/random_guess_spec.rb +51 -0
  578. data/spec/search/operators/resample_and_clone_spec.rb +50 -0
  579. data/spec/search/operators/resample_values_spec.rb +126 -0
  580. data/spec/search/operators/sizePreservingMutation_spec.rb +2 -0
  581. data/spec/search/operators/uniformBackboneCrossover_spec.rb +63 -0
  582. data/spec/search/stations/station_spec.rb +496 -0
  583. data/spec/spec_helper.rb +11 -0
  584. metadata +738 -0
@@ -0,0 +1,883 @@
1
+ require File.join(File.dirname(__FILE__), "/../spec_helper")
2
+ include Nudge
3
+
4
+
5
+ describe ExecYInstruction do
6
+ before(:each) do
7
+ @context = Interpreter.new
8
+ @i1 = ExecYInstruction.new(@context)
9
+ end
10
+
11
+ it "should have the right context" do
12
+ @i1.context.should == @context
13
+ end
14
+
15
+ [:preconditions?, :setup, :derive, :cleanup].each do |methodName|
16
+ it "should respond to \##{methodName}" do
17
+ @i1.should respond_to(methodName)
18
+ end
19
+ end
20
+
21
+ describe "\#go" do
22
+ before(:each) do
23
+ @context = Interpreter.new
24
+ @i1 = ExecYInstruction.new(@context)
25
+ @context.reset("do int_add")
26
+ end
27
+
28
+ describe "\#preconditions?" do
29
+ it "should check that the :exec stack has at least one item" do
30
+ @i1.preconditions?.should == true
31
+ end
32
+ end
33
+
34
+ describe "\#cleanup" do
35
+ it "should end up with a block {do exec_y [something]} in the second position on the :exec stack" do
36
+ @context.stacks[:exec].depth.should == 1
37
+ @i1.go
38
+ @context.stacks[:exec].depth.should == 2
39
+ @context.stacks[:exec].peek.listing.should == "do int_add"
40
+ @context.stacks[:exec].entries[0].points.should == 3
41
+ @context.stacks[:exec].entries[0].listing.should include("do exec_y")
42
+ @context.stacks[:exec].entries[0].listing.should include(@context.stacks[:exec].peek.listing)
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+
49
+ describe ExecKInstruction do
50
+ before(:each) do
51
+ @context = Interpreter.new
52
+ @i1 = ExecKInstruction.new(@context)
53
+ end
54
+
55
+ it "should have the right context" do
56
+ @i1.context.should == @context
57
+ end
58
+
59
+ [:preconditions?, :setup, :derive, :cleanup].each do |methodName|
60
+ it "should respond to \##{methodName}" do
61
+ @i1.should respond_to(methodName)
62
+ end
63
+ end
64
+
65
+ describe "\#go" do
66
+ before(:each) do
67
+ @context = Interpreter.new
68
+ @i1 = ExecKInstruction.new(@context)
69
+ @context.reset("block { do int_add do int_subtract }")
70
+ @context.step # unwrapping the two instructions
71
+ end
72
+
73
+ describe "\#preconditions?" do
74
+ it "should check that the :exec stack has at least two items" do
75
+ @i1.preconditions?.should == true
76
+ end
77
+ end
78
+
79
+ describe "\#cleanup" do
80
+ it "should delete the item from the second position on the :exec stack" do
81
+ @context.stacks[:exec].depth.should == 2
82
+ @i1.go
83
+ @context.stacks[:exec].depth.should == 1
84
+ @context.stacks[:exec].peek.listing.should == "do int_add"
85
+ end
86
+ end
87
+ end
88
+ end
89
+
90
+
91
+ describe ExecSInstruction do
92
+ before(:each) do
93
+ @context = Interpreter.new
94
+ @i1 = ExecSInstruction.new(@context)
95
+ end
96
+
97
+ it "should have the right context" do
98
+ @i1.context.should == @context
99
+ end
100
+
101
+ [:preconditions?, :setup, :derive, :cleanup].each do |methodName|
102
+ it "should respond to \##{methodName}" do
103
+ @i1.should respond_to(methodName)
104
+ end
105
+ end
106
+
107
+ describe "\#go" do
108
+ before(:each) do
109
+ @context = Interpreter.new
110
+ @i1 = ExecSInstruction.new(@context)
111
+ @context.reset("block { do int_add do int_subtract do int_multiply}")
112
+ @context.step # unwrapping the three instructions
113
+ end
114
+
115
+ describe "\#preconditions?" do
116
+ it "should check that the :exec stack has at least three items" do
117
+ @i1.preconditions?.should == true
118
+ end
119
+ end
120
+
121
+ describe "\#cleanup" do
122
+ it "should result in the top one [replaced], the old 3rd one, then a block with the 2nd and 3rd" do
123
+ @context.stacks[:exec].depth.should == 3
124
+ @i1.go
125
+ @context.stacks[:exec].depth.should == 3
126
+ @context.stacks[:exec].entries[2].listing.should == "do int_add" # old top one
127
+ @context.stacks[:exec].entries[1].listing.should == "do int_multiply" # old 3rd one
128
+ @context.stacks[:exec].entries[0].listing.should == "block {do int_subtract do int_multiply}"
129
+ end
130
+ end
131
+ end
132
+ end
133
+
134
+
135
+
136
+ describe ExecPopInstruction do
137
+ before(:each) do
138
+ @context = Interpreter.new
139
+ @i1 = ExecPopInstruction.new(@context)
140
+ end
141
+
142
+ it "should have the right context" do
143
+ @i1.context.should == @context
144
+ end
145
+
146
+ [:preconditions?, :setup, :derive, :cleanup].each do |methodName|
147
+ it "should respond to \##{methodName}" do
148
+ @i1.should respond_to(methodName)
149
+ end
150
+ end
151
+
152
+ describe "\#go" do
153
+ before(:each) do
154
+ @context = Interpreter.new
155
+ @i1 = ExecPopInstruction.new(@context)
156
+ @context.reset("block {literal float(-2.1)\nliteral float(-2.1)}")
157
+ end
158
+
159
+ describe "\#preconditions?" do
160
+ it "should check that the :exec stack has at least one item" do
161
+ @i1.preconditions?.should == true
162
+ end
163
+ end
164
+
165
+ describe "\#cleanup" do
166
+ it "should remove one item from the stack" do
167
+ @context.step
168
+ @context.stacks[:exec].depth.should == 2
169
+ @i1.go
170
+ @context.stacks[:exec].depth.should == 1
171
+ end
172
+ end
173
+ end
174
+ end
175
+
176
+
177
+ describe ExecDuplicateInstruction do
178
+ before(:each) do
179
+ @context = Interpreter.new
180
+ @i1 = ExecDuplicateInstruction.new(@context)
181
+ end
182
+
183
+ it "should have the right context" do
184
+ @i1.context.should == @context
185
+ end
186
+
187
+ [:preconditions?, :setup, :derive, :cleanup].each do |methodName|
188
+ it "should respond to \##{methodName}" do
189
+ @i1.should respond_to(methodName)
190
+ end
191
+ end
192
+
193
+ describe "\#go" do
194
+ before(:each) do
195
+ @myInterpreter = Interpreter.new
196
+ @i1 = ExecDuplicateInstruction.new(@myInterpreter)
197
+ @myInterpreter.reset("literal bool(false)")
198
+ end
199
+
200
+ describe "\#preconditions?" do
201
+ it "should check that the :exec stack has at least one item" do
202
+ @i1.preconditions?.should == true
203
+ end
204
+ end
205
+
206
+ describe "\#cleanup" do
207
+ it "should push a copy of the top item onto the :exec stack" do
208
+ @i1.go
209
+ @myInterpreter.stacks[:exec].depth.should == 2
210
+ @myInterpreter.stacks[:exec].entries[0].value.should == @myInterpreter.stacks[:exec].entries[1].value
211
+ end
212
+
213
+ it "should not be the same objectID, just in case" do
214
+ @i1.go
215
+ id1 = @myInterpreter.stacks[:exec].entries[0].object_id
216
+ id2 = @myInterpreter.stacks[:exec].entries[1].object_id
217
+ id1.should_not == id2
218
+ end
219
+ end
220
+ end
221
+ end
222
+
223
+
224
+ describe ExecSwapInstruction do
225
+ before(:each) do
226
+ @context = Interpreter.new
227
+ @i1 = ExecSwapInstruction.new(@context)
228
+ end
229
+
230
+ it "should have the right context" do
231
+ @i1.context.should == @context
232
+ end
233
+
234
+ [:preconditions?, :setup, :derive, :cleanup].each do |methodName|
235
+ it "should respond to \##{methodName}" do
236
+ @i1.should respond_to(methodName)
237
+ end
238
+ end
239
+
240
+ describe "\#go" do
241
+ before(:each) do
242
+ @myInterpreter = Interpreter.new
243
+ @i1 = ExecSwapInstruction.new(@myInterpreter)
244
+ @myInterpreter.reset("block{literal bool(false) literal int(88)}")
245
+ @myInterpreter.step # [pushing the two points]
246
+ end
247
+
248
+ describe "\#preconditions?" do
249
+ it "should check that the :exec stack has at least one item" do
250
+ @i1.preconditions?.should == true
251
+ end
252
+ end
253
+
254
+ describe "\#cleanup" do
255
+ it "should push a copy of the top item onto the :exec stack" do
256
+ @myInterpreter.stacks[:exec].entries[0].value.should == 88
257
+ @myInterpreter.stacks[:exec].entries[1].value.should == false
258
+ @i1.go
259
+ @myInterpreter.stacks[:exec].depth.should == 2
260
+ @myInterpreter.stacks[:exec].entries[0].value.should == false
261
+ @myInterpreter.stacks[:exec].entries[1].value.should == 88
262
+ end
263
+ end
264
+ end
265
+ end
266
+
267
+
268
+ describe ExecDepthInstruction do
269
+ before(:each) do
270
+ @context = Interpreter.new
271
+ @i1 = ExecDepthInstruction.new(@context)
272
+ end
273
+
274
+ it "should have its context set" do
275
+ @i1.context.should == @context
276
+ end
277
+
278
+ [:preconditions?, :setup, :derive, :cleanup].each do |methodName|
279
+ it "should respond to \##{methodName}" do
280
+ @i1.should respond_to(methodName)
281
+ end
282
+ end
283
+
284
+ describe "\#go" do
285
+ before(:each) do
286
+ @i1 = ExecDepthInstruction.new(@context)
287
+ @context.reset("block{literal bool(false) literal int(88) block {}}")
288
+ end
289
+
290
+ describe "\#preconditions?" do
291
+ it "should check that the :bool stack responds to #depth" do
292
+ @i1.preconditions?.should == true
293
+ end
294
+ end
295
+
296
+ describe "\#cleanup" do
297
+ it "should count the items on the stack and push it onto the :int stack" do
298
+ @context.stacks[:int].depth.should == 0
299
+ @i1.go
300
+ @context.stacks[:int].peek.value.should == 1
301
+ @context.step # unpacking the three points onto :exec
302
+ @i1.go
303
+ @context.stacks[:int].peek.value.should == 3
304
+ end
305
+ end
306
+ end
307
+ end
308
+
309
+
310
+
311
+ describe ExecFlushInstruction do
312
+ before(:each) do
313
+ @context = Interpreter.new
314
+ @i1 = ExecFlushInstruction.new(@context)
315
+ end
316
+
317
+ it "should have a context upon creation" do
318
+ @i1.context.should == @context
319
+ end
320
+
321
+ [:preconditions?, :setup, :derive, :cleanup].each do |methodName|
322
+ it "should respond to \##{methodName}" do
323
+ @i1.should respond_to(methodName)
324
+ end
325
+ end
326
+
327
+ describe "\#go" do
328
+ before(:each) do
329
+ @i1 = ExecFlushInstruction.new(@context)
330
+ @context.reset("block{literal bool(false) literal int(88) block {}}")
331
+ end
332
+
333
+ describe "\#preconditions?" do
334
+ it "should check that the :exec stack responds to #depth" do
335
+ @i1.preconditions?.should == true
336
+ end
337
+ end
338
+
339
+ describe "\#cleanup" do
340
+ it "should remove all items on the :exec stack" do
341
+ @context.step
342
+ @context.stacks[:exec].depth.should == 3
343
+ @i1.go
344
+ @context.stacks[:exec].depth.should == 0
345
+ end
346
+ end
347
+ end
348
+ end
349
+
350
+
351
+ describe ExecRotateInstruction do
352
+ before(:each) do
353
+ @context = Interpreter.new
354
+ @i1 = ExecRotateInstruction.new(@context)
355
+ end
356
+
357
+ it "should have the right context" do
358
+ @i1.context.should == @context
359
+ end
360
+
361
+ [:preconditions?, :setup, :derive, :cleanup].each do |methodName|
362
+ it "should respond to \##{methodName}" do
363
+ @i1.should respond_to(methodName)
364
+ end
365
+ end
366
+
367
+ describe "\#go" do
368
+ before(:each) do
369
+ @context = Interpreter.new
370
+ @i1 = ExecRotateInstruction.new(@context)
371
+ @context.reset("block{literal bool(false) literal int(88) literal float(0.5)}")
372
+ @context.step # [pushing the 3 points]
373
+ end
374
+
375
+ describe "\#preconditions?" do
376
+ it "should check that the :exec stack has at least one item" do
377
+ @i1.preconditions?.should == true
378
+ end
379
+ end
380
+
381
+ describe "\#cleanup" do
382
+ it "should rearrange the three items on the :exec stack" do
383
+ and_now = @context.stacks[:exec].entries.collect {|i| i.value}
384
+ and_now.should == [0.5, 88, false] # because the stacks are "backwards" in array form
385
+ @i1.go
386
+ and_now = @context.stacks[:exec].entries.collect {|i| i.value}
387
+ and_now.should == [88, false, 0.5] # bottom one comes to top
388
+ end
389
+ end
390
+ end
391
+ end
392
+
393
+
394
+ describe ExecYankdupInstruction do
395
+ before(:each) do
396
+ @context = Interpreter.new
397
+ @i1 = ExecYankdupInstruction.new(@context)
398
+ end
399
+
400
+ it "should check its context is set" do
401
+ @i1.context.should == @context
402
+ end
403
+
404
+ [:preconditions?, :setup, :derive, :cleanup].each do |methodName|
405
+ it "should respond to \##{methodName}" do
406
+ @i1.should respond_to(methodName)
407
+ end
408
+ end
409
+
410
+ describe "\#go" do
411
+ before(:each) do
412
+ @context.clear_stacks
413
+ @i1 = ExecYankdupInstruction.new(@context)
414
+ end
415
+
416
+ describe "\#preconditions?" do
417
+ it "should check that there is one :int and at least one :exec item" do
418
+ @context.reset("block {}")
419
+ @context.stacks[:int].push(LiteralPoint.new("int",2))
420
+ @i1.preconditions?.should == true
421
+ end
422
+ end
423
+
424
+ describe "\#cleanup" do
425
+ before(:each) do
426
+ @context.clear_stacks
427
+ (1..3).each {|i| @context.stacks[:exec].push(LiteralPoint.new("float",i*1.0))}
428
+ end
429
+
430
+ it "should duplicate the top item if the position integer is negative" do
431
+ @context.stacks[:int].push(LiteralPoint.new("int", -99))
432
+ @i1.go
433
+ and_now = @context.stacks[:exec].entries.collect {|i| i.value}
434
+ and_now.should == [1.0,2.0,3.0,3.0]
435
+ end
436
+
437
+ it "should duplicate the top item if the position integer is zero" do
438
+ @context.stacks[:int].push(LiteralPoint.new("int", 0))
439
+ @i1.go
440
+ and_now = @context.stacks[:exec].entries.collect {|i| i.value}
441
+ and_now.should == [1.0,2.0,3.0, 3.0]
442
+ end
443
+
444
+ it "should clone the bottom item and push it if the position is more than the stackdepth" do
445
+ @context.stacks[:int].push(LiteralPoint.new("int", 1000))
446
+ @i1.go
447
+ and_now = @context.stacks[:exec].entries.collect {|i| i.value}
448
+ and_now.should == [1.0,2.0,3.0, 1.0]
449
+ end
450
+
451
+ it "should push a copy of the indicated item to the top of the stack, counting from the 'top down'" do
452
+ @context.stacks[:int].push(LiteralPoint.new("int", 2))
453
+ @i1.go
454
+ and_now = @context.stacks[:exec].entries.collect {|i| i.value}
455
+ and_now.should == [1.0,2.0,3.0, 1.0]
456
+
457
+ @context.stacks[:int].push(LiteralPoint.new("int", 2))
458
+ @i1.go
459
+ and_now = @context.stacks[:exec].entries.collect {|i| i.value}
460
+ and_now.should == [1.0,2.0,3.0, 1.0, 2.0]
461
+ end
462
+ end
463
+ end
464
+ end
465
+
466
+
467
+ describe ExecYankInstruction do
468
+ before(:each) do
469
+ @context = Interpreter.new
470
+ @i1 = ExecYankInstruction.new(@context)
471
+ end
472
+
473
+ it "should check its context is set" do
474
+ @i1.context.should == @context
475
+ end
476
+
477
+ [:preconditions?, :setup, :derive, :cleanup].each do |methodName|
478
+ it "should respond to \##{methodName}" do
479
+ @i1.should respond_to(methodName)
480
+ end
481
+ end
482
+
483
+ describe "\#go" do
484
+ before(:each) do
485
+ @i1 = ExecYankInstruction.new(@context)
486
+ @context.clear_stacks
487
+ @int1 = LiteralPoint.new("int", 3)
488
+ end
489
+
490
+ describe "\#preconditions?" do
491
+ it "should check that there is one :int and at least one more :int" do
492
+ @context.stacks[:exec].push(LiteralPoint.new("float", -99.99))
493
+ @context.stacks[:int].push(@int1)
494
+ @i1.preconditions?.should == true
495
+ end
496
+ end
497
+
498
+ describe "\#cleanup" do
499
+ before(:each) do
500
+ @context.clear_stacks
501
+ (1..3).each {|i| @context.stacks[:exec].push(LiteralPoint.new("float",i*0.5))}
502
+ end
503
+
504
+ it "should not change anything if the position integer is negative" do
505
+ @context.stacks[:int].push(LiteralPoint.new("int", -99))
506
+ @i1.go
507
+ and_now = @context.stacks[:exec].entries.collect {|i| i.value}
508
+ and_now.should == [0.5,1.0,1.5]
509
+ end
510
+
511
+ it "should not change anything if the position integer is zero" do
512
+ @context.stacks[:int].push(LiteralPoint.new("int", 0))
513
+ @i1.go
514
+ and_now = @context.stacks[:exec].entries.collect {|i| i.value}
515
+ and_now.should == [0.5,1.0,1.5]
516
+ end
517
+
518
+ it "should pull the last item on the stack to the top if the position is more than the stackdepth" do
519
+ @context.stacks[:int].push(LiteralPoint.new("int", 1000))
520
+ @i1.go
521
+ and_now = @context.stacks[:exec].entries.collect {|i| i.value}
522
+ and_now.should == [1.0,1.5, 0.5]
523
+ end
524
+
525
+ it "should yank the indicated item to the top of the stack, counting from the 'top' 'down'" do
526
+ @context.stacks[:int].push(LiteralPoint.new("int", 1))
527
+ @i1.go
528
+ and_now = @context.stacks[:exec].entries.collect {|i| i.value}
529
+ and_now.should == [0.5,1.5, 1.0]
530
+ end
531
+ end
532
+ end
533
+ end
534
+
535
+
536
+ describe ExecShoveInstruction do
537
+ before(:each) do
538
+ @context = Interpreter.new
539
+ @i1 = ExecShoveInstruction.new(@context)
540
+ end
541
+
542
+ it "should check its context is set" do
543
+ @i1.context.should == @context
544
+ end
545
+
546
+ [:preconditions?, :setup, :derive, :cleanup].each do |methodName|
547
+ it "should respond to \##{methodName}" do
548
+ @i1.should respond_to(methodName)
549
+ end
550
+ end
551
+
552
+ describe "\#go" do
553
+ before(:each) do
554
+ @i1 = ExecShoveInstruction.new(@context)
555
+ @context.clear_stacks
556
+ @float1 = LiteralPoint.new("float", 9.9)
557
+ end
558
+
559
+ describe "\#preconditions?" do
560
+ it "should check that there is one :int and at least one :float" do
561
+ @context.stacks[:int].push(LiteralPoint.new("int", 4))
562
+ @context.stacks[:exec].push(@float1)
563
+ @i1.preconditions?.should == true
564
+ end
565
+ end
566
+
567
+ describe "\#cleanup" do
568
+ before(:each) do
569
+ @context.clear_stacks
570
+ 11.times {@context.stacks[:exec].push(@float1)}
571
+ @context.stacks[:exec].push(LiteralPoint.new("float", 1.1)) # making it 12 deep
572
+ end
573
+
574
+ it "should not move the top item if the integer is negative" do
575
+ @context.stacks[:int].push(LiteralPoint.new("int", -99))
576
+ @i1.go
577
+ @context.stacks[:exec].depth.should == 12
578
+ @context.stacks[:exec].peek.value.should == 1.1
579
+ end
580
+
581
+ it "should not move the top item if the integer is zero" do
582
+ @context.stacks[:int].push(LiteralPoint.new("int", 0))
583
+ @i1.go
584
+ @context.stacks[:exec].depth.should == 12
585
+ @context.stacks[:exec].peek.value.should == 1.1
586
+ end
587
+
588
+ it "should move the top item farther down if the value is less than the depth" do
589
+ @context.stacks[:int].push(LiteralPoint.new("int", 1000))
590
+ @i1.go
591
+ @context.stacks[:exec].depth.should == 12
592
+ @context.stacks[:exec].entries[0].value.should == 1.1
593
+ end
594
+
595
+ it "should move the top item to the bottom if the value is more than the depth" do
596
+ @context.stacks[:int].push(LiteralPoint.new("int", 4))
597
+ @i1.go
598
+ @context.stacks[:exec].depth.should == 12
599
+ @context.stacks[:exec].entries[11].value.should == 9.9
600
+ @context.stacks[:exec].entries[7].value.should == 1.1
601
+ end
602
+ end
603
+ end
604
+ end
605
+
606
+
607
+ describe ExecDoRangeInstruction do
608
+ before(:each) do
609
+ @context = Interpreter.new
610
+ @i1 = ExecDoRangeInstruction.new(@context)
611
+ end
612
+
613
+ it "should check its context is set" do
614
+ @i1.context.should == @context
615
+ end
616
+
617
+ [:preconditions?, :setup, :derive, :cleanup].each do |methodName|
618
+ it "should respond to \##{methodName}" do
619
+ @i1.should respond_to(methodName)
620
+ end
621
+ end
622
+
623
+ describe "\#go" do
624
+ before(:each) do
625
+ @i1 = ExecDoRangeInstruction.new(@context)
626
+ @context.reset("block {}")
627
+ @context.enable(ExecDoRangeInstruction)
628
+ end
629
+
630
+ describe "\#preconditions?" do
631
+ it "should check that there are two :ints and at least one :exec item" do
632
+ @context.stacks[:int].push(LiteralPoint.new("int", 3))
633
+ @context.stacks[:int].push(LiteralPoint.new("int", 3))
634
+ @i1.preconditions?.should == true
635
+ end
636
+ end
637
+
638
+ describe "\#cleanup" do
639
+ before(:each) do
640
+ @context.reset("block {}")
641
+ end
642
+
643
+ it "should finish if the :ints are identical, pushing an :int and a copy of the codeblock" do
644
+ @context.stacks[:int].push(LiteralPoint.new("int", 3))
645
+ @context.stacks[:int].push(LiteralPoint.new("int", 3))
646
+ @i1.go
647
+ @context.stacks[:int].depth.should == 1
648
+ @context.stacks[:int].peek.value.should == 3
649
+ @context.stacks[:exec].depth.should == 1
650
+ @context.stacks[:exec].peek.listing.should == "block {}"
651
+ end
652
+
653
+ it "should increment the counter if the counter < destination, and push a bunch of stuff" do
654
+ @context.stacks[:int].push(LiteralPoint.new("int", 1))
655
+ @context.stacks[:int].push(LiteralPoint.new("int", 3))
656
+ @i1.go
657
+
658
+ @context.stacks[:int].depth.should == 1
659
+ @context.stacks[:int].peek.value.should == 1
660
+ @context.stacks[:exec].depth.should == 2
661
+ @context.stacks[:exec].entries[1].listing.should == "block {}"
662
+ @context.stacks[:exec].entries[0].listing.should == "block {\n literal int (2)\n literal int (3)\n do exec_do_range\n block {}}"
663
+
664
+ 5.times {@context.step} # block {}; unwrap; push counter; push dest; run exec_do_range
665
+
666
+ @context.stacks[:int].depth.should == 2
667
+ @context.stacks[:int].peek.value.should == 2
668
+
669
+ @context.stacks[:exec].depth.should == 2
670
+ @context.stacks[:exec].entries[1].listing.should == "block {}"
671
+ @context.stacks[:exec].entries[0].listing.should == "block {\n literal int (3)\n literal int (3)\n do exec_do_range\n block {}}"
672
+ end
673
+
674
+ it "should decrement the counter if the counter > destination, and push a bunch of stuff" do
675
+ @context.stacks[:int].push(LiteralPoint.new("int", -2))
676
+ @context.stacks[:int].push(LiteralPoint.new("int", -19))
677
+ @i1.go
678
+
679
+ @context.stacks[:int].depth.should == 1
680
+ @context.stacks[:int].peek.value.should == -2
681
+ @context.stacks[:exec].depth.should == 2
682
+ @context.stacks[:exec].entries[1].listing.should == "block {}"
683
+ @context.stacks[:exec].entries[0].listing.should == "block {\n literal int (-3)\n literal int (-19)\n do exec_do_range\n block {}}"
684
+
685
+ 5.times {@context.step} # block {}; unwrap; push counter; push dest; run exec_do_range
686
+
687
+ @context.stacks[:int].depth.should == 2
688
+ @context.stacks[:int].peek.value.should == -3
689
+
690
+ @context.stacks[:exec].depth.should == 2
691
+ @context.stacks[:exec].entries[1].listing.should == "block {}"
692
+ @context.stacks[:exec].entries[0].listing.should == "block {\n literal int (-4)\n literal int (-19)\n do exec_do_range\n block {}}"
693
+ end
694
+
695
+ it "should 'continue' until counter and destination are the same value" do
696
+ @context.stacks[:int].push(LiteralPoint.new("int", 1))
697
+ @context.stacks[:int].push(LiteralPoint.new("int", 100))
698
+ @i1.go
699
+ @context.run # finish it off
700
+ @context.stacks[:int].depth.should == 100
701
+ @context.stacks[:exec].depth.should == 0
702
+ end
703
+ end
704
+ end
705
+ end
706
+
707
+
708
+ # EXEC.DO*TIMES: Like EXEC.DO*COUNT but does not push the loop counter. This should be implemented as a macro that expands into EXEC.DO*RANGE, similarly to the implementation of EXEC.DO*COUNT, except that a call to INTEGER.POP should be tacked on to the front of the loop body code in the call to EXEC.DO*RANGE. This call to INTEGER.POP will remove the loop counter, which will have been pushed by EXEC.DO*RANGE, prior to the execution of the loop body.
709
+
710
+
711
+ describe ExecDoTimesInstruction do
712
+ before(:each) do
713
+ @context = Interpreter.new
714
+ @i1 = ExecDoTimesInstruction.new(@context)
715
+ end
716
+
717
+ it "should check its context is set" do
718
+ @i1.context.should == @context
719
+ end
720
+
721
+ [:preconditions?, :setup, :derive, :cleanup].each do |methodName|
722
+ it "should respond to \##{methodName}" do
723
+ @i1.should respond_to(methodName)
724
+ end
725
+ end
726
+
727
+ describe "\#go" do
728
+ before(:each) do
729
+ @i1 = ExecDoTimesInstruction.new(@context)
730
+ @context.reset("block {}")
731
+ @context.enable(ExecDoTimesInstruction)
732
+ end
733
+
734
+ describe "\#preconditions?" do
735
+ it "should check that there are two :ints and at least one :exec item" do
736
+ @context.stacks[:int].push(LiteralPoint.new("int", 3))
737
+ @context.stacks[:int].push(LiteralPoint.new("int", 3))
738
+ @i1.preconditions?.should == true
739
+ end
740
+ end
741
+
742
+ describe "\#cleanup" do
743
+ before(:each) do
744
+ @context.reset("block {}")
745
+ end
746
+
747
+ it "should finish if the :ints are identical, leaving only a copy of the codeblock" do
748
+ @context.stacks[:int].push(LiteralPoint.new("int", 3))
749
+ @context.stacks[:int].push(LiteralPoint.new("int", 3))
750
+ @i1.go
751
+ @context.stacks[:int].depth.should == 0
752
+ @context.stacks[:exec].depth.should == 1
753
+ @context.stacks[:exec].peek.listing.should == "block {}"
754
+ end
755
+
756
+ it "should increment the counter if the counter < destination, and push a bunch of stuff" do
757
+ @context.stacks[:int].push(LiteralPoint.new("int", 1))
758
+ @context.stacks[:int].push(LiteralPoint.new("int", 3))
759
+ @i1.go
760
+
761
+ @context.stacks[:int].depth.should == 0
762
+ @context.stacks[:exec].depth.should == 2
763
+ @context.stacks[:exec].entries[1].listing.should == "block {}"
764
+ @context.stacks[:exec].entries[0].listing.should == "block {\n literal int (2)\n literal int (3)\n do exec_do_times\n block {}}"
765
+
766
+ 5.times {@context.step} # block {}; unwrap; push counter; push dest; run exec_do_range
767
+
768
+ @context.stacks[:int].depth.should == 0
769
+ @context.stacks[:exec].depth.should == 2
770
+ @context.stacks[:exec].entries[1].listing.should == "block {}"
771
+ @context.stacks[:exec].entries[0].listing.should == "block {\n literal int (3)\n literal int (3)\n do exec_do_times\n block {}}"
772
+ end
773
+
774
+ it "should decrement the counter if the counter > destination, and push a bunch of stuff" do
775
+ @context.reset("literal float (0.1)")
776
+ @context.stacks[:int].push(LiteralPoint.new("int", -2))
777
+ @context.stacks[:int].push(LiteralPoint.new("int", -19))
778
+ @i1.go
779
+
780
+ @context.stacks[:int].depth.should == 0
781
+ @context.stacks[:exec].depth.should == 2
782
+ @context.stacks[:exec].entries[1].listing.should == "literal float (0.1)"
783
+ @context.stacks[:exec].entries[0].listing.should == "block {\n literal int (-3)\n literal int (-19)\n do exec_do_times\n literal float (0.1)}"
784
+
785
+ 5.times {@context.step} # block {}; unwrap; push counter; push dest; run exec_do_times
786
+
787
+ @context.stacks[:int].depth.should == 0
788
+ @context.stacks[:float].depth.should == 1
789
+ @context.stacks[:exec].depth.should == 2
790
+ @context.stacks[:exec].entries[1].listing.should == "literal float (0.1)"
791
+ @context.stacks[:exec].entries[0].listing.should == "block {\n literal int (-4)\n literal int (-19)\n do exec_do_times\n literal float (0.1)}"
792
+ end
793
+
794
+ it "should 'continue' until counter and destination are the same value" do
795
+ @context.reset("literal float (0.1)")
796
+ @context.stacks[:int].push(LiteralPoint.new("int", 1))
797
+ @context.stacks[:int].push(LiteralPoint.new("int", 100))
798
+ @i1.go
799
+ @context.run # finish it off
800
+ @context.stacks[:float].depth.should == 100
801
+ @context.stacks[:exec].depth.should == 0
802
+ end
803
+ end
804
+ end
805
+ end
806
+
807
+
808
+ # EXEC.DO*COUNT: An iteration instruction that performs a loop (the body of which is taken from the EXEC stack) the number of times indicated by the INTEGER argument, pushing an index (which runs from zero to one less than the number of iterations) onto the INTEGER stack prior to each execution of the loop body. This is similar to CODE.DO*COUNT except that it takes its code argument from the EXEC stack. This should be implemented as a macro that expands into a call to EXEC.DO*RANGE. EXEC.DO*COUNT takes a single INTEGER argument (the number of times that the loop will be executed) and a single EXEC argument (the body of the loop). If the provided INTEGER argument is negative or zero then this becomes a NOOP. Otherwise it expands into: ( 0 <1 - IntegerArg> EXEC.DO*RANGE <ExecArg> )
809
+
810
+
811
+ describe ExecDoCountInstruction do
812
+ before(:each) do
813
+ @context = Interpreter.new
814
+ @i1 = ExecDoCountInstruction.new(@context)
815
+ end
816
+
817
+ it "should check its context is set" do
818
+ @i1.context.should == @context
819
+ end
820
+
821
+ [:preconditions?, :setup, :derive, :cleanup].each do |methodName|
822
+ it "should respond to \##{methodName}" do
823
+ @i1.should respond_to(methodName)
824
+ end
825
+ end
826
+
827
+ describe "\#go" do
828
+ before(:each) do
829
+ @i1 = ExecDoCountInstruction.new(@context)
830
+ @context.reset("block {}")
831
+ @context.enable(ExecDoCountInstruction)
832
+ @context.enable(ExecDoRangeInstruction)
833
+ end
834
+
835
+ describe "\#preconditions?" do
836
+ it "should check that there are two :ints and at least one :exec item" do
837
+ @context.stacks[:int].push(LiteralPoint.new("int", 3))
838
+ @context.stacks[:int].push(LiteralPoint.new("int", 3))
839
+ @context.enable(ExecDoRangeInstruction)
840
+ @i1.preconditions?.should == true
841
+ end
842
+
843
+ it "should check that the @context knows about exec_do_range" do
844
+ @context.disable(ExecDoRangeInstruction)
845
+ @context.stacks[:int].push(LiteralPoint.new("int", 3))
846
+ @context.stacks[:int].push(LiteralPoint.new("int", 3))
847
+ lambda{@i1.preconditions?}.should raise_error
848
+ end
849
+ end
850
+
851
+ describe "\#cleanup" do
852
+ before(:each) do
853
+ @context.reset("block {}")
854
+ @context.enable(ExecDoRangeInstruction)
855
+ end
856
+
857
+ it "should not work if the int is negative or zero" do
858
+ @context.stacks[:int].push(LiteralPoint.new("int", -213))
859
+ @i1.go
860
+ @context.stacks[:int].depth.should == 1
861
+ @context.stacks[:exec].depth.should == 1
862
+ @context.stacks[:exec].peek.listing.should == "block {}"
863
+
864
+ @context.reset("block {}")
865
+ @context.stacks[:int].push(LiteralPoint.new("int", 0))
866
+ @i1.go
867
+ @context.stacks[:int].depth.should == 1
868
+ @context.stacks[:exec].depth.should == 1
869
+ @context.stacks[:exec].peek.listing.should == "block {}"
870
+ end
871
+
872
+ it "should push a 0 onto :int, and an exec_do_range block onto :exec" do
873
+ @context.stacks[:int].push(LiteralPoint.new("int", 3))
874
+ @i1.go
875
+
876
+ @context.stacks[:int].depth.should == 0
877
+ @context.stacks[:exec].depth.should == 1
878
+ res = "block {\n literal int (0)\n literal int (2)\n do exec_do_range\n block {}}"
879
+ @context.stacks[:exec].entries[0].listing.should == res
880
+ end
881
+ end
882
+ end
883
+ end