cauldron 0.1.2 → 0.1.3
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/Gemfile +6 -0
- data/Gemfile.lock +63 -0
- data/History.md +5 -0
- data/Rakefile +62 -16
- data/VERSION +1 -1
- data/cauldron.gemspec +463 -0
- data/cauldron/lib/cauldron.rb +1 -1
- data/features/cauldron_generates_runtime_method.feature +7 -4
- data/features/cauldron_generates_single_paramter_methods.feature +25 -0
- data/features/cauldron_interactive_start_terminal.feature +17 -0
- data/features/cauldron_quit_terminal.feature +9 -0
- data/features/cauldron_start_terminal.feature +0 -1
- data/features/step_definitions/cauldron_steps.rb +10 -5
- data/features/step_definitions/terminal_steps.rb +27 -0
- data/features/support/env.rb +2 -0
- data/features/support/hooks.rb +15 -0
- data/lib/Chain.rb +3 -3
- data/lib/Mapping.rb +1 -0
- data/lib/PartialChain.rb +253 -0
- data/lib/Theory.rb +28 -4
- data/lib/UnifiedChain.rb +94 -125
- data/lib/cauldron.rb +3 -0
- data/lib/cauldron/demos.rb +4 -4
- data/lib/cauldron/env.rb +1 -0
- data/lib/cauldron/pot.rb +42 -38
- data/lib/cauldron/terminal.rb +19 -3
- data/lib/cauldron/util/home.rb +21 -0
- data/lib/cauldron/util/saver.rb +45 -0
- data/lib/core/Container.rb +1 -1
- data/lib/core/runtime_method/ActsAsRuntimeMethod.rb +28 -28
- data/lib/core/runtime_method/RuntimeMethod.rb +6 -23
- data/lib/core/statement/ActsAsStatement.rb +0 -96
- data/lib/core/statement/BlockStatement.rb +1 -1
- data/lib/core/statement/OpenStatement.rb +1 -1
- data/lib/core/statement/Statement.rb +39 -94
- data/lib/core/statement/TheoryStatement.rb +1 -1
- data/lib/core/syntax/BlockContainer.rb +0 -28
- data/lib/core/variable/MethodParameter.rb +1 -1
- data/lib/required.rb +2 -14
- data/lib/theories.rb +0 -1
- data/lib/theory/ActionImplementation.rb +1 -1
- data/lib/theory/TheoryAction.rb +2 -2
- data/lib/theory/TheoryConnector.rb +11 -14
- data/lib/theory/TheoryImplementation.rb +10 -9
- data/lib/util/MethodWriter.rb +10 -10
- data/sandbox.rb +23 -0
- data/spec/cauldron/pot_spec.rb +62 -10
- data/spec/cauldron/runtime_method_spec.rb +31 -17
- data/spec/cauldron/saver_spec.rb +45 -0
- data/spec/cauldron/terminal_spec.rb +10 -1
- data/spec/cauldron/theory_spec.rb +4 -4
- data/spec/cauldron/unified_chain_spec.rb +38 -0
- data/spec/spec_helper.rb +3 -1
- data/tasks/development_tasks.rake +4 -0
- data/tasks/theory_tasks.rake +16 -20
- data/test/fixtures/theories/0/desc +6 -6
- data/test/fixtures/theories/0/dump +0 -0
- data/test/fixtures/theories/1/desc +7 -7
- data/test/fixtures/theories/1/dump +0 -0
- data/test/fixtures/theories/10/desc +13 -13
- data/test/fixtures/theories/10/dump +0 -0
- data/test/fixtures/theories/11/desc +10 -10
- data/test/fixtures/theories/11/dump +0 -0
- data/test/fixtures/theories/12/desc +9 -9
- data/test/fixtures/theories/12/dump +0 -0
- data/test/fixtures/theories/13/desc +16 -16
- data/test/fixtures/theories/13/dump +0 -0
- data/test/fixtures/theories/14/desc +16 -16
- data/test/fixtures/theories/14/dump +0 -0
- data/test/fixtures/theories/15/desc +10 -10
- data/test/fixtures/theories/15/dump +0 -0
- data/test/fixtures/theories/16/desc +10 -10
- data/test/fixtures/theories/16/dump +0 -0
- data/test/fixtures/theories/17/desc +7 -7
- data/test/fixtures/theories/17/dump +0 -0
- data/test/fixtures/theories/18/desc +7 -7
- data/test/fixtures/theories/18/dump +0 -0
- data/test/fixtures/theories/19/desc +7 -7
- data/test/fixtures/theories/19/dump +0 -0
- data/test/fixtures/theories/2/desc +6 -6
- data/test/fixtures/theories/2/dump +0 -0
- data/test/fixtures/theories/20/desc +13 -13
- data/test/fixtures/theories/20/dump +0 -0
- data/test/fixtures/theories/3/desc +7 -7
- data/test/fixtures/theories/3/dump +0 -0
- data/test/fixtures/theories/4/desc +7 -7
- data/test/fixtures/theories/4/dump +0 -0
- data/test/fixtures/theories/5/desc +6 -6
- data/test/fixtures/theories/5/dump +0 -0
- data/test/fixtures/theories/6/desc +7 -7
- data/test/fixtures/theories/6/dump +0 -0
- data/test/fixtures/theories/7/desc +7 -7
- data/test/fixtures/theories/7/dump +0 -0
- data/test/fixtures/theories/8/desc +7 -7
- data/test/fixtures/theories/8/dump +0 -0
- data/test/fixtures/theories/9/desc +16 -16
- data/test/fixtures/theories/9/dump +0 -0
- data/test/fixtures/theory_implementations/0/dump +0 -0
- data/test/fixtures/theory_implementations/2/dump +0 -0
- data/test/ts_complete.rb +1 -10
- data/test/unit/core/runtime_method/tc_realised_runtime_method.rb +1 -0
- data/test/unit/core/runtime_method/tc_runtime_method.rb +16 -39
- data/test/unit/core/statement/tc_block_statement.rb +3 -3
- data/test/unit/core/statement/tc_open_statement.rb +4 -4
- data/test/unit/core/statement/tc_statement.rb +2 -147
- data/test/unit/core/statement/tc_theory_statement.rb +1 -1
- data/test/unit/theory/tc_theory_dependent.rb +3 -3
- data/test/unit/theory/tc_theory_result.rb +5 -5
- data/test/unit/util/tc_method_validation.rb +45 -45
- data/test/unit/util/tc_parser.rb +1 -1
- data/test/unit/util/tc_string_to_theory.rb +2 -2
- metadata +74 -48
- data/lib/ScopeDependencies.rb +0 -8
- data/lib/core/statement/StatementDependencies.rb +0 -271
- data/lib/core/structure/DeclareNewInstanceStructure.rb +0 -49
- data/lib/core/structure/DeclareRuntimeMethodStructure.rb +0 -34
- data/lib/core/structure/DeclareVariableAsLiteralStructure.rb +0 -31
- data/lib/core/structure/DeclareVariableAsVariableStructure.rb +0 -52
- data/lib/core/structure/FixnumAdditionStructure.rb +0 -56
- data/lib/core/structure/InstanceCallContainerStructure.rb +0 -50
- data/lib/core/structure/InstanceCallStructure.rb +0 -53
- data/lib/core/structure/InstanceMethodCallStructure.rb +0 -21
- data/lib/core/structure/ReturnStructure.rb +0 -20
- data/lib/core/structure/StatementStructure.rb +0 -11
- data/test/unit/core/statement/tc_statement_dependencies.rb +0 -147
- data/test/unit/core/structure/tc_declare_new_instance_structure.rb +0 -41
- data/test/unit/core/structure/tc_declare_variable_as_literal_structure.rb +0 -41
- data/test/unit/core/structure/tc_declare_variable_as_variable_structure.rb +0 -66
- data/test/unit/core/structure/tc_instance_call_container_structure.rb +0 -41
- data/test/unit/core/structure/tc_return_structure.rb +0 -32
- data/test/unit/tc_instance_call_structure.rb +0 -35
- data/test/unit/tc_statement_structure_2.rb +0 -43
@@ -1,66 +0,0 @@
|
|
1
|
-
require 'required'
|
2
|
-
require 'test/unit'
|
3
|
-
|
4
|
-
class TestDeclareVariableAsVariableStructure < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def setup
|
7
|
-
|
8
|
-
# Create the structure instance that generates the appropriate statement
|
9
|
-
@statement_generator = DeclareVariableAsVariableStructure.new
|
10
|
-
|
11
|
-
# Create some simple variable declarations
|
12
|
-
@fixnum_variable = FixnumVariable.new(8)
|
13
|
-
@manny_variable = StringVariable.new('manny')
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
def teardown
|
18
|
-
System.reset
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_statements
|
22
|
-
|
23
|
-
# Test that "var = var(8)" can be created
|
24
|
-
assert_equal(1,@statement_generator.statements([@fixnum_variable]).length)
|
25
|
-
assert(@statement_generator.statements([@fixnum_variable]).first.kind_of?(Statement))
|
26
|
-
assert_equal(@statement_generator.length,@statement_generator.statements([@fixnum_variable]).first.length)
|
27
|
-
|
28
|
-
assert_equal(3,@statement_generator.statements([@manny_variable]).length)
|
29
|
-
assert_equal(0,@statement_generator.statements([]).length)
|
30
|
-
|
31
|
-
# Attempt to generate structures that generate string variables
|
32
|
-
assert_equal(3,@statement_generator.statements([@manny_variable]).length)
|
33
|
-
|
34
|
-
# Attempt to generate a string+string statement
|
35
|
-
le = 'Le'.to_var
|
36
|
-
chuck = 'Chuck'.to_var
|
37
|
-
assert_equal(6,@statement_generator.statements([le,chuck]).length)
|
38
|
-
|
39
|
-
# Test that declared variables can be retrieved from statement variabies
|
40
|
-
# e.g. var = statement_var.declared_variable
|
41
|
-
statement_var_a_unknown = Unknown.new
|
42
|
-
statement_var_a = Statement.new(statement_var_a_unknown,Equal.new,8.to_literal).to_var
|
43
|
-
# TODO I'm not sure I should allow the re-dclaration of variables here
|
44
|
-
assert_equal(2,@statement_generator.statements([statement_var_a]).length)
|
45
|
-
assert_equal(
|
46
|
-
' = var_'+statement_var_a.variable_id.to_s+'.declared_variable',
|
47
|
-
@statement_generator.statements([statement_var_a]).last.write[6..35]
|
48
|
-
)
|
49
|
-
|
50
|
-
# Check that the 'push' method isn't used in statement declarations
|
51
|
-
# Otherwise we generate allot of redundant variables.
|
52
|
-
# e.g.
|
53
|
-
# var_a = ['test','asdf']
|
54
|
-
# var_b = var_a.push('test2')
|
55
|
-
#
|
56
|
-
# var_a and var_b are essentially the same variable.
|
57
|
-
options_a = [
|
58
|
-
Statement.new(Return.new,6.to_literal).to_var,
|
59
|
-
RuntimeMethod.new(MethodUsage.new).to_var
|
60
|
-
]
|
61
|
-
assert_equal(3,@statement_generator.statements(options_a).length)
|
62
|
-
|
63
|
-
end
|
64
|
-
|
65
|
-
end
|
66
|
-
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'required'
|
2
|
-
require 'test/unit'
|
3
|
-
|
4
|
-
class TestInstanceCallContainerStructure < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def setup
|
7
|
-
|
8
|
-
# Create an array of variables to allow <runtime_method_var>.push(<statement_var>)
|
9
|
-
@runtime_method_var = RuntimeMethod.new(MethodUsage.new).to_var
|
10
|
-
@statement_var = Statement.new().to_var
|
11
|
-
@statement_and_runtime_method_var = [
|
12
|
-
@runtime_method_var,
|
13
|
-
@statement_var
|
14
|
-
]
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
def teardown
|
19
|
-
System.reset
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_statements
|
23
|
-
|
24
|
-
# Chect that <runtime_method_var>.push(<statement_var>) can be created
|
25
|
-
assert_equal(1,InstanceCallContainerStructure.new().statements(@statement_and_runtime_method_var).length)
|
26
|
-
assert_equal(
|
27
|
-
@runtime_method_var.write+'.push('+@statement_var.write+')',
|
28
|
-
InstanceCallContainerStructure.new().statements(@statement_and_runtime_method_var).first.write
|
29
|
-
)
|
30
|
-
|
31
|
-
# Check that <runtime_method_var>.push(<statement_var>) changes uniq_id but retains old reference
|
32
|
-
resulting_statement = InstanceCallContainerStructure.new().statements(@statement_and_runtime_method_var).first
|
33
|
-
assert_equal(resulting_statement.first.subject.variable_id,@runtime_method_var.variable_id)
|
34
|
-
#assert_not_equal(resulting_statement.first.subject.uniq_id,@runtime_method_var.uniq_id)
|
35
|
-
assert(resulting_statement.first.subject.uniq_id_history.kind_of?(Array))
|
36
|
-
#assert(resulting_statement.first.subject.uniq_id_history.any? {|x| x == @runtime_method_var.uniq_id})
|
37
|
-
#assert_equal(1,resulting_statement.first.subject.uniq_id_history.length)
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'required'
|
2
|
-
require 'test/unit'
|
3
|
-
|
4
|
-
class TestReturnStructure < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def setup
|
7
|
-
|
8
|
-
# Create the structure instance that generates the appropriate statement
|
9
|
-
@statement_generator = ReturnStructure.new()
|
10
|
-
@scabb = 'Scabb'.to_var
|
11
|
-
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
def teardown
|
16
|
-
CodeHandler.reset_global_id
|
17
|
-
System.reset
|
18
|
-
RuntimeMethod.reset_global_id
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_statements
|
22
|
-
|
23
|
-
# Check that 'scabb' was returned
|
24
|
-
assert_equal(1,@statement_generator.statements([@scabb]).length)
|
25
|
-
assert_equal(
|
26
|
-
'return var_'+@scabb.variable_id.to_s,
|
27
|
-
@statement_generator.statements([@scabb]).first.write
|
28
|
-
)
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'required'
|
2
|
-
require 'test/unit'
|
3
|
-
|
4
|
-
class TestInstanceCallStructure < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def setup
|
7
|
-
|
8
|
-
# Simple string example
|
9
|
-
@lechuck_variable = StringVariable.new('LeChuck')
|
10
|
-
|
11
|
-
# Create an a simple chop method
|
12
|
-
@chop_le_chuck = InstanceCallStructure.new(StringVariable,Chop.new)
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
def teardown
|
17
|
-
System.reset
|
18
|
-
RuntimeMethod.reset_global_id
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_instance_calls
|
22
|
-
|
23
|
-
# Assert that one instance call is created correctly
|
24
|
-
assert_equal(1,@chop_le_chuck.instance_calls([@lechuck_variable]).length)
|
25
|
-
assert(@chop_le_chuck.instance_calls([@lechuck_variable]).first.kind_of?(InstanceCallContainer))
|
26
|
-
|
27
|
-
# Confirm instance call hasn't any parameters
|
28
|
-
assert_equal(0,@chop_le_chuck.instance_calls([@lechuck_variable]).first.length)
|
29
|
-
|
30
|
-
# Assert the no results can be retrieved
|
31
|
-
assert_equal(0,@chop_le_chuck.instance_calls([]).length)
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'required'
|
2
|
-
require 'test/unit'
|
3
|
-
|
4
|
-
class TestStatementStructure2 < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def setup
|
7
|
-
|
8
|
-
# Create a simple statement structure var = 8
|
9
|
-
@fixnum_variable = FixnumVariable.new(8)
|
10
|
-
#@fixnum_structure = StatementStructure2.new(StatementStructure2.declared_fixnum)
|
11
|
-
|
12
|
-
# Simple string example
|
13
|
-
@manny_variable = StringVariable.new('manny')
|
14
|
-
|
15
|
-
# Create an a simple chop method
|
16
|
-
@chop_le_chuck = InstanceCallStructure.new(StringVariable,Chop.new)
|
17
|
-
|
18
|
-
# Simple statement structure that declares a new string variable
|
19
|
-
#@string_structure = StatementStructure2.new(StatementStructure2.declared_string)
|
20
|
-
|
21
|
-
# Adding strings structure
|
22
|
-
@adding_string = StatementStructure2.new(StatementStructure2.declared_string_addition)
|
23
|
-
|
24
|
-
# Adding fixnum.times structure
|
25
|
-
|
26
|
-
67.to_literal
|
27
|
-
|
28
|
-
# CONTINUE I would like to just use StatementStructure with String Variable ?
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
def teardown
|
35
|
-
System.reset
|
36
|
-
RuntimeMethod.reset_global_id
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_statements
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|