Skip to content

Commit

Permalink
frontend: Prepare new helper methods for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dinfuehr committed Nov 15, 2024
1 parent ec59005 commit 6e936ff
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions dora-frontend/src/generator/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ use self::Bytecode::*;
use crate::generator::{bty_from_ty, generate_fct_id};
use crate::sema::{create_tuple, find_impl, FctDefinitionId, Sema, TypeParamDefinition};
use crate::sema::{
ClassDefinitionId, ConstDefinitionId, EnumDefinitionId, FieldId, GlobalDefinitionId,
ClassDefinitionId, ConstDefinitionId, EnumDefinitionId, FieldId, GlobalDefinitionId, SemaFlags,
StructDefinitionId, TraitDefinitionId,
};
use crate::stdlib_lookup::lookup_fct;
use crate::sym::ModuleSymTable;
use crate::typeck::find_method_call_candidates;
use crate::{check_program, SourceType, SourceTypeArray, TraitType};
use crate::{empty_sta, test, ty};
use crate::{SourceType, SourceTypeArray, TraitType};
use dora_bytecode::{
self as bytecode, BytecodeFunction, BytecodeOffset, BytecodeType, BytecodeTypeArray,
BytecodeVisitor, ClassId, ConstPoolEntry, ConstPoolIdx, EnumId, FunctionId, GlobalId, Register,
Expand Down Expand Up @@ -60,6 +60,24 @@ fn code_method_with_struct_name(code: &'static str, struct_name: &'static str) -
})
}

#[allow(unused)]
fn setup(code: &'static str) -> Sema {
let args: SemaFlags = SemaFlags::for_test(code);
let mut sa = Sema::new(args);

let result = check_program(&mut sa);
assert!(result);

sa
}

#[allow(unused)]
fn bc(sa: &Sema, path: &str) -> Vec<Bytecode> {
let fct_id = lookup_fct(sa, path);
let fct = generate_fct_id(sa, fct_id);
build(&fct)
}

fn gen<F>(code: &'static str, testfct: F)
where
F: FnOnce(&Sema, Vec<Bytecode>),
Expand Down

0 comments on commit 6e936ff

Please sign in to comment.