@@ -34,6 +34,7 @@ export function defineTests(
3434 python : `print("${ msg } ")` ,
3535 ruby : `puts "${ msg } "` ,
3636 cpp : null ,
37+ rust : null ,
3738 javascript : `console.log("${ msg } ")` ,
3839 typescript : null ,
3940 } satisfies Record < RuntimeLang , string | null >
@@ -56,6 +57,7 @@ export function defineTests(
5657 python : [ `${ varName } = ${ value } ` , `print(${ varName } )` ] ,
5758 ruby : [ `${ varName } = ${ value } ` , `puts ${ varName } ` ] ,
5859 cpp : [ null , null ] ,
60+ rust : [ null , null ] ,
5961 javascript : [
6062 `const ${ varName } = ${ value } ` ,
6163 `console.log(${ varName } )` ,
@@ -86,6 +88,7 @@ export function defineTests(
8688 python : `raise Exception("${ errorMsg } ")` ,
8789 ruby : `raise "${ errorMsg } "` ,
8890 cpp : null ,
91+ rust : null ,
8992 javascript : `throw new Error("${ errorMsg } ")` ,
9093 typescript : null ,
9194 } satisfies Record < RuntimeLang , string | null >
@@ -108,6 +111,7 @@ export function defineTests(
108111 python : [ `testVar = 42` , `while True:\n pass` , `print(testVar)` ] ,
109112 ruby : [ `testVar = 42` , `loop do\nend` , `puts testVar` ] ,
110113 cpp : [ null , null , null ] ,
114+ rust : [ null , null , null ] ,
111115 javascript : [
112116 `const testVar = 42` ,
113117 `while(true) {}` ,
@@ -150,6 +154,7 @@ export function defineTests(
150154 python : `with open("${ targetFile } ", "w") as f:\n f.write("${ msg } ")` ,
151155 ruby : `File.open("${ targetFile } ", "w") {|f| f.write("${ msg } ") }` ,
152156 cpp : null ,
157+ rust : null ,
153158 javascript : null ,
154159 typescript : null ,
155160 } satisfies Record < RuntimeLang , string | null >
@@ -178,6 +183,7 @@ export function defineTests(
178183 "test.cpp" ,
179184 `#include <iostream>\nint main() {\n std::cout << "${ msg } " << std::endl;\n return 0;\n}\n` ,
180185 ] ,
186+ rust : [ "test.rs" , `fn main() {\n println!("${ msg } ");\n}\n` ] ,
181187 javascript : [ "test.js" , `console.log("${ msg } ")` ] ,
182188 typescript : [ "test.ts" , `console.log("${ msg } ")` ] ,
183189 } satisfies Record < RuntimeLang , [ string , string ] | [ null , null ] >
@@ -202,6 +208,10 @@ export function defineTests(
202208 "test_error.cpp" ,
203209 `#include <stdexcept>\nint main() {\n throw std::runtime_error("${ errorMsg } ");\n return 0;\n}\n` ,
204210 ] ,
211+ rust : [
212+ "test_error.rs" ,
213+ `fn main() {\n panic!("${ errorMsg } ");\n}\n` ,
214+ ] ,
205215 javascript : [ "test_error.js" , `throw new Error("${ errorMsg } ");\n` ] ,
206216 // TODO: tscが出す型エラーのテストはできていない
207217 typescript : [ "test_error.ts" , `throw new Error("${ errorMsg } ");\n` ] ,
@@ -248,6 +258,14 @@ export function defineTests(
248258 } ,
249259 [ "test_multi_main.cpp" , "test_multi_sub.cpp" ] ,
250260 ] ,
261+ rust : [
262+ {
263+ "test_multi_main.rs" :
264+ "mod test_multi_sub;\nfn main() {\n test_multi_sub::print_message();\n}\n" ,
265+ "test_multi_sub.rs" : `pub fn print_message() {\n println!("${ msg } ");\n}\n` ,
266+ } ,
267+ [ "test_multi_main.rs" ] ,
268+ ] ,
251269 javascript : [ null , null ] ,
252270 typescript : [ null , null ] ,
253271 } satisfies Record <
@@ -280,6 +298,7 @@ export function defineTests(
280298 `File.open("${ targetFile } ", "w") {|f| f.write("${ msg } ") }` ,
281299 ] ,
282300 cpp : [ null , null ] ,
301+ rust : [ null , null ] ,
283302 javascript : [ null , null ] ,
284303 typescript : [ null , null ] ,
285304 } satisfies Record < RuntimeLang , [ string , string ] | [ null , null ] >
0 commit comments