Procházet zdrojové kódy

Add runtime library.

master
Ben Kurtovic před 8 roky
rodič
revize
9923f261a3
1 změnil soubory, kde provedl 31 přidání a 0 odebrání
  1. +31
    -0
      lib/kgrader/runtime.rb

+ 31
- 0
lib/kgrader/runtime.rb Zobrazit soubor

@@ -0,0 +1,31 @@
require 'timeout'

module KGrader
module Runtime
MAX_COLS = 79

def testcase(options)
puts " running test: #{$0} ".center MAX_COLS, '='
begin
Timeout::timeout options[:alarm] { yield }
rescue Timeout::Error
comment "timeout"
grade 0
end
puts " done ".center MAX_COLS, '-'
end

def grade(score)
IO.new(3).write score
exit
end

def comment(text)
IO.new(4).write text + "\n"
end

def shake
ARGV[0]
end
end
end

Načítá se…
Zrušit
Uložit