@@ -12,6 +12,7 @@ export function defineTests(
1212 (
1313 {
1414 python : 2000 ,
15+ ruby : 2000 ,
1516 cpp : 10000 ,
1617 } as Record < RuntimeLang , number >
1718 ) [ lang ]
@@ -30,6 +31,7 @@ export function defineTests(
3031 const printCode = (
3132 {
3233 python : `print("${ msg } ")` ,
34+ ruby : `puts "${ msg } "` ,
3335 cpp : null ,
3436 } satisfies Record < RuntimeLang , string | null >
3537 ) [ lang ] ;
@@ -54,6 +56,7 @@ export function defineTests(
5456 const [ setIntVarCode , printIntVarCode ] = (
5557 {
5658 python : [ `${ varName } = ${ value } ` , `print(${ varName } )` ] ,
59+ ruby : [ `${ varName } = ${ value } ` , `puts ${ varName } ` ] ,
5760 cpp : [ null , null ] ,
5861 } satisfies Record < RuntimeLang , string [ ] | null [ ] >
5962 ) [ lang ] ;
@@ -80,6 +83,7 @@ export function defineTests(
8083 const errorCode = (
8184 {
8285 python : `raise Exception("${ errorMsg } ")` ,
86+ ruby : `raise "${ errorMsg } "` ,
8387 cpp : null ,
8488 } satisfies Record < RuntimeLang , string | null >
8589 ) [ lang ] ;
@@ -99,6 +103,7 @@ export function defineTests(
99103 const [ setIntVarCode , infLoopCode , printIntVarCode ] = (
100104 {
101105 python : [ `testVar = 42` , `while True:\n pass` , `print(testVar)` ] ,
106+ ruby : [ `testVar = 42` , `loop do\nend` , `puts testVar` ] ,
102107 cpp : [ null , null , null ] ,
103108 } satisfies Record < RuntimeLang , ( string | null ) [ ] >
104109 ) [ lang ] ;
@@ -132,6 +137,7 @@ export function defineTests(
132137 const [ filename , code ] = (
133138 {
134139 python : [ "test.py" , `print("${ msg } ")` ] ,
140+ ruby : [ "test.rb" , `puts "${ msg } "` ] ,
135141 cpp : [
136142 "test.cpp" ,
137143 `#include <iostream>\nint main() {\n std::cout << "${ msg } " << std::endl;\n return 0;\n}\n` ,
@@ -156,6 +162,7 @@ export function defineTests(
156162 const [ filename , code ] = (
157163 {
158164 python : [ "test_error.py" , `raise Exception("${ errorMsg } ")\n` ] ,
165+ ruby : [ "test_error.rb" , `raise "${ errorMsg } "\n` ] ,
159166 cpp : [
160167 "test_error.cpp" ,
161168 `#include <stdexcept>\nint main() {\n throw std::runtime_error("${ errorMsg } ");\n return 0;\n}\n` ,
@@ -183,6 +190,14 @@ export function defineTests(
183190 } ,
184191 [ "test_multi_main.py" ] ,
185192 ] ,
193+ ruby : [
194+ {
195+ "test_multi_main.rb" :
196+ "require_relative 'test_multi_sub'\nprint_message\n" ,
197+ "test_multi_sub.rb" : `def print_message\n puts "${ msg } "\nend\n` ,
198+ } ,
199+ [ "test_multi_main.rb" ] ,
200+ ] ,
186201 cpp : [
187202 {
188203 "test_multi_main.cpp" :
0 commit comments