-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
105 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { default as code } from "./code.js?raw"; | ||
export * from './runner' | ||
|
||
export { default as code } from "./code.js?raw"; | ||
export { default as Worker } from './worker?worker' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { createLogger } from "libs/logger"; | ||
import type { TestRunnerFactory } from "testing"; | ||
import { JsTestRunner } from 'testing-javascript' | ||
|
||
import type { Input, Output } from "../tests-data"; | ||
import type { PaymentSystemType } from "../reference"; | ||
|
||
interface TestingModule { | ||
payment(type: PaymentSystemType, base: number, amount: number): number; | ||
} | ||
|
||
export class TestRunner extends JsTestRunner<TestingModule, Input, Output> { | ||
async executeTest(m: TestingModule, input: Input): Promise<Output> { | ||
return m.payment(input.paymentSystem, input.base, input.amount); | ||
} | ||
} | ||
|
||
export const factory: TestRunnerFactory<Input, Output> = async (_, { code, out }) => | ||
new TestRunner(createLogger(out), code); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,5 @@ | ||
import { createLogger } from "libs/logger"; | ||
import type { TestRunnerFactory } from "testing"; | ||
import { startTestRunnerActor } from "testing/actor"; | ||
import { JsTestRunner } from 'testing-javascript' | ||
|
||
import type { Input, Output } from "../tests-data"; | ||
import type { PaymentSystemType } from "../reference"; | ||
|
||
interface TestingModule { | ||
payment(type: PaymentSystemType, base: number, amount: number): number; | ||
} | ||
|
||
class TestRunner extends JsTestRunner<TestingModule, Input, Output> { | ||
async executeTest(m: TestingModule, input: Input): Promise<Output> { | ||
return m.payment(input.paymentSystem, input.base, input.amount); | ||
} | ||
} | ||
|
||
const factory: TestRunnerFactory<Input, Output> = async (_, { code, out }) => | ||
new TestRunner(createLogger(out), code); | ||
import { factory } from './runner'; | ||
|
||
startTestRunnerActor(factory); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { default as code } from './code.php?raw' | ||
export * from './runner' | ||
|
||
export { default as code } from './code.php?raw' | ||
export { default as Worker } from './worker?worker' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import type { TestRunnerFactory } from "testing"; | ||
import { FailSafePHP, PHPTestRunner, phpRuntimeFactory } from "testing-php"; | ||
|
||
import type { Input, Output } from "../tests-data"; | ||
import { PaymentSystemType } from "../reference"; | ||
|
||
const PHP_PAYMENT_SYSTEM_TYPES: Record<PaymentSystemType, string> = { | ||
[PaymentSystemType.PayPal]: "PaymentSystemType::PAYPAL", | ||
[PaymentSystemType.WebMoney]: "PaymentSystemType::WEBMONEY", | ||
[PaymentSystemType.CatBank]: "PaymentSystemType::CAT_BANK", | ||
}; | ||
|
||
export class TestRunner extends PHPTestRunner<Input, Output> { | ||
protected override caseExecutionCode({ | ||
paymentSystem, | ||
base, | ||
amount, | ||
}: Input): string { | ||
return `strval(payment(${PHP_PAYMENT_SYSTEM_TYPES[paymentSystem]}, ${base}, ${amount}))`; | ||
} | ||
protected transformResult(result: string): Output { | ||
const r = parseInt(result, 10); | ||
if (isNaN(r)) { | ||
throw new Error(`Invalid result type: ${result}, expected number`); | ||
} | ||
return r; | ||
} | ||
} | ||
|
||
export const factory: TestRunnerFactory<Input, Output> = async ( | ||
_, | ||
{ code, out } | ||
) => new TestRunner(out, new FailSafePHP(phpRuntimeFactory), code); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,5 @@ | ||
import type { TestRunnerFactory } from "testing"; | ||
import { startTestRunnerActor } from "testing/actor"; | ||
import { FailSafePHP, PHPTestRunner, phpRuntimeFactory } from "testing-php"; | ||
|
||
import type { Input, Output } from "../tests-data"; | ||
import { PaymentSystemType } from "../reference"; | ||
|
||
const PHP_PAYMENT_SYSTEM_TYPES: Record<PaymentSystemType, string> = { | ||
[PaymentSystemType.PayPal]: "PaymentSystemType::PAYPAL", | ||
[PaymentSystemType.WebMoney]: "PaymentSystemType::WEBMONEY", | ||
[PaymentSystemType.CatBank]: "PaymentSystemType::CAT_BANK", | ||
}; | ||
|
||
class TestRunner extends PHPTestRunner<Input, Output> { | ||
protected override caseExecutionCode({ | ||
paymentSystem, | ||
base, | ||
amount, | ||
}: Input): string { | ||
return `strval(payment(${PHP_PAYMENT_SYSTEM_TYPES[paymentSystem]}, ${base}, ${amount}))`; | ||
} | ||
protected transformResult(result: string): Output { | ||
const r = parseInt(result, 10); | ||
if (isNaN(r)) { | ||
throw new Error(`Invalid result type: ${result}, expected number`); | ||
} | ||
return r; | ||
} | ||
} | ||
|
||
const factory: TestRunnerFactory<Input, Output> = async ( | ||
_, | ||
{ code, out } | ||
) => new TestRunner(out, new FailSafePHP(phpRuntimeFactory), code); | ||
import { factory } from './runner'; | ||
|
||
startTestRunnerActor(factory); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { default as code } from "./code.py?raw" | ||
export * from './runner' | ||
|
||
export { default as code } from "./code.py?raw" | ||
export { default as Worker } from "./worker?worker" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { createLogger } from "libs/logger"; | ||
import type { TestRunnerFactory } from "testing"; | ||
import { PyTestRunner, pyRuntimeFactory } from "testing-python"; | ||
|
||
import type { Input, Output } from "../tests-data"; | ||
|
||
export class TestRunner extends PyTestRunner<Input, Output> { | ||
protected override caseExecutionCode({ | ||
paymentSystem, | ||
base, | ||
amount, | ||
}: Input): string { | ||
return `payment("${paymentSystem}", ${base}, ${amount})`; | ||
} | ||
} | ||
|
||
export const factory: TestRunnerFactory<Input, Output> = async ( | ||
ctx, | ||
{ code, out } | ||
) => new TestRunner(await pyRuntimeFactory(ctx, createLogger(out)), code); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,5 @@ | ||
import { createLogger } from 'libs/logger'; | ||
import type { TestRunnerFactory } from "testing"; | ||
import { startTestRunnerActor } from "testing/actor"; | ||
import { PyTestRunner, pyRuntimeFactory } from "testing-python"; | ||
|
||
import type { Input, Output } from "../tests-data"; | ||
|
||
class TestRunner extends PyTestRunner<Input, Output> { | ||
protected override caseExecutionCode({ paymentSystem, base, amount }: Input): string { | ||
return `payment("${paymentSystem}", ${base}, ${amount})`; | ||
} | ||
} | ||
|
||
const factory: TestRunnerFactory<Input, Output> = async (ctx, { code, out }) => | ||
new TestRunner(await pyRuntimeFactory(ctx, createLogger(out)), code); | ||
import { factory } from "./runner"; | ||
|
||
startTestRunnerActor(factory); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { default as code } from './code.ts?raw' | ||
export * from './runner.js' | ||
|
||
export { default as code } from './code.ts?raw' | ||
export { default as Worker } from './worker?worker' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { createLogger } from "libs/logger"; | ||
import type { TestRunnerConfig, TestRunnerFactory } from "testing"; | ||
import { TsTestRunner } from "testing-typescript"; | ||
|
||
import type { Input, Output } from "../tests-data"; | ||
import type { PaymentSystemType } from "../reference"; | ||
|
||
interface TestingModule { | ||
payment(type: PaymentSystemType, base: number, amount: number): number; | ||
} | ||
|
||
export class TestRunner extends TsTestRunner<TestingModule, Input, Output> { | ||
async executeTest(m: TestingModule, input: Input): Promise<Output> { | ||
return m.payment(input.paymentSystem, input.base, input.amount); | ||
} | ||
} | ||
|
||
export const factory: TestRunnerFactory<Input, Output> = async ( | ||
_, | ||
{ code, out }: TestRunnerConfig | ||
) => new TestRunner(createLogger(out), code); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,5 @@ | ||
import { createLogger } from "libs/logger"; | ||
import type { TestRunnerConfig, TestRunnerFactory } from "testing"; | ||
import { startTestRunnerActor } from "testing/actor"; | ||
import { TsTestRunner } from "testing-typescript"; | ||
|
||
import type { Input, Output } from "../tests-data"; | ||
import type { PaymentSystemType } from "../reference"; | ||
|
||
interface TestingModule { | ||
payment(type: PaymentSystemType, base: number, amount: number): number; | ||
} | ||
|
||
class TestRunner extends TsTestRunner<TestingModule, Input, Output> { | ||
async executeTest(m: TestingModule, input: Input): Promise<Output> { | ||
return m.payment(input.paymentSystem, input.base, input.amount); | ||
} | ||
} | ||
|
||
const factory: TestRunnerFactory<Input, Output> = async ( | ||
_, | ||
{ code, out }: TestRunnerConfig | ||
) => new TestRunner(createLogger(out), code); | ||
import { factory } from './runner.js' | ||
|
||
startTestRunnerActor(factory); |