nudge 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +5 -0
- data/LICENSE.txt +21 -0
- data/Rakefile +23 -0
- data/VERSION +1 -0
- data/_spikes/couch_document_spike.rb +24 -0
- data/_spikes/nested_parsing/nested.rb +0 -0
- data/_spikes/nested_parsing/nested.treetop +6 -0
- data/_spikes/nudgeview/init.rb +19 -0
- data/_spikes/nudgeview/public/javascripts/app.js +12 -0
- data/_spikes/nudgeview/public/javascripts/jquery.js +4376 -0
- data/_spikes/nudgeview/public/javascripts/jquery.svg.js +1325 -0
- data/_spikes/nudgeview/views/index.erb +18 -0
- data/_spikes/nudgeview/views/index.haml +8 -0
- data/_spikes/simplestWeb/simplest.rb +44 -0
- data/_spikes/simplestWeb/views/main.erb +19 -0
- data/_spikes/sketches/nudgecode_spike.rb +146 -0
- data/_spikes/sketches/searchDSL_spike.rb +25 -0
- data/_spikes/sketches/search_operator_sketch_spike.txt +287 -0
- data/_spikes/sketches/searchspace_spike.rb +96 -0
- data/_spikes/symbolic_regression/activate.rb +35 -0
- data/_spikes/symbolic_regression/config/environment.rb +340 -0
- data/_spikes/symbolic_regression/config/environments/deployment.rb +0 -0
- data/_spikes/symbolic_regression/config/environments/development.rb +0 -0
- data/_spikes/symbolic_regression/experiment/objectives/programLength.rb +2 -0
- data/_spikes/symbolic_regression/experiment/objectives/summedSquaredError.rb +2 -0
- data/_spikes/symbolic_regression/lib/tasks/run.rake +0 -0
- data/doc/classes/BlockNode.html +146 -0
- data/doc/classes/BlockNode.src/M000246.html +18 -0
- data/doc/classes/BoolAndInstruction.html +218 -0
- data/doc/classes/BoolAndInstruction.src/M000003.html +15 -0
- data/doc/classes/BoolAndInstruction.src/M000004.html +16 -0
- data/doc/classes/BoolAndInstruction.src/M000005.html +15 -0
- data/doc/classes/BoolAndInstruction.src/M000006.html +15 -0
- data/doc/classes/BoolEqualQInstruction.html +218 -0
- data/doc/classes/BoolEqualQInstruction.src/M000015.html +15 -0
- data/doc/classes/BoolEqualQInstruction.src/M000016.html +16 -0
- data/doc/classes/BoolEqualQInstruction.src/M000017.html +15 -0
- data/doc/classes/BoolEqualQInstruction.src/M000018.html +15 -0
- data/doc/classes/BoolFromFloatInstruction.html +218 -0
- data/doc/classes/BoolFromFloatInstruction.src/M000071.html +15 -0
- data/doc/classes/BoolFromFloatInstruction.src/M000072.html +15 -0
- data/doc/classes/BoolFromFloatInstruction.src/M000073.html +15 -0
- data/doc/classes/BoolFromFloatInstruction.src/M000074.html +15 -0
- data/doc/classes/BoolFromIntInstruction.html +218 -0
- data/doc/classes/BoolFromIntInstruction.src/M000067.html +15 -0
- data/doc/classes/BoolFromIntInstruction.src/M000068.html +15 -0
- data/doc/classes/BoolFromIntInstruction.src/M000069.html +15 -0
- data/doc/classes/BoolFromIntInstruction.src/M000070.html +15 -0
- data/doc/classes/BoolNotInstruction.html +218 -0
- data/doc/classes/BoolNotInstruction.src/M000019.html +15 -0
- data/doc/classes/BoolNotInstruction.src/M000020.html +15 -0
- data/doc/classes/BoolNotInstruction.src/M000021.html +15 -0
- data/doc/classes/BoolNotInstruction.src/M000022.html +15 -0
- data/doc/classes/BoolOrInstruction.html +218 -0
- data/doc/classes/BoolOrInstruction.src/M000007.html +15 -0
- data/doc/classes/BoolOrInstruction.src/M000008.html +16 -0
- data/doc/classes/BoolOrInstruction.src/M000009.html +15 -0
- data/doc/classes/BoolOrInstruction.src/M000010.html +15 -0
- data/doc/classes/BoolRandomInstruction.html +218 -0
- data/doc/classes/BoolRandomInstruction.src/M000187.html +15 -0
- data/doc/classes/BoolRandomInstruction.src/M000188.html +14 -0
- data/doc/classes/BoolRandomInstruction.src/M000189.html +15 -0
- data/doc/classes/BoolRandomInstruction.src/M000190.html +15 -0
- data/doc/classes/BoolType.html +196 -0
- data/doc/classes/BoolType.src/M000240.html +16 -0
- data/doc/classes/BoolType.src/M000241.html +15 -0
- data/doc/classes/BoolType.src/M000242.html +15 -0
- data/doc/classes/BoolXorInstruction.html +218 -0
- data/doc/classes/BoolXorInstruction.src/M000011.html +15 -0
- data/doc/classes/BoolXorInstruction.src/M000012.html +16 -0
- data/doc/classes/BoolXorInstruction.src/M000013.html +15 -0
- data/doc/classes/BoolXorInstruction.src/M000014.html +15 -0
- data/doc/classes/ChannelNode.html +161 -0
- data/doc/classes/ChannelNode.src/M000249.html +15 -0
- data/doc/classes/ChannelNode.src/M000250.html +16 -0
- data/doc/classes/CodeType.html +269 -0
- data/doc/classes/CodeType.src/M000219.html +38 -0
- data/doc/classes/CodeType.src/M000220.html +16 -0
- data/doc/classes/CodeType.src/M000221.html +16 -0
- data/doc/classes/CodeType.src/M000222.html +16 -0
- data/doc/classes/CodeType.src/M000223.html +24 -0
- data/doc/classes/CodeType.src/M000224.html +42 -0
- data/doc/classes/ERCNode.html +183 -0
- data/doc/classes/ERCNode.src/M000254.html +15 -0
- data/doc/classes/ERCNode.src/M000255.html +16 -0
- data/doc/classes/ERCNode.src/M000256.html +16 -0
- data/doc/classes/ExecPopInstruction.html +218 -0
- data/doc/classes/ExecPopInstruction.src/M000075.html +15 -0
- data/doc/classes/ExecPopInstruction.src/M000076.html +14 -0
- data/doc/classes/ExecPopInstruction.src/M000077.html +15 -0
- data/doc/classes/ExecPopInstruction.src/M000078.html +14 -0
- data/doc/classes/FloatAbsInstruction.html +218 -0
- data/doc/classes/FloatAbsInstruction.src/M000107.html +15 -0
- data/doc/classes/FloatAbsInstruction.src/M000108.html +15 -0
- data/doc/classes/FloatAbsInstruction.src/M000109.html +15 -0
- data/doc/classes/FloatAbsInstruction.src/M000110.html +15 -0
- data/doc/classes/FloatAddInstruction.html +218 -0
- data/doc/classes/FloatAddInstruction.src/M000079.html +15 -0
- data/doc/classes/FloatAddInstruction.src/M000080.html +16 -0
- data/doc/classes/FloatAddInstruction.src/M000081.html +15 -0
- data/doc/classes/FloatAddInstruction.src/M000082.html +15 -0
- data/doc/classes/FloatCosineInstruction.html +218 -0
- data/doc/classes/FloatCosineInstruction.src/M000123.html +15 -0
- data/doc/classes/FloatCosineInstruction.src/M000124.html +15 -0
- data/doc/classes/FloatCosineInstruction.src/M000125.html +15 -0
- data/doc/classes/FloatCosineInstruction.src/M000126.html +15 -0
- data/doc/classes/FloatDivideInstruction.html +218 -0
- data/doc/classes/FloatDivideInstruction.src/M000091.html +15 -0
- data/doc/classes/FloatDivideInstruction.src/M000092.html +16 -0
- data/doc/classes/FloatDivideInstruction.src/M000093.html +20 -0
- data/doc/classes/FloatDivideInstruction.src/M000094.html +15 -0
- data/doc/classes/FloatFromBoolInstruction.html +218 -0
- data/doc/classes/FloatFromBoolInstruction.src/M000055.html +15 -0
- data/doc/classes/FloatFromBoolInstruction.src/M000056.html +15 -0
- data/doc/classes/FloatFromBoolInstruction.src/M000057.html +15 -0
- data/doc/classes/FloatFromBoolInstruction.src/M000058.html +15 -0
- data/doc/classes/FloatFromIntInstruction.html +218 -0
- data/doc/classes/FloatFromIntInstruction.src/M000063.html +15 -0
- data/doc/classes/FloatFromIntInstruction.src/M000064.html +15 -0
- data/doc/classes/FloatFromIntInstruction.src/M000065.html +15 -0
- data/doc/classes/FloatFromIntInstruction.src/M000066.html +15 -0
- data/doc/classes/FloatGreaterThanQInstruction.html +218 -0
- data/doc/classes/FloatGreaterThanQInstruction.src/M000035.html +15 -0
- data/doc/classes/FloatGreaterThanQInstruction.src/M000036.html +16 -0
- data/doc/classes/FloatGreaterThanQInstruction.src/M000037.html +15 -0
- data/doc/classes/FloatGreaterThanQInstruction.src/M000038.html +15 -0
- data/doc/classes/FloatIfInstruction.html +218 -0
- data/doc/classes/FloatIfInstruction.src/M000047.html +16 -0
- data/doc/classes/FloatIfInstruction.src/M000048.html +15 -0
- data/doc/classes/FloatIfInstruction.src/M000049.html +14 -0
- data/doc/classes/FloatIfInstruction.src/M000050.html +17 -0
- data/doc/classes/FloatLessThanQInstruction.html +218 -0
- data/doc/classes/FloatLessThanQInstruction.src/M000039.html +15 -0
- data/doc/classes/FloatLessThanQInstruction.src/M000040.html +16 -0
- data/doc/classes/FloatLessThanQInstruction.src/M000041.html +15 -0
- data/doc/classes/FloatLessThanQInstruction.src/M000042.html +15 -0
- data/doc/classes/FloatMaxInstruction.html +218 -0
- data/doc/classes/FloatMaxInstruction.src/M000095.html +15 -0
- data/doc/classes/FloatMaxInstruction.src/M000096.html +16 -0
- data/doc/classes/FloatMaxInstruction.src/M000097.html +15 -0
- data/doc/classes/FloatMaxInstruction.src/M000098.html +15 -0
- data/doc/classes/FloatMinInstruction.html +218 -0
- data/doc/classes/FloatMinInstruction.src/M000099.html +15 -0
- data/doc/classes/FloatMinInstruction.src/M000100.html +16 -0
- data/doc/classes/FloatMinInstruction.src/M000101.html +15 -0
- data/doc/classes/FloatMinInstruction.src/M000102.html +15 -0
- data/doc/classes/FloatMultiplyInstruction.html +218 -0
- data/doc/classes/FloatMultiplyInstruction.src/M000083.html +15 -0
- data/doc/classes/FloatMultiplyInstruction.src/M000084.html +16 -0
- data/doc/classes/FloatMultiplyInstruction.src/M000085.html +15 -0
- data/doc/classes/FloatMultiplyInstruction.src/M000086.html +15 -0
- data/doc/classes/FloatNegativeInstruction.html +218 -0
- data/doc/classes/FloatNegativeInstruction.src/M000103.html +15 -0
- data/doc/classes/FloatNegativeInstruction.src/M000104.html +15 -0
- data/doc/classes/FloatNegativeInstruction.src/M000105.html +15 -0
- data/doc/classes/FloatNegativeInstruction.src/M000106.html +15 -0
- data/doc/classes/FloatPowerInstruction.html +218 -0
- data/doc/classes/FloatPowerInstruction.src/M000111.html +15 -0
- data/doc/classes/FloatPowerInstruction.src/M000112.html +16 -0
- data/doc/classes/FloatPowerInstruction.src/M000113.html +20 -0
- data/doc/classes/FloatPowerInstruction.src/M000114.html +15 -0
- data/doc/classes/FloatRandomInstruction.html +218 -0
- data/doc/classes/FloatRandomInstruction.src/M000191.html +15 -0
- data/doc/classes/FloatRandomInstruction.src/M000192.html +14 -0
- data/doc/classes/FloatRandomInstruction.src/M000193.html +15 -0
- data/doc/classes/FloatRandomInstruction.src/M000194.html +15 -0
- data/doc/classes/FloatSineInstruction.html +218 -0
- data/doc/classes/FloatSineInstruction.src/M000119.html +15 -0
- data/doc/classes/FloatSineInstruction.src/M000120.html +15 -0
- data/doc/classes/FloatSineInstruction.src/M000121.html +15 -0
- data/doc/classes/FloatSineInstruction.src/M000122.html +15 -0
- data/doc/classes/FloatSqrtInstruction.html +218 -0
- data/doc/classes/FloatSqrtInstruction.src/M000115.html +15 -0
- data/doc/classes/FloatSqrtInstruction.src/M000116.html +15 -0
- data/doc/classes/FloatSqrtInstruction.src/M000117.html +19 -0
- data/doc/classes/FloatSqrtInstruction.src/M000118.html +15 -0
- data/doc/classes/FloatSubtractInstruction.html +218 -0
- data/doc/classes/FloatSubtractInstruction.src/M000087.html +15 -0
- data/doc/classes/FloatSubtractInstruction.src/M000088.html +16 -0
- data/doc/classes/FloatSubtractInstruction.src/M000089.html +15 -0
- data/doc/classes/FloatSubtractInstruction.src/M000090.html +15 -0
- data/doc/classes/FloatTangentInstruction.html +218 -0
- data/doc/classes/FloatTangentInstruction.src/M000127.html +15 -0
- data/doc/classes/FloatTangentInstruction.src/M000128.html +15 -0
- data/doc/classes/FloatTangentInstruction.src/M000129.html +15 -0
- data/doc/classes/FloatTangentInstruction.src/M000130.html +15 -0
- data/doc/classes/FloatType.html +196 -0
- data/doc/classes/FloatType.src/M000243.html +19 -0
- data/doc/classes/FloatType.src/M000244.html +15 -0
- data/doc/classes/FloatType.src/M000245.html +15 -0
- data/doc/classes/Helpers.html +161 -0
- data/doc/classes/Helpers.src/M000343.html +21 -0
- data/doc/classes/Helpers.src/M000344.html +24 -0
- data/doc/classes/Instruction/InstructionMethodError.html +110 -0
- data/doc/classes/Instruction/NaNResultError.html +110 -0
- data/doc/classes/Instruction/NotEnoughStackItems.html +110 -0
- data/doc/classes/Instruction.html +500 -0
- data/doc/classes/Instruction.src/M000131.html +17 -0
- data/doc/classes/Instruction.src/M000132.html +15 -0
- data/doc/classes/Instruction.src/M000133.html +15 -0
- data/doc/classes/Instruction.src/M000134.html +15 -0
- data/doc/classes/Instruction.src/M000135.html +15 -0
- data/doc/classes/Instruction.src/M000136.html +15 -0
- data/doc/classes/Instruction.src/M000137.html +15 -0
- data/doc/classes/Instruction.src/M000138.html +15 -0
- data/doc/classes/Instruction.src/M000139.html +22 -0
- data/doc/classes/Instruction.src/M000140.html +15 -0
- data/doc/classes/Instruction.src/M000141.html +25 -0
- data/doc/classes/Instruction.src/M000142.html +15 -0
- data/doc/classes/Instruction.src/M000143.html +15 -0
- data/doc/classes/Instruction.src/M000144.html +15 -0
- data/doc/classes/Instruction.src/M000145.html +15 -0
- data/doc/classes/Instruction.src/M000146.html +15 -0
- data/doc/classes/InstructionNode.html +161 -0
- data/doc/classes/InstructionNode.src/M000247.html +15 -0
- data/doc/classes/InstructionNode.src/M000248.html +16 -0
- data/doc/classes/IntAbsInstruction.html +218 -0
- data/doc/classes/IntAbsInstruction.src/M000175.html +15 -0
- data/doc/classes/IntAbsInstruction.src/M000176.html +15 -0
- data/doc/classes/IntAbsInstruction.src/M000177.html +15 -0
- data/doc/classes/IntAbsInstruction.src/M000178.html +15 -0
- data/doc/classes/IntAddInstruction.html +218 -0
- data/doc/classes/IntAddInstruction.src/M000147.html +15 -0
- data/doc/classes/IntAddInstruction.src/M000148.html +16 -0
- data/doc/classes/IntAddInstruction.src/M000149.html +15 -0
- data/doc/classes/IntAddInstruction.src/M000150.html +15 -0
- data/doc/classes/IntDepthInstruction.html +218 -0
- data/doc/classes/IntDepthInstruction.src/M000211.html +15 -0
- data/doc/classes/IntDepthInstruction.src/M000212.html +14 -0
- data/doc/classes/IntDepthInstruction.src/M000213.html +15 -0
- data/doc/classes/IntDepthInstruction.src/M000214.html +15 -0
- data/doc/classes/IntDivideInstruction.html +218 -0
- data/doc/classes/IntDivideInstruction.src/M000155.html +15 -0
- data/doc/classes/IntDivideInstruction.src/M000156.html +16 -0
- data/doc/classes/IntDivideInstruction.src/M000157.html +20 -0
- data/doc/classes/IntDivideInstruction.src/M000158.html +15 -0
- data/doc/classes/IntDuplicateInstruction.html +218 -0
- data/doc/classes/IntDuplicateInstruction.src/M000203.html +15 -0
- data/doc/classes/IntDuplicateInstruction.src/M000204.html +15 -0
- data/doc/classes/IntDuplicateInstruction.src/M000205.html +15 -0
- data/doc/classes/IntDuplicateInstruction.src/M000206.html +15 -0
- data/doc/classes/IntEqualQInstruction.html +218 -0
- data/doc/classes/IntEqualQInstruction.src/M000023.html +15 -0
- data/doc/classes/IntEqualQInstruction.src/M000024.html +16 -0
- data/doc/classes/IntEqualQInstruction.src/M000025.html +15 -0
- data/doc/classes/IntEqualQInstruction.src/M000026.html +15 -0
- data/doc/classes/IntFlushInstruction.html +218 -0
- data/doc/classes/IntFlushInstruction.src/M000215.html +15 -0
- data/doc/classes/IntFlushInstruction.src/M000216.html +14 -0
- data/doc/classes/IntFlushInstruction.src/M000217.html +14 -0
- data/doc/classes/IntFlushInstruction.src/M000218.html +15 -0
- data/doc/classes/IntFromBoolInstruction.html +218 -0
- data/doc/classes/IntFromBoolInstruction.src/M000051.html +15 -0
- data/doc/classes/IntFromBoolInstruction.src/M000052.html +15 -0
- data/doc/classes/IntFromBoolInstruction.src/M000053.html +15 -0
- data/doc/classes/IntFromBoolInstruction.src/M000054.html +15 -0
- data/doc/classes/IntFromFloatInstruction.html +218 -0
- data/doc/classes/IntFromFloatInstruction.src/M000059.html +15 -0
- data/doc/classes/IntFromFloatInstruction.src/M000060.html +15 -0
- data/doc/classes/IntFromFloatInstruction.src/M000061.html +15 -0
- data/doc/classes/IntFromFloatInstruction.src/M000062.html +15 -0
- data/doc/classes/IntGreaterThanQInstruction.html +218 -0
- data/doc/classes/IntGreaterThanQInstruction.src/M000031.html +15 -0
- data/doc/classes/IntGreaterThanQInstruction.src/M000032.html +16 -0
- data/doc/classes/IntGreaterThanQInstruction.src/M000033.html +15 -0
- data/doc/classes/IntGreaterThanQInstruction.src/M000034.html +15 -0
- data/doc/classes/IntIfInstruction.html +218 -0
- data/doc/classes/IntIfInstruction.src/M000043.html +16 -0
- data/doc/classes/IntIfInstruction.src/M000044.html +15 -0
- data/doc/classes/IntIfInstruction.src/M000045.html +14 -0
- data/doc/classes/IntIfInstruction.src/M000046.html +17 -0
- data/doc/classes/IntLessThanQInstruction.html +218 -0
- data/doc/classes/IntLessThanQInstruction.src/M000027.html +15 -0
- data/doc/classes/IntLessThanQInstruction.src/M000028.html +16 -0
- data/doc/classes/IntLessThanQInstruction.src/M000029.html +15 -0
- data/doc/classes/IntLessThanQInstruction.src/M000030.html +15 -0
- data/doc/classes/IntMaxInstruction.html +218 -0
- data/doc/classes/IntMaxInstruction.src/M000167.html +15 -0
- data/doc/classes/IntMaxInstruction.src/M000168.html +16 -0
- data/doc/classes/IntMaxInstruction.src/M000169.html +16 -0
- data/doc/classes/IntMaxInstruction.src/M000170.html +15 -0
- data/doc/classes/IntMinInstruction.html +218 -0
- data/doc/classes/IntMinInstruction.src/M000171.html +15 -0
- data/doc/classes/IntMinInstruction.src/M000172.html +16 -0
- data/doc/classes/IntMinInstruction.src/M000173.html +16 -0
- data/doc/classes/IntMinInstruction.src/M000174.html +15 -0
- data/doc/classes/IntModuloInstruction.html +218 -0
- data/doc/classes/IntModuloInstruction.src/M000163.html +15 -0
- data/doc/classes/IntModuloInstruction.src/M000164.html +16 -0
- data/doc/classes/IntModuloInstruction.src/M000165.html +20 -0
- data/doc/classes/IntModuloInstruction.src/M000166.html +15 -0
- data/doc/classes/IntMultiplyInstruction.html +218 -0
- data/doc/classes/IntMultiplyInstruction.src/M000151.html +15 -0
- data/doc/classes/IntMultiplyInstruction.src/M000152.html +16 -0
- data/doc/classes/IntMultiplyInstruction.src/M000153.html +15 -0
- data/doc/classes/IntMultiplyInstruction.src/M000154.html +15 -0
- data/doc/classes/IntNegativeInstruction.html +218 -0
- data/doc/classes/IntNegativeInstruction.src/M000179.html +15 -0
- data/doc/classes/IntNegativeInstruction.src/M000180.html +15 -0
- data/doc/classes/IntNegativeInstruction.src/M000181.html +15 -0
- data/doc/classes/IntNegativeInstruction.src/M000182.html +15 -0
- data/doc/classes/IntPopInstruction.html +218 -0
- data/doc/classes/IntPopInstruction.src/M000195.html +15 -0
- data/doc/classes/IntPopInstruction.src/M000196.html +15 -0
- data/doc/classes/IntPopInstruction.src/M000197.html +14 -0
- data/doc/classes/IntPopInstruction.src/M000198.html +14 -0
- data/doc/classes/IntRandomInstruction.html +218 -0
- data/doc/classes/IntRandomInstruction.src/M000183.html +15 -0
- data/doc/classes/IntRandomInstruction.src/M000184.html +14 -0
- data/doc/classes/IntRandomInstruction.src/M000185.html +15 -0
- data/doc/classes/IntRandomInstruction.src/M000186.html +15 -0
- data/doc/classes/IntRotateInstruction.html +218 -0
- data/doc/classes/IntRotateInstruction.src/M000207.html +15 -0
- data/doc/classes/IntRotateInstruction.src/M000208.html +17 -0
- data/doc/classes/IntRotateInstruction.src/M000209.html +14 -0
- data/doc/classes/IntRotateInstruction.src/M000210.html +17 -0
- data/doc/classes/IntSubtractInstruction.html +218 -0
- data/doc/classes/IntSubtractInstruction.src/M000159.html +15 -0
- data/doc/classes/IntSubtractInstruction.src/M000160.html +16 -0
- data/doc/classes/IntSubtractInstruction.src/M000161.html +16 -0
- data/doc/classes/IntSubtractInstruction.src/M000162.html +15 -0
- data/doc/classes/IntSwapInstruction.html +218 -0
- data/doc/classes/IntSwapInstruction.src/M000199.html +15 -0
- data/doc/classes/IntSwapInstruction.src/M000200.html +16 -0
- data/doc/classes/IntSwapInstruction.src/M000201.html +14 -0
- data/doc/classes/IntSwapInstruction.src/M000202.html +16 -0
- data/doc/classes/IntType.html +240 -0
- data/doc/classes/IntType.src/M000235.html +15 -0
- data/doc/classes/IntType.src/M000236.html +15 -0
- data/doc/classes/IntType.src/M000237.html +18 -0
- data/doc/classes/IntType.src/M000238.html +15 -0
- data/doc/classes/IntType.src/M000239.html +15 -0
- data/doc/classes/LiteralNode.html +183 -0
- data/doc/classes/LiteralNode.src/M000251.html +15 -0
- data/doc/classes/LiteralNode.src/M000252.html +16 -0
- data/doc/classes/LiteralNode.src/M000253.html +16 -0
- data/doc/classes/Nudge/Channel.html +437 -0
- data/doc/classes/Nudge/Channel.src/M000286.html +15 -0
- data/doc/classes/Nudge/Channel.src/M000287.html +19 -0
- data/doc/classes/Nudge/Channel.src/M000288.html +15 -0
- data/doc/classes/Nudge/Channel.src/M000289.html +15 -0
- data/doc/classes/Nudge/Channel.src/M000290.html +15 -0
- data/doc/classes/Nudge/Channel.src/M000291.html +19 -0
- data/doc/classes/Nudge/Channel.src/M000292.html +19 -0
- data/doc/classes/Nudge/Channel.src/M000293.html +17 -0
- data/doc/classes/Nudge/Channel.src/M000294.html +15 -0
- data/doc/classes/Nudge/Channel.src/M000295.html +20 -0
- data/doc/classes/Nudge/Channel.src/M000296.html +15 -0
- data/doc/classes/Nudge/Channel.src/M000297.html +17 -0
- data/doc/classes/Nudge/Channel.src/M000298.html +15 -0
- data/doc/classes/Nudge/CodeBlock.html +331 -0
- data/doc/classes/Nudge/CodeBlock.src/M000263.html +15 -0
- data/doc/classes/Nudge/CodeBlock.src/M000264.html +15 -0
- data/doc/classes/Nudge/CodeBlock.src/M000265.html +15 -0
- data/doc/classes/Nudge/CodeBlock.src/M000266.html +15 -0
- data/doc/classes/Nudge/CodeBlock.src/M000267.html +15 -0
- data/doc/classes/Nudge/CodeBlock.src/M000268.html +17 -0
- data/doc/classes/Nudge/CodeBlock.src/M000269.html +20 -0
- data/doc/classes/Nudge/CodeBlock.src/M000270.html +15 -0
- data/doc/classes/Nudge/CodeBlock.src/M000271.html +19 -0
- data/doc/classes/Nudge/DeadLocation.html +152 -0
- data/doc/classes/Nudge/DeadLocation.src/M000334.html +17 -0
- data/doc/classes/Nudge/Erc.html +335 -0
- data/doc/classes/Nudge/Erc.src/M000278.html +16 -0
- data/doc/classes/Nudge/Erc.src/M000279.html +15 -0
- data/doc/classes/Nudge/Erc.src/M000280.html +15 -0
- data/doc/classes/Nudge/Erc.src/M000281.html +15 -0
- data/doc/classes/Nudge/Erc.src/M000282.html +18 -0
- data/doc/classes/Nudge/Erc.src/M000283.html +15 -0
- data/doc/classes/Nudge/Erc.src/M000284.html +17 -0
- data/doc/classes/Nudge/Erc.src/M000285.html +15 -0
- data/doc/classes/Nudge/Individual.html +313 -0
- data/doc/classes/Nudge/Individual.src/M000314.html +21 -0
- data/doc/classes/Nudge/Individual.src/M000315.html +15 -0
- data/doc/classes/Nudge/Individual.src/M000316.html +15 -0
- data/doc/classes/Nudge/Individual.src/M000317.html +17 -0
- data/doc/classes/Nudge/Individual.src/M000318.html +25 -0
- data/doc/classes/Nudge/InstructionPoint/InstructionNotFoundError.html +110 -0
- data/doc/classes/Nudge/InstructionPoint.html +350 -0
- data/doc/classes/Nudge/InstructionPoint.src/M000299.html +15 -0
- data/doc/classes/Nudge/InstructionPoint.src/M000300.html +15 -0
- data/doc/classes/Nudge/InstructionPoint.src/M000301.html +17 -0
- data/doc/classes/Nudge/InstructionPoint.src/M000302.html +15 -0
- data/doc/classes/Nudge/InstructionPoint.src/M000303.html +17 -0
- data/doc/classes/Nudge/InstructionPoint.src/M000304.html +17 -0
- data/doc/classes/Nudge/InstructionPoint.src/M000305.html +17 -0
- data/doc/classes/Nudge/InstructionPoint.src/M000306.html +15 -0
- data/doc/classes/Nudge/Interpreter.html +369 -0
- data/doc/classes/Nudge/Interpreter.src/M000257.html +20 -0
- data/doc/classes/Nudge/Interpreter.src/M000258.html +19 -0
- data/doc/classes/Nudge/Interpreter.src/M000259.html +15 -0
- data/doc/classes/Nudge/Interpreter.src/M000260.html +19 -0
- data/doc/classes/Nudge/Interpreter.src/M000261.html +17 -0
- data/doc/classes/Nudge/LiteralPoint.html +291 -0
- data/doc/classes/Nudge/LiteralPoint.src/M000272.html +16 -0
- data/doc/classes/Nudge/LiteralPoint.src/M000273.html +15 -0
- data/doc/classes/Nudge/LiteralPoint.src/M000274.html +15 -0
- data/doc/classes/Nudge/LiteralPoint.src/M000275.html +18 -0
- data/doc/classes/Nudge/LiteralPoint.src/M000276.html +17 -0
- data/doc/classes/Nudge/LiteralPoint.src/M000277.html +15 -0
- data/doc/classes/Nudge/Location.html +525 -0
- data/doc/classes/Nudge/Location.src/M000319.html +19 -0
- data/doc/classes/Nudge/Location.src/M000320.html +15 -0
- data/doc/classes/Nudge/Location.src/M000321.html +26 -0
- data/doc/classes/Nudge/Location.src/M000322.html +15 -0
- data/doc/classes/Nudge/Location.src/M000323.html +20 -0
- data/doc/classes/Nudge/Location.src/M000324.html +16 -0
- data/doc/classes/Nudge/Location.src/M000325.html +25 -0
- data/doc/classes/Nudge/Location.src/M000326.html +15 -0
- data/doc/classes/Nudge/Location.src/M000327.html +21 -0
- data/doc/classes/Nudge/Location.src/M000328.html +16 -0
- data/doc/classes/Nudge/Location.src/M000329.html +15 -0
- data/doc/classes/Nudge/Location.src/M000330.html +16 -0
- data/doc/classes/Nudge/Location.src/M000331.html +20 -0
- data/doc/classes/Nudge/Location.src/M000332.html +17 -0
- data/doc/classes/Nudge/Location.src/M000333.html +17 -0
- data/doc/classes/Nudge/NondominatedSubset.html +196 -0
- data/doc/classes/Nudge/NondominatedSubset.src/M000005.html +19 -0
- data/doc/classes/Nudge/NondominatedSubset.src/M000006.html +19 -0
- data/doc/classes/Nudge/NondominatedSubset.src/M000007.html +25 -0
- data/doc/classes/Nudge/NondominatedSubset.src/M000339.html +19 -0
- data/doc/classes/Nudge/NondominatedSubset.src/M000340.html +19 -0
- data/doc/classes/Nudge/NondominatedSubset.src/M000341.html +25 -0
- data/doc/classes/Nudge/PopulationResample.html +175 -0
- data/doc/classes/Nudge/PopulationResample.src/M000003.html +22 -0
- data/doc/classes/Nudge/PopulationResample.src/M000337.html +22 -0
- data/doc/classes/Nudge/ProgramPoint.html +148 -0
- data/doc/classes/Nudge/ProgramPoint.src/M000262.html +15 -0
- data/doc/classes/Nudge/RandomGuess.html +176 -0
- data/doc/classes/Nudge/RandomGuess.src/M000002.html +21 -0
- data/doc/classes/Nudge/RandomGuess.src/M000336.html +21 -0
- data/doc/classes/Nudge/ResampleValues.html +169 -0
- data/doc/classes/Nudge/ResampleValues.src/M000004.html +36 -0
- data/doc/classes/Nudge/ResampleValues.src/M000338.html +36 -0
- data/doc/classes/Nudge/SearchOperator.html +175 -0
- data/doc/classes/Nudge/SearchOperator.src/M000001.html +15 -0
- data/doc/classes/Nudge/SearchOperator.src/M000335.html +15 -0
- data/doc/classes/Nudge/Stack.html +350 -0
- data/doc/classes/Nudge/Stack.src/M000307.html +15 -0
- data/doc/classes/Nudge/Stack.src/M000308.html +15 -0
- data/doc/classes/Nudge/Stack.src/M000309.html +18 -0
- data/doc/classes/Nudge/Stack.src/M000310.html +15 -0
- data/doc/classes/Nudge/Stack.src/M000311.html +15 -0
- data/doc/classes/Nudge/Stack.src/M000312.html +15 -0
- data/doc/classes/Nudge/Stack.src/M000313.html +15 -0
- data/doc/classes/Nudge/UniformBackboneCrossover.html +152 -0
- data/doc/classes/Nudge/UniformBackboneCrossover.src/M000008.html +35 -0
- data/doc/classes/Nudge/UniformBackboneCrossover.src/M000342.html +35 -0
- data/doc/classes/Nudge.html +174 -0
- data/doc/classes/NudgeType.html +363 -0
- data/doc/classes/NudgeType.src/M000225.html +17 -0
- data/doc/classes/NudgeType.src/M000226.html +15 -0
- data/doc/classes/NudgeType.src/M000227.html +15 -0
- data/doc/classes/NudgeType.src/M000228.html +15 -0
- data/doc/classes/NudgeType.src/M000229.html +15 -0
- data/doc/classes/NudgeType.src/M000230.html +15 -0
- data/doc/classes/NudgeType.src/M000231.html +15 -0
- data/doc/classes/NudgeType.src/M000232.html +15 -0
- data/doc/classes/NudgeType.src/M000233.html +15 -0
- data/doc/classes/NudgeType.src/M000234.html +15 -0
- data/doc/created.rid +1 -0
- data/doc/files/lib/instructions/bool_basics_rb.html +90 -0
- data/doc/files/lib/instructions/comparisons_rb.html +90 -0
- data/doc/files/lib/instructions/conditionals_rb.html +90 -0
- data/doc/files/lib/instructions/conversions_rb.html +90 -0
- data/doc/files/lib/instructions/exec_rb.html +90 -0
- data/doc/files/lib/instructions/float_arithmetic_rb.html +90 -0
- data/doc/files/lib/instructions/float_transcendental_rb.html +90 -0
- data/doc/files/lib/instructions/infrastructure_rb.html +100 -0
- data/doc/files/lib/instructions/int_arithmetic_rb.html +90 -0
- data/doc/files/lib/instructions/random_value_rb.html +90 -0
- data/doc/files/lib/instructions/stack_manipulation_rb.html +90 -0
- data/doc/files/lib/interpreter/grammars/nudge_language_helpers_rb.html +97 -0
- data/doc/files/lib/interpreter/grammars/nudge_language_treetop.html +180 -0
- data/doc/files/lib/interpreter/interpreter_rb.html +90 -0
- data/doc/files/lib/interpreter/programPoints_rb.html +90 -0
- data/doc/files/lib/interpreter/stack_rb.html +90 -0
- data/doc/files/lib/interpreter/types/codeType_rb.html +157 -0
- data/doc/files/lib/interpreter/types/codeType_rb.src/M000001.html +15 -0
- data/doc/files/lib/interpreter/types/codeType_rb.src/M000002.html +15 -0
- data/doc/files/lib/interpreter/types/pushTypes_rb.html +107 -0
- data/doc/files/lib/nudge_rb.html +152 -0
- data/doc/files/lib/search/evaluators/structural_complexity_rb.html +90 -0
- data/doc/files/lib/search/helpers_rb.html +90 -0
- data/doc/files/lib/search/individual/individual_rb.html +90 -0
- data/doc/files/lib/search/locations/location_rb.html +100 -0
- data/doc/files/lib/search/operators/basic_operators_rb.html +90 -0
- data/doc/fr_class_index.html +191 -0
- data/doc/fr_file_index.html +71 -0
- data/doc/fr_method_index.html +711 -0
- data/doc/index.html +21 -0
- data/doc/rdoc-style.css +299 -0
- data/features/parser_recognizes_nudge_language.feature +9 -0
- data/lib/instructions/bool_basics.rb +85 -0
- data/lib/instructions/code_basics.rb +14 -0
- data/lib/instructions/comparisons.rb +152 -0
- data/lib/instructions/conditionals.rb +44 -0
- data/lib/instructions/conversions.rb +94 -0
- data/lib/instructions/exec.rb +154 -0
- data/lib/instructions/float_arithmetic.rb +201 -0
- data/lib/instructions/float_transcendental.rb +47 -0
- data/lib/instructions/infrastructure.rb +84 -0
- data/lib/instructions/int_arithmetic.rb +160 -0
- data/lib/instructions/name_basics.rb +44 -0
- data/lib/instructions/name_bindings.rb +65 -0
- data/lib/instructions/random_value.rb +43 -0
- data/lib/instructions/stack_manipulation.rb +739 -0
- data/lib/interpreter/grammars/nudge_language.treetop +83 -0
- data/lib/interpreter/grammars/nudge_language_helpers.rb +64 -0
- data/lib/interpreter/interpreter.rb +176 -0
- data/lib/interpreter/programPoints.rb +236 -0
- data/lib/interpreter/stack.rb +39 -0
- data/lib/interpreter/types/codeType.rb +108 -0
- data/lib/interpreter/types/pushTypes.rb +102 -0
- data/lib/nudge.rb +38 -0
- data/lib/search/experiments/experiment.rb +53 -0
- data/lib/search/helpers.rb +22 -0
- data/lib/search/individual/batch.rb +25 -0
- data/lib/search/individual/individual.rb +147 -0
- data/lib/search/operators/basic_operators.rb +230 -0
- data/lib/search/operators/evaluators.rb +107 -0
- data/lib/search/operators/samplers_and_selectors.rb +123 -0
- data/lib/search/stations/station.rb +147 -0
- data/push_language_coverage.md +177 -0
- data/readme.md +19 -0
- data/spec/data/couchdb_spec.rb +2 -0
- data/spec/fixtures/just_block.example +1 -0
- data/spec/fixtures/just_block_with_newline.example +1 -0
- data/spec/fixtures/long_arithmetic.example +7 -0
- data/spec/fixtures/one_line_instr.example +1 -0
- data/spec/fixtures/untidy1.example +20 -0
- data/spec/fixtures/untidy1fixed.example +12 -0
- data/spec/instructions/bool_basics_spec.rb +97 -0
- data/spec/instructions/bool_stack_spec.rb +391 -0
- data/spec/instructions/code_basics_spec.rb +43 -0
- data/spec/instructions/code_stack_spec.rb +382 -0
- data/spec/instructions/comparisons_spec.rb +486 -0
- data/spec/instructions/conditionals_spec.rb +162 -0
- data/spec/instructions/conversions_spec.rb +92 -0
- data/spec/instructions/exec_spec.rb +883 -0
- data/spec/instructions/float_calculations_spec.rb +148 -0
- data/spec/instructions/float_stack_spec.rb +382 -0
- data/spec/instructions/float_transcendental_spec.rb +89 -0
- data/spec/instructions/instruction_class_spec.rb +9 -0
- data/spec/instructions/int_calculations_spec.rb +125 -0
- data/spec/instructions/int_stack_spec.rb +398 -0
- data/spec/instructions/name_basics_spec.rb +158 -0
- data/spec/instructions/name_bindings_spec.rb +257 -0
- data/spec/instructions/name_stack_spec.rb +382 -0
- data/spec/instructions/random_values_spec.rb +68 -0
- data/spec/integration/search_integration.rb +67 -0
- data/spec/interpreter/channel_spec.rb +92 -0
- data/spec/interpreter/codeblock_spec.rb +135 -0
- data/spec/interpreter/codetype_spec.rb +257 -0
- data/spec/interpreter/erc_spec.rb +130 -0
- data/spec/interpreter/instruction_spec.rb +97 -0
- data/spec/interpreter/interpreter_spec.rb +266 -0
- data/spec/interpreter/literal_spec.rb +94 -0
- data/spec/interpreter/parser_spec.rb +324 -0
- data/spec/interpreter/stack_spec.rb +81 -0
- data/spec/interpreter/types_spec.rb +102 -0
- data/spec/search/batch_spec.rb +30 -0
- data/spec/search/experiments/experiment_spec.rb +101 -0
- data/spec/search/helpers_spec.rb +59 -0
- data/spec/search/individual_spec.rb +356 -0
- data/spec/search/operators/any_one_sampler_spec.rb +40 -0
- data/spec/search/operators/dominated_quantile_spec.rb +111 -0
- data/spec/search/operators/duplicate_genomes_spec.rb +35 -0
- data/spec/search/operators/evaluators/program_point_evaluator_spec.rb +43 -0
- data/spec/search/operators/evaluators/test_case_evaluator_spec.rb +133 -0
- data/spec/search/operators/infrastructure_spec.rb +47 -0
- data/spec/search/operators/most_dominated_subset_spec.rb +47 -0
- data/spec/search/operators/nondominated_subset_spec.rb +97 -0
- data/spec/search/operators/pointCrossover_spec.rb +55 -0
- data/spec/search/operators/pointDeletion_spec.rb +57 -0
- data/spec/search/operators/pointMutation_spec.rb +71 -0
- data/spec/search/operators/random_guess_spec.rb +51 -0
- data/spec/search/operators/resample_and_clone_spec.rb +50 -0
- data/spec/search/operators/resample_values_spec.rb +126 -0
- data/spec/search/operators/sizePreservingMutation_spec.rb +2 -0
- data/spec/search/operators/uniformBackboneCrossover_spec.rb +63 -0
- data/spec/search/stations/station_spec.rb +496 -0
- data/spec/spec_helper.rb +11 -0
- metadata +738 -0
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
require File.join(File.dirname(__FILE__), "/../spec_helper")
|
|
3
|
+
|
|
4
|
+
require 'pp'
|
|
5
|
+
include Nudge
|
|
6
|
+
|
|
7
|
+
describe "parser" do
|
|
8
|
+
before(:all) do
|
|
9
|
+
@parser = NudgeLanguageParser.new
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "should fail for an empty program" do
|
|
13
|
+
empty = ""
|
|
14
|
+
@parser.parse(empty).should == nil
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
describe "works for single-line code" do
|
|
20
|
+
it "should recognize 'block {}'" do
|
|
21
|
+
just_block = fixture(:just_block)
|
|
22
|
+
@parser.parse(just_block).should be_a_kind_of(BlockNode)
|
|
23
|
+
asCode = @parser.parse(just_block).to_points
|
|
24
|
+
asCode.should be_a_kind_of(CodeBlock)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "should have the right #contents for 'block {}'" do
|
|
28
|
+
just_block = fixture(:just_block)
|
|
29
|
+
asCode = @parser.parse(just_block).to_points
|
|
30
|
+
asCode.should be_a_kind_of(CodeBlock)
|
|
31
|
+
asCode.contents.should be_a_kind_of(Array)
|
|
32
|
+
asCode.contents.length.should == 0
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it %(should recognize \"block {}\\n\") do
|
|
36
|
+
extraSpace = @parser.parse(fixture(:just_block_with_newline))
|
|
37
|
+
extraSpace.should be_a_kind_of(BlockNode)
|
|
38
|
+
asCode = extraSpace.to_points
|
|
39
|
+
asCode.should be_a_kind_of(CodeBlock)
|
|
40
|
+
asCode.contents.should be_a_kind_of(Array)
|
|
41
|
+
asCode.contents.length.should == 0
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
describe ": just one instruction line" do
|
|
45
|
+
[fixture(:one_line_instr), "do foo_bar", "do\tfoo_bar"].each do |b|
|
|
46
|
+
it "should recognize \"#{b}\"" do
|
|
47
|
+
@parser.parse(b).should be_a_kind_of(InstructionNode)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "should return an Instruction object for \"#{b}\"" do
|
|
51
|
+
asCode = @parser.parse(b).to_points
|
|
52
|
+
asCode.should be_a_kind_of(InstructionPoint)
|
|
53
|
+
asCode.name.should == "foo_bar"
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
describe ": just one channel line" do
|
|
59
|
+
["ref x", "ref\tx"].each do |b|
|
|
60
|
+
it "should recognize \"#{b}\"" do
|
|
61
|
+
@parser.parse(b).should be_a_kind_of(ChannelNode)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it "should return a Channel object for \"#{b}\"" do
|
|
65
|
+
asCode = @parser.parse(b).to_points
|
|
66
|
+
asCode.should be_a_kind_of(ChannelPoint)
|
|
67
|
+
asCode.name.should == "x"
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
describe ": just one literal line" do
|
|
73
|
+
|
|
74
|
+
describe "(integer literals)" do
|
|
75
|
+
[["literal int(8)",:int,8],
|
|
76
|
+
["literal\tint (8)",:int,8],
|
|
77
|
+
["literal int( -221 )",:int,-221]
|
|
78
|
+
].each do |b|
|
|
79
|
+
|
|
80
|
+
it "should recognize \"#{b[0]}\"" do
|
|
81
|
+
@parser.parse(b[0]).should be_a_kind_of(LiteralNode)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it "should return a LiteralPoint for \"#{b[0]}\"" do
|
|
85
|
+
asCode = @parser.parse(b[0]).to_points
|
|
86
|
+
asCode.should be_a_kind_of(LiteralPoint)
|
|
87
|
+
asCode.type.should == b[1]
|
|
88
|
+
asCode.value.should == b[2]
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
describe "(boolean literals)" do
|
|
94
|
+
[["literal bool(true)",:bool,true],
|
|
95
|
+
["literal\t bool (false)",:bool,false],
|
|
96
|
+
["literal bool ( FALSE )",:bool,false],
|
|
97
|
+
["literal bool (\tTrue)",:bool,true]
|
|
98
|
+
].each do |b|
|
|
99
|
+
|
|
100
|
+
it "should recognize \"#{b[0]}\"" do
|
|
101
|
+
@parser.parse(b[0]).should be_a_kind_of(LiteralNode)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
it "should return a LiteralPoint object for \"#{b[0]}\"" do
|
|
105
|
+
asCode = @parser.parse(b[0]).to_points
|
|
106
|
+
asCode.should be_a_kind_of(LiteralPoint)
|
|
107
|
+
asCode.type.should == b[1]
|
|
108
|
+
asCode.value.should == b[2]
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
describe "(float literals)" do
|
|
114
|
+
[["literal float(-6.2)",:float,-6.2],
|
|
115
|
+
["literal\t float (1992.0001)",:float,1992.0001],
|
|
116
|
+
["literal\t float ( 0.00010101 ) ",:float,0.00010101],
|
|
117
|
+
["literal\t float (2)",:float,2.0]].each do |b|
|
|
118
|
+
|
|
119
|
+
it "should recognize \"#{b[0]}\"" do
|
|
120
|
+
@parser.parse(b[0]).should be_a_kind_of(LiteralNode)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
it "should return a LiteralPoint object for \"#{b[0]}\"" do
|
|
124
|
+
asCode = @parser.parse(b[0]).to_points
|
|
125
|
+
asCode.should be_a_kind_of(LiteralPoint)
|
|
126
|
+
asCode.type.should == b[1]
|
|
127
|
+
asCode.value.should be_close(b[2],0.000001)
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
describe ": just one ERC line" do
|
|
136
|
+
describe "(integer ERCs)" do
|
|
137
|
+
[["sample int(-912)",:int,-912],["sample\tint ( -88 )",:int,-88]].each do |b|
|
|
138
|
+
it "should recognize \"#{b}\"" do
|
|
139
|
+
@parser.parse(b[0]).should be_a_kind_of(ERCNode)
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
it "should return an Erc object for \"#{b[0]}\"" do
|
|
143
|
+
asCode = @parser.parse(b[0]).to_points
|
|
144
|
+
asCode.should be_a_kind_of(Erc)
|
|
145
|
+
asCode.type.should == b[1]
|
|
146
|
+
asCode.value.should ==b[2]
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
describe "(boolean ERCs)" do
|
|
152
|
+
[["sample bool(true)",:bool, true],
|
|
153
|
+
["sample\t bool ( false ) ",:bool, false]].each do |b|
|
|
154
|
+
it "should recognize \"#{b[0]}\"" do
|
|
155
|
+
@parser.parse(b[0]).should be_a_kind_of(ERCNode)
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
it "should return an Erc object for \"#{b[0]}\"" do
|
|
159
|
+
asCode = @parser.parse(b[0]).to_points
|
|
160
|
+
asCode.should be_a_kind_of(Erc)
|
|
161
|
+
asCode.type.should == b[1]
|
|
162
|
+
asCode.value.should ==b[2]
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
it "should ignore case" do
|
|
167
|
+
@parser.parse("literal bool (FALSE)").value.should == false
|
|
168
|
+
@parser.parse("literal bool(True)").value.should == true
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
describe "(float ERCs)" do
|
|
174
|
+
[["sample float(-9999.001)",:float,-9999.001],
|
|
175
|
+
["sample\t float ( 33.3 ) ",:float,33.3],
|
|
176
|
+
["sample\t\t \tfloat (\t12.12\t)",:float,12.12],
|
|
177
|
+
["sample float (1000)",:float,1000.0]].each do |b|
|
|
178
|
+
it "should recognize \"#{b[0]}\"" do
|
|
179
|
+
@parser.parse(b[0]).should be_a_kind_of(ERCNode)
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
it "should return an Erc object for \"#{b[0]}\"" do
|
|
183
|
+
asCode = @parser.parse(b[0]).to_points
|
|
184
|
+
asCode.should be_a_kind_of(Erc)
|
|
185
|
+
asCode.type.should == b[1]
|
|
186
|
+
asCode.value.should be_close(b[2],0.000001)
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
describe "should handle long lists in blocks" do
|
|
197
|
+
listy = ["block {\n literal int(1)}", "block {\n literal int(2)\n literal int(3)}"]
|
|
198
|
+
listy.each do |n|
|
|
199
|
+
it "should recognize \"#{n}\"" do
|
|
200
|
+
@parser.parse(n).should_not == nil
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
describe "should handle two-line code" do
|
|
208
|
+
b2s = [" block {} block {}","\tblock{}\n\tblock{}","instr hey_there\ninstr now_then"]
|
|
209
|
+
b2s.each do |b|
|
|
210
|
+
it "should fail to recognize \"#{b}\" because there are two root lines" do
|
|
211
|
+
@parser.parse(b).should == nil
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
b2s = ["block {\n ref x}"]
|
|
216
|
+
b2s.each do |b|
|
|
217
|
+
it "should recognize \"#{b}\"" do
|
|
218
|
+
@parser.parse(b).should_not == nil
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
it "should have the right stuff inside it" do
|
|
222
|
+
asCode = @parser.parse(b).to_points
|
|
223
|
+
asCode.should be_a_kind_of(CodeBlock)
|
|
224
|
+
asCode.contents.should be_a_kind_of(Array)
|
|
225
|
+
asCode.contents[0].should be_a_kind_of(ChannelPoint)
|
|
226
|
+
asCode.contents[0].name.should == "x"
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
b2s = ["block {\n block {}}"]
|
|
231
|
+
b2s.each do |b|
|
|
232
|
+
it "should recognize \"#{b}\"" do
|
|
233
|
+
@parser.parse(b).should_not == nil
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
it "should have the right stuff inside it" do
|
|
237
|
+
asCode = @parser.parse(b).to_points
|
|
238
|
+
asCode.should be_a_kind_of(CodeBlock)
|
|
239
|
+
asCode.contents.should be_a_kind_of(Array)
|
|
240
|
+
asCode.contents[0].should be_a_kind_of(CodeBlock)
|
|
241
|
+
asCode.contents[0].contents.should == []
|
|
242
|
+
end
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
b2s = [["block {\n do hey_now}",InstructionPoint],
|
|
246
|
+
["block {\n literal int (22) }",LiteralPoint],
|
|
247
|
+
["block {\n ref WVIZ}",ChannelPoint]]
|
|
248
|
+
b2s.each do |b|
|
|
249
|
+
it "should have the correct inner node type for \"#{b[0]}\"" do
|
|
250
|
+
asCode = @parser.parse(b[0]).to_points
|
|
251
|
+
asCode.should be_a_kind_of(CodeBlock)
|
|
252
|
+
asCode.contents.should be_a_kind_of(Array)
|
|
253
|
+
asCode.contents[0].should be_a_kind_of(b[1])
|
|
254
|
+
end
|
|
255
|
+
end
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
describe "it should work for long lists of one-line points in a block" do
|
|
261
|
+
b2s = [["block {\n do A\n do B\n do C}",3],
|
|
262
|
+
["block {\n literal int(22)\n literal int( 23) \n literal int( 24 )\n ref x\nref y}",5],
|
|
263
|
+
["block {\n ref WVIZ\n ref WAMU}",2]]
|
|
264
|
+
b2s.each do |b|
|
|
265
|
+
it "should have the correct inner node type for \"#{b[0]}\"" do
|
|
266
|
+
asCode = @parser.parse(b[0]).to_points
|
|
267
|
+
asCode.should be_a_kind_of(CodeBlock)
|
|
268
|
+
asCode.contents.should be_a_kind_of(Array)
|
|
269
|
+
asCode.contents.length.should == b[1]
|
|
270
|
+
end
|
|
271
|
+
end
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
describe "should handle nested blocks" do
|
|
277
|
+
nesty = ["block{\n block {\n block {}}}","block {\n block {}\n block {\n block {\n block {}}}}"]
|
|
278
|
+
nesty.each do |n|
|
|
279
|
+
it "should recognize \"#{n}\"" do
|
|
280
|
+
@parser.parse(n).should_not == nil
|
|
281
|
+
end
|
|
282
|
+
end
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
describe "should handle structured blocks" do
|
|
288
|
+
nasty = ["block{\n ref x\n block {\n ref y}}","block {\n block {}\n ref x\n ref y}"]
|
|
289
|
+
nasty.each do |n|
|
|
290
|
+
it "should recognize \"#{n}\"" do
|
|
291
|
+
@parser.parse(n).should_not == nil
|
|
292
|
+
end
|
|
293
|
+
end
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
describe "handling complex literals" do
|
|
299
|
+
it "should be able to parse code literals" do
|
|
300
|
+
meta = "block { literal code(block {sample int«8»})}"
|
|
301
|
+
trickymeta = @parser.parse(meta)
|
|
302
|
+
trickymeta.should_not == nil
|
|
303
|
+
trickymeta.to_points.contents[0].should be_a_kind_of(LiteralPoint)
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
it "should be able to parse nested code literals (and samples)" do
|
|
307
|
+
nested = "block { literal code( sample code « sample code «do int_add»»)}"
|
|
308
|
+
trickymeta = @parser.parse(nested)
|
|
309
|
+
trickymeta.should_not == nil
|
|
310
|
+
trickymeta.to_points.contents[0].should be_a_kind_of(LiteralPoint)
|
|
311
|
+
end
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
describe "should handle one-point programs with whitespace" do
|
|
317
|
+
buggy = ["block{}", " block{}", " do int_add", " ref x"]
|
|
318
|
+
buggy.each do |n|
|
|
319
|
+
it "should recognize \"#{n}\"" do
|
|
320
|
+
@parser.parse(n).should_not == nil
|
|
321
|
+
end
|
|
322
|
+
end
|
|
323
|
+
end
|
|
324
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), "/../spec_helper")
|
|
2
|
+
include Nudge
|
|
3
|
+
|
|
4
|
+
describe "stack" do
|
|
5
|
+
before(:each) do
|
|
6
|
+
@myStack = Stack.new(:int)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
describe "initialization" do
|
|
10
|
+
it "should have a name" do
|
|
11
|
+
@myStack.name.should == :int
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "should only accept a symbol as a name" do
|
|
15
|
+
lambda{ Stack.new("hi")}.should raise_error(ArgumentError,"Stack name must be a Symbol")
|
|
16
|
+
lambda{ Stack.new(88)}.should raise_error(ArgumentError)
|
|
17
|
+
lambda{ Stack.new(:caprica)}.should_not raise_error
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should have no entries" do
|
|
21
|
+
@myStack.entries.should have(0).items
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
describe "pushing and popping" do
|
|
27
|
+
it "should allow an object to be pushed" do
|
|
28
|
+
@myStack.push(12)
|
|
29
|
+
@myStack.entries[0].should == 12
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "should grow by one when an item is pushed" do
|
|
33
|
+
@myStack.push(1)
|
|
34
|
+
@myStack.push(2)
|
|
35
|
+
@myStack.push(3)
|
|
36
|
+
@myStack.entries.should have(3).items
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "should ignore attempts to push nil" do
|
|
40
|
+
@myStack.push(nil)
|
|
41
|
+
@myStack.entries.should have(0).items
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "should return its top item when popping" do
|
|
45
|
+
@myStack.push('hello')
|
|
46
|
+
fellOff = @myStack.pop
|
|
47
|
+
fellOff.should == 'hello'
|
|
48
|
+
@myStack.entries.should have(0).items
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "should fail silently if popped when empty, returning nil" do
|
|
52
|
+
empty = @myStack.pop
|
|
53
|
+
empty.should == nil
|
|
54
|
+
@myStack.entries.should have(0).items
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
describe "peeking" do
|
|
59
|
+
it "should return but not pop the last item on the stack" do
|
|
60
|
+
@myStack.push(1)
|
|
61
|
+
@myStack.peek.should == 1
|
|
62
|
+
@myStack.push(2)
|
|
63
|
+
@myStack.peek.should == 2
|
|
64
|
+
@myStack.push(3)
|
|
65
|
+
@myStack.peek.should == 3
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it "should fail silently if popped when empty, returning nil" do
|
|
69
|
+
@myStack.peek.should == nil
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
describe "depth" do
|
|
74
|
+
it "should return the number of items" do
|
|
75
|
+
@myStack.depth.should == 0
|
|
76
|
+
@myStack.push(1)
|
|
77
|
+
@myStack.push(2)
|
|
78
|
+
@myStack.depth.should == 2
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), "/../spec_helper")
|
|
2
|
+
include Nudge
|
|
3
|
+
|
|
4
|
+
describe "Type list" do
|
|
5
|
+
it "should have an #all_types [getter] method to return a list of every defined type" do
|
|
6
|
+
# will be a list of every type subclassed from NudgeType
|
|
7
|
+
NudgeType.all_types.should include(IntType)
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
describe "Int Type" do
|
|
12
|
+
it "should be a Singleton" do
|
|
13
|
+
IntType.instance.should be_a_kind_of(Singleton)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "should parse a string from code and produce the actual value" do
|
|
17
|
+
IntType.from_s("3").should == 3
|
|
18
|
+
lambda{IntType.from_s()}.should raise_error
|
|
19
|
+
end
|
|
20
|
+
it "should return the result of self.randomize when it receives an #any_value call" do
|
|
21
|
+
IntType.should_receive(:rand).and_return(0)
|
|
22
|
+
IntType.any_value.should == IntType.defaultLowest
|
|
23
|
+
IntType.should_receive(:rand).and_return(IntType.defaultHighest-IntType.defaultLowest)
|
|
24
|
+
IntType.any_value.should == IntType.defaultHighest
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
it "should return a result from a given range when that range is passed in" do
|
|
28
|
+
IntType.should_receive(:rand).and_return(0.0)
|
|
29
|
+
param1 = {:randomIntegerLowerBound => 9, :randomIntegerUpperBound =>10}
|
|
30
|
+
IntType.random_value(param1).should == 9
|
|
31
|
+
IntType.should_receive(:rand).and_return(3.0)
|
|
32
|
+
param2 = {:randomIntegerLowerBound => 90, :randomIntegerUpperBound =>100}
|
|
33
|
+
IntType.random_value(param2).should == 93
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "should work for any order of lower and upper bounds" do
|
|
37
|
+
IntType.should_receive(:rand).and_return(3)
|
|
38
|
+
backwards = {:randomIntegerLowerBound => 100, :randomIntegerUpperBound =>90}
|
|
39
|
+
IntType.random_value(backwards).should == 93
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "should actually work" do
|
|
43
|
+
lambda{IntType.any_value}.should_not raise_error
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
describe "Bool Type" do
|
|
50
|
+
it "should be a Singleton" do
|
|
51
|
+
BoolType.instance.should be_a_kind_of(Singleton)
|
|
52
|
+
end
|
|
53
|
+
it "should parse a string from code and produce the actual value" do
|
|
54
|
+
BoolType.from_s("false").should == false
|
|
55
|
+
lambda{BoolType.from_s()}.should raise_error
|
|
56
|
+
end
|
|
57
|
+
it "should return the result of self.randomize when it receives an #any_value call" do
|
|
58
|
+
BoolType.should_receive(:rand).and_return(0.1)
|
|
59
|
+
BoolType.any_value.should == true
|
|
60
|
+
BoolType.should_receive(:rand).and_return(0.9)
|
|
61
|
+
BoolType.any_value.should == false
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it "should return a result from a biased coin when the prob of true is passed in" do
|
|
65
|
+
BoolType.should_receive(:rand).and_return(0.1)
|
|
66
|
+
BoolType.any_value.should == true
|
|
67
|
+
BoolType.should_receive(:rand).and_return(0.1)
|
|
68
|
+
BoolType.random_value(:randomBooleanTruthProb => 0.05).should == false
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it "should actually work" do
|
|
72
|
+
lambda{BoolType.any_value}.should_not raise_error
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
describe "Float Type" do
|
|
78
|
+
it "should be a Singleton" do
|
|
79
|
+
FloatType.instance.should be_a_kind_of(Singleton)
|
|
80
|
+
end
|
|
81
|
+
it "should return the result of self.randomize when it receives an #any_value call" do
|
|
82
|
+
FloatType.should_receive(:random_value).and_return(-9.2)
|
|
83
|
+
FloatType.any_value.should == -9.2
|
|
84
|
+
end
|
|
85
|
+
it "should return a result from a given range when that range is passed in" do
|
|
86
|
+
FloatType.should_receive(:rand).and_return(0.0)
|
|
87
|
+
FloatType.random_value(:randomFloatLowerBound=>0.0, :randomFloatUpperBound=>10.0).should == 0.0
|
|
88
|
+
FloatType.should_receive(:rand).and_return(0.5)
|
|
89
|
+
FloatType.random_value(:randomFloatLowerBound=>-101.101,:randomFloatUpperBound=>101.101).should == 0.0
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it "should work for any order of lower and upper bounds" do
|
|
93
|
+
FloatType.should_receive(:rand).and_return(0.5)
|
|
94
|
+
backwards = {:randomFloatLowerBound=>101.101, :randomFloatUpperBound=>-101.101}
|
|
95
|
+
FloatType.random_value(backwards).should == 0.0
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
it "should actually work" do
|
|
99
|
+
lambda{FloatType.any_value}.should_not raise_error
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), "./../spec_helper")
|
|
2
|
+
include Nudge
|
|
3
|
+
|
|
4
|
+
describe "Batches" do
|
|
5
|
+
it "should be a kind of Array" do
|
|
6
|
+
Batch.new.should be_a_kind_of(Array)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it "should raise an exception if a non-Individual is added after initialization" do
|
|
10
|
+
careful = Batch.[](Individual.new("block {}"), Individual.new("block {}"))
|
|
11
|
+
careful.length.should == 2
|
|
12
|
+
|
|
13
|
+
lambda{careful = Batch.[](12)}.should raise_error(ArgumentError)
|
|
14
|
+
lambda{careful = Batch.[](Individual.new("do int_add"))}.should_not raise_error(ArgumentError)
|
|
15
|
+
|
|
16
|
+
lambda{careful = Batch.[](Individual.new("do int_add"),12)}.should raise_error(ArgumentError)
|
|
17
|
+
lambda{careful = Batch.[](Individual.new("do int_add"),
|
|
18
|
+
Individual.new("do int_add"))}.should_not raise_error(ArgumentError)
|
|
19
|
+
|
|
20
|
+
lambda{careful = Batch.new(12)}.should raise_error(ArgumentError)
|
|
21
|
+
lambda{careful = Batch.new(Individual.new("do int_add"))}.should_not raise_error(ArgumentError)
|
|
22
|
+
|
|
23
|
+
lambda{careful[1] = 991}.should raise_error(ArgumentError)
|
|
24
|
+
lambda{careful[1] = Individual.new("do int_add")}.should_not raise_error(ArgumentError)
|
|
25
|
+
|
|
26
|
+
lambda{careful << false}.should raise_error(ArgumentError)
|
|
27
|
+
lambda{careful << Individual.new("do int_add")}.should_not raise_error(ArgumentError)
|
|
28
|
+
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), "./../../spec_helper")
|
|
2
|
+
require 'fakeweb'
|
|
3
|
+
include Nudge
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
describe "Experiment" do
|
|
8
|
+
before(:each) do
|
|
9
|
+
@exp = Experiment.new
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "should have a name defaulting to 'default_experiment'" do
|
|
13
|
+
@exp.name.should == 'default_experiment'
|
|
14
|
+
Experiment.new(name: "regress").name.should == "regress"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe "#config object" do
|
|
18
|
+
it "should have a #config attribute, of class Config" do
|
|
19
|
+
@exp.config.should_not == nil
|
|
20
|
+
@exp.config.should be_a_kind_of(Nudge::Config)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "should have an #instructions Array, defaulting to all of them" do
|
|
25
|
+
(@exp.instructions.sort_by {|i| i.to_s}).should == (Instruction.all_instructions.sort_by {|i| i.to_s})
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "should have a #types Array, defaulting to [BoolType, FloatType, IntType]" do
|
|
29
|
+
@exp.types.should == [BoolType, FloatType, IntType]
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
describe "stations" do
|
|
34
|
+
before(:each) do
|
|
35
|
+
@exp = Experiment.new
|
|
36
|
+
Station.cleanup
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "should have an empty hash of Station names" do
|
|
40
|
+
@exp.station_names.should == []
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
describe "build_station" do
|
|
44
|
+
it "should create a new Station instance, and add it to its own #stations list" do
|
|
45
|
+
@exp.build_station("wondrous")
|
|
46
|
+
@exp.station_names.should include("wondrous")
|
|
47
|
+
Station.stations.keys.should include("wondrous")
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "should use the parameters passed in" do
|
|
51
|
+
@exp.build_station("wondrous", capacity:12)
|
|
52
|
+
Station.stations["wondrous"].capacity.should == 12
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
describe "connect_stations" do
|
|
57
|
+
it "should create a #flows_into connection between two Stations when called" do
|
|
58
|
+
@exp.build_station("alphaville")
|
|
59
|
+
@exp.build_station("beta_2")
|
|
60
|
+
Station.stations["alphaville"].downstream.should be_empty
|
|
61
|
+
Station.stations["beta_2"].downstream.should be_empty
|
|
62
|
+
@exp.connect_stations("alphaville", "beta_2")
|
|
63
|
+
Station.stations["alphaville"].downstream.should include("beta_2")
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it "should raise an ArgumentError if either name does not yet exist in the Experiment" do
|
|
67
|
+
@exp.build_station("alphaville")
|
|
68
|
+
@exp.build_station("beta_2")
|
|
69
|
+
lambda{@exp.connect_stations("alphaville", "beta_2")}.should_not raise_error(ArgumentError)
|
|
70
|
+
lambda{@exp.connect_stations("cygnus", "beta_2")}.should raise_error(ArgumentError)
|
|
71
|
+
lambda{@exp.connect_stations("alphaville", "cygnus")}.should raise_error(ArgumentError)
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
describe "objectives" do
|
|
77
|
+
it "should have a library of 'permitted' objectives, an empty hash to begin with" do
|
|
78
|
+
@exp.objectives.should == {}
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
describe "databases" do
|
|
84
|
+
it "should have a couchDB URL attribute, via parameter setting or default" do
|
|
85
|
+
@exp.couch_url.should == "http://localhost:5984"
|
|
86
|
+
otherplace = 'http://vagueserver.com:99999'
|
|
87
|
+
Experiment.new(:couch_url => otherplace).couch_url.should == otherplace
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it "should have a method to check that couchDB is accessible" do
|
|
91
|
+
FakeWeb.register_uri(:get, "http://localhost:5984", :status => ["200", "OK"])
|
|
92
|
+
@exp.couch_url = "http://localhost:5984"
|
|
93
|
+
@exp.couch_live?.should == true
|
|
94
|
+
|
|
95
|
+
FakeWeb.register_uri(:get, "http://localhost:99999", :exception => SocketError)
|
|
96
|
+
@exp.couch_url = "http://localhost:99999"
|
|
97
|
+
@exp.couch_live?.should == false
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), "./../spec_helper")
|
|
2
|
+
include Nudge
|
|
3
|
+
|
|
4
|
+
describe "Config" do
|
|
5
|
+
it "should have a class #setup method that stores a block" do
|
|
6
|
+
Nudge::Config.should respond_to(:setup)
|
|
7
|
+
Nudge::Config.setup {:foo}
|
|
8
|
+
Nudge::Config.stored_state.should be_a_kind_of(Proc)
|
|
9
|
+
Nudge::Config.stored_state.call.should == :foo
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
describe "InterpreterSettings" do
|
|
16
|
+
before(:each) do
|
|
17
|
+
@s1 = InterpreterSettings.new
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should have an Array of active instruction classNames" do
|
|
21
|
+
@s1.instructions.should be_a_kind_of(Array)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "should default to all instructions defined" do
|
|
25
|
+
@s1.instructions.should == Instruction.all_instructions
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "should have an Array of variable names" do
|
|
29
|
+
@s1.references.should == []
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "should have an Array of active Types" do
|
|
33
|
+
@s1.types.should be_a_kind_of(Array)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "should default to the Push types" do
|
|
37
|
+
@s1.types.should == NudgeType.push_types
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
describe "setting the value of Setting#attribute in initialization" do
|
|
41
|
+
it "should allow Hash-values for instructions" do
|
|
42
|
+
bools = [BoolAndInstruction, BoolOrInstruction]
|
|
43
|
+
s2 = InterpreterSettings.new(:instructions => bools)
|
|
44
|
+
s2.instructions.should == bools
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "should allow Hash-values for types" do
|
|
48
|
+
push = [IntType, BoolType, FloatType]
|
|
49
|
+
s2 = InterpreterSettings.new(:types => push)
|
|
50
|
+
s2.types.should == push
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "should allow Hash-values for variable names" do
|
|
54
|
+
vars = ["x1", "x3", "y1"]
|
|
55
|
+
s2 = InterpreterSettings.new(:references => vars)
|
|
56
|
+
s2.references.should == vars
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|