lib/take/unit/generator.rb in take-0.0.9 vs lib/take/unit/generator.rb in take-0.0.10
- old
+ new
@@ -4,11 +4,10 @@
def initialize(parent, options)
@parent = parent
@groups = [@parent]
@options = options
- @group_functions = []
end
def generate
@output ||= begin
@output = ""
@@ -47,11 +46,11 @@
def walk_group(node)
@groups << node
group.children.select(&:test?).
each { |child| walk(child) }
- @group_functions << "group_#{group_name}"
+ group.children.select(&:group?).each { |child| walk(child) }
@output << <<-CODE
// group #{group_name}
void group_#{group_name}()
{
@@ -61,11 +60,16 @@
CODE
@output << group.children.select(&:test?).
map { |child| " test_#{group_name(child)}();" }.
join("\n")
@output << "\n"
+ group.children.select(&:group?).
+ each { |child| @output << " group_#{group_name}_" \
+ "#{child.name}();\n" }
@output << "}\n\n"
+
+
@groups.pop
end
def walk_test(node)
@output << <<-CODE
@@ -127,10 +131,11 @@
output(TEXT_COLOR_MAGENTA "FILE \\"" TEXT_COLOR_BOLD_MAGENTA
__FILE TEXT_COLOR_MAGENTA "\\":\\n");
CODE
- @group_functions.each { |func| @output << " #{func}();\n" }
+ node.children.select(&:group?).
+ each { |child| @output << " group_#{child.name}();\n" }
@output << <<-CODE
output2("\\n\\t" TEXT_COLOR_MAGENTA "RESULT:\\n\\t\\t"
"PASSED: " TEXT_COLOR_BOLD_MAGENTA "%zu"
TEXT_COLOR_MAGENTA "\\n\\t\\tFAILED: "