Sha256: aa71573447656cfc903785d682c40c2419cefb4ab8c910b74a1e8b23e1ef61dc
Contents?: true
Size: 1001 Bytes
Versions: 7
Compression:
Stored size: 1001 Bytes
Contents
class Gobstones::Batch attr_accessor :options, :examples, :content, :extra def initialize(content, examples, extra, options) @content = content @examples = examples @extra = extra @options = options end def run_tests!(output) Mumukit::Metatest::Framework.new( checker: Gobstones::Checker.new(options), runner: Gobstones::MultipleExecutionsRunner.new).test output, examples end def to_json examples.map { |example| example_json(example) }.to_json end private def example_json(example) expected_board = example[:postconditions][:final_board] base = example_base_json(example) expected_board ? base.merge(extraBoard: expected_board) : base end def example_base_json(example) {initialBoard: example[:preconditions][:initial_board], originalCode: content, code: "#{example_code(example)}\n#{extra}"} end def example_code(example) Gobstones::ExampleCodeBuilder.new(content, example, options).build end end
Version data entries
7 entries across 7 versions & 1 rubygems