@@ -5,7 +5,7 @@ import { emptyMutex, RuntimeContext, RuntimeLang } from "./runtime";
55export function defineTests (
66 lang : RuntimeLang ,
77 runtimeRef : RefObject < Record < RuntimeLang , RuntimeContext > > ,
8- filesRef : RefObject < Readonly < Record < string , string > > > ,
8+ filesRef : RefObject < Readonly < Record < string , string > > >
99) {
1010 describe ( `${ lang } Runtime` , function ( ) {
1111 this . timeout (
@@ -35,6 +35,7 @@ export function defineTests(
3535 ruby : `puts "${ msg } "` ,
3636 cpp : null ,
3737 javascript : `console.log("${ msg } ")` ,
38+ typescript : null ,
3839 } satisfies Record < RuntimeLang , string | null >
3940 ) [ lang ] ;
4041 if ( ! printCode ) {
@@ -64,6 +65,7 @@ export function defineTests(
6465 `var ${ varName } = ${ value } ` ,
6566 `console.log(${ varName } )` ,
6667 ] ,
68+ typescript : [ null , null ] ,
6769 } satisfies Record < RuntimeLang , string [ ] | null [ ] >
6870 ) [ lang ] ;
6971 if ( ! setIntVarCode || ! printIntVarCode ) {
@@ -92,6 +94,7 @@ export function defineTests(
9294 ruby : `raise "${ errorMsg } "` ,
9395 cpp : null ,
9496 javascript : `throw new Error("${ errorMsg } ")` ,
97+ typescript : null ,
9598 } satisfies Record < RuntimeLang , string | null >
9699 ) [ lang ] ;
97100 if ( ! errorCode ) {
@@ -117,6 +120,7 @@ export function defineTests(
117120 `while(true) {}` ,
118121 `console.log(testVar)` ,
119122 ] ,
123+ typescript : [ null , null , null ] ,
120124 } satisfies Record < RuntimeLang , ( string | null ) [ ] >
121125 ) [ lang ] ;
122126 if ( ! setIntVarCode || ! infLoopCode || ! printIntVarCode ) {
@@ -163,12 +167,15 @@ export function defineTests(
163167 `#include <iostream>\nint main() {\n std::cout << "${ msg } " << std::endl;\n return 0;\n}\n` ,
164168 ] ,
165169 javascript : [ "test.js" , `console.log("${ msg } ")` ] ,
170+ typescript : [ "test.ts" , `console.log("${ msg } ")` ] ,
166171 } satisfies Record < RuntimeLang , [ string , string ] | [ null , null ] >
167172 ) [ lang ] ;
168173 if ( ! filename || ! code ) {
169174 this . skip ( ) ;
170175 }
171- const result = await runtimeRef . current [ lang ] . runFiles ( [ filename ] , { [ filename ] : code } ) ;
176+ const result = await runtimeRef . current [ lang ] . runFiles ( [ filename ] , {
177+ [ filename ] : code ,
178+ } ) ;
172179 console . log ( `${ lang } single file stdout test: ` , result ) ;
173180 expect ( result ) . to . be . deep . equal ( [
174181 {
@@ -189,12 +196,16 @@ export function defineTests(
189196 `#include <stdexcept>\nint main() {\n throw std::runtime_error("${ errorMsg } ");\n return 0;\n}\n` ,
190197 ] ,
191198 javascript : [ "test_error.js" , `throw new Error("${ errorMsg } ");\n` ] ,
199+ // TODO: tscが出す型エラーのテストはできていない
200+ typescript : [ "test_error.ts" , `throw new Error("${ errorMsg } ");\n` ] ,
192201 } satisfies Record < RuntimeLang , [ string , string ] | [ null , null ] >
193202 ) [ lang ] ;
194203 if ( ! filename || ! code ) {
195204 this . skip ( ) ;
196205 }
197- const result = await runtimeRef . current [ lang ] . runFiles ( [ filename ] , { [ filename ] : code } ) ;
206+ const result = await runtimeRef . current [ lang ] . runFiles ( [ filename ] , {
207+ [ filename ] : code ,
208+ } ) ;
198209 console . log ( `${ lang } single file error capture test: ` , result ) ;
199210 // eslint-disable-next-line @typescript-eslint/no-unused-expressions
200211 expect ( result . filter ( ( r ) => r . message . includes ( errorMsg ) ) ) . to . not . be
@@ -231,6 +242,7 @@ export function defineTests(
231242 [ "test_multi_main.cpp" , "test_multi_sub.cpp" ] ,
232243 ] ,
233244 javascript : [ null , null ] ,
245+ typescript : [ null , null ] ,
234246 } satisfies Record <
235247 RuntimeLang ,
236248 [ Record < string , string > , string [ ] ] | [ null , null ]
@@ -239,7 +251,10 @@ export function defineTests(
239251 if ( ! codes || ! execFiles ) {
240252 this . skip ( ) ;
241253 }
242- const result = await runtimeRef . current [ lang ] . runFiles ( execFiles , codes ) ;
254+ const result = await runtimeRef . current [ lang ] . runFiles (
255+ execFiles ,
256+ codes
257+ ) ;
243258 console . log ( `${ lang } multifile stdout test: ` , result ) ;
244259 expect ( result ) . to . be . deep . equal ( [
245260 {
0 commit comments