Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions DSL/DSL.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def initialize(path)
@test = {}
read_config path
end

def read_config(path)
eval File.read(path)
end
Expand Down Expand Up @@ -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
Expand Down
20 changes: 14 additions & 6 deletions DSL/config
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions DSL/dsl_tester.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env jruby

require_relative 'DSL.rb'

DSL.new('config').run_all