diff --git a/DSL/DSL.rb b/DSL/DSL.rb index a58b025..9c4fdbe 100644 --- a/DSL/DSL.rb +++ b/DSL/DSL.rb @@ -24,7 +24,7 @@ def initialize(path) @test = {} read_config path end - + def read_config(path) eval File.read(path) end @@ -55,13 +55,13 @@ def test(name, &block) @test[name] = block end - def in(*args) + def given(*args) # @context : stdin, stdout, stderr, wait_thr @context[0].puts(args.join ' ') if args.any? @context[0].close end - def out(*args) + def expected(*args) # @context : stdin, stdout, stderr, wait_thr full_result = {} output = @context[1].gets.strip # with trailing and leading whitespaces removed diff --git a/DSL/config b/DSL/config index 3f46255..fed97c6 100644 --- a/DSL/config +++ b/DSL/config @@ -6,12 +6,20 @@ students_files 'main' time_limit 14.2 memory_limit 25 -test 'first' do |t| - t.in 3,10,20,30 - t.out 10,20,30 +test 'first' do + given 3,10,20,30 + expected 10,20,30 end -test 'second' do |t| - t.in 2,-34,1 - t.out -34,1 +test 'second' do + given 2,-34,1 + expected -34,1 +end + +test 'third' do + n = rand 1..10 + arr = Array.new(n) { rand -50..50 } + + given n, *arr + expected *arr end \ No newline at end of file diff --git a/DSL/dsl_tester.rb b/DSL/dsl_tester.rb new file mode 100755 index 0000000..91fe57f --- /dev/null +++ b/DSL/dsl_tester.rb @@ -0,0 +1,5 @@ +#!/usr/bin/env jruby + +require_relative 'DSL.rb' + +DSL.new('config').run_all \ No newline at end of file