mirror of
https://github.com/DaanVandenBosch/phantasmal-world.git
synced 2025-04-05 07:18:29 +08:00
Moved a function to test utils.
This commit is contained in:
parent
cb81b988e5
commit
064f0659e4
@ -1,5 +1,3 @@
|
||||
import { assemble } from "../assembly";
|
||||
import { InstructionSegment, SegmentType } from "../instructions";
|
||||
import { OP_ADDI, OP_DIVI, OP_MULI, OP_SUBI, Opcode } from "../opcodes";
|
||||
import { ControlFlowGraph } from "./ControlFlowGraph";
|
||||
import {
|
||||
@ -8,6 +6,7 @@ import {
|
||||
register_value,
|
||||
REGISTER_VALUES,
|
||||
} from "./register_value";
|
||||
import { to_instructions } from "../../../../test/src/utils";
|
||||
|
||||
test(`trivial case`, () => {
|
||||
const im = to_instructions(`
|
||||
@ -174,14 +173,3 @@ test(`get_random`, () => {
|
||||
expect(v2.size()).toBe(5);
|
||||
expect(v2.to_array()).toEqual([20, 21, 22, 23, 24]);
|
||||
});
|
||||
|
||||
function to_instructions(assembly: string): InstructionSegment[] {
|
||||
const { object_code, warnings, errors } = assemble(assembly.split("\n"));
|
||||
|
||||
expect(warnings).toEqual([]);
|
||||
expect(errors).toEqual([]);
|
||||
|
||||
return object_code.filter(
|
||||
segment => segment.type === SegmentType.Instructions,
|
||||
) as InstructionSegment[];
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
import * as fs from "fs";
|
||||
import { InstructionSegment, SegmentType } from "../../src/quest_editor/scripting/instructions";
|
||||
import { assemble } from "../../src/quest_editor/scripting/assembly";
|
||||
|
||||
/**
|
||||
* Applies f to all QST files in a directory.
|
||||
@ -46,3 +48,14 @@ export function get_qst_files(dir: string): [string, string][] {
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
export function to_instructions(assembly: string, manual_stack?: boolean): InstructionSegment[] {
|
||||
const { object_code, warnings, errors } = assemble(assembly.split("\n"), manual_stack);
|
||||
|
||||
expect(warnings).toEqual([]);
|
||||
expect(errors).toEqual([]);
|
||||
|
||||
return object_code.filter(
|
||||
segment => segment.type === SegmentType.Instructions,
|
||||
) as InstructionSegment[];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user