Skip to content

Commit

Permalink
better name
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbclifford committed Dec 30, 2023
1 parent 2732025 commit 92e5dcc
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions tests/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ pub fn write() {
let console = BaseType::class(ctx.console).into();
let test_attr_t: MethodType = BaseType::class(test_attr).into();

common::WriteTestResult::WithVariables {
common::MainMethod::WithVariables {
locals: vec![
LocalVariable::new(ctype! { object[] }),
LocalVariable::new(ctype! { int }),
Expand All @@ -170,7 +170,7 @@ pub fn write() {
LocalVariable::new(ctype! { object[] }),
LocalVariable::new(ctype! { int }),
],
main_body: asm! {
body: asm! {
load_token_type BaseType::class(ctx.class);
call get_type;
LoadTokenType test_attr_t;
Expand Down
16 changes: 8 additions & 8 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,22 @@ pub fn read_fixture(name: &str, source: &str, test: impl FnOnce(Resolution)) ->
Ok(())
}

pub enum WriteTestResult {
MainBody(Vec<Instruction>),
pub enum MainMethod {
Body(Vec<Instruction>),
WithVariables {
main_body: Vec<Instruction>,
body: Vec<Instruction>,
locals: Vec<LocalVariable>
},
WithExceptions {
main_body: Vec<Instruction>,
body: Vec<Instruction>,
locals: Vec<LocalVariable>,
exceptions: Vec<body::Exception>
}
}

pub fn write_fixture(
name: &str,
test: impl FnOnce(&mut WriteContext) -> WriteTestResult,
test: impl FnOnce(&mut WriteContext) -> MainMethod,
expect: &[u8],
) -> Result<(), Box<dyn std::error::Error>> {
let dll_name = format!("{}.dll", name);
Expand Down Expand Up @@ -110,9 +110,9 @@ pub fn write_fixture(
};

let (exceptions, vars, ins) = match test(&mut ctx) {
WriteTestResult::MainBody(ins) => (vec![], vec![], ins),
WriteTestResult::WithVariables { main_body, locals } => (vec![], locals, main_body),
WriteTestResult::WithExceptions { main_body, locals, exceptions } => (exceptions, locals, main_body),
MainMethod::Body(ins) => (vec![], vec![], ins),
MainMethod::WithVariables { body: main_body, locals } => (vec![], locals, main_body),
MainMethod::WithExceptions { body: main_body, locals, exceptions } => (exceptions, locals, main_body),
};

let main = ctx.resolution.push_method(
Expand Down
4 changes: 2 additions & 2 deletions tests/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,12 @@ pub fn write() {
let add = ctx.resolution.event_add_index(event);
let remove = ctx.resolution.event_remove_index(event);

common::WriteTestResult::WithVariables {
common::MainMethod::WithVariables {
locals: vec![
LocalVariable::new(BaseType::class(ctx.class).into()),
LocalVariable::new(handler_method),
],
main_body: asm! {
body: asm! {
// init obj
new_object ctx.default_ctor;
StoreLocal 0;
Expand Down
4 changes: 2 additions & 2 deletions tests/exceptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ pub fn write() {
Return;
};

common::WriteTestResult::WithExceptions {
common::MainMethod::WithExceptions {
exceptions: vec![
body::Exception {
kind: body::ExceptionKind::Filter { offset: filter_start },
Expand All @@ -187,7 +187,7 @@ pub fn write() {
}
],
locals: vec![LocalVariable::new(ctype! { object })],
main_body: instructions
body: instructions
}
},
b"before throw\nerror code 1\nfinally\n",
Expand Down
4 changes: 2 additions & 2 deletions tests/fields_props.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ pub fn write() {
),
);

common::WriteTestResult::WithVariables {
common::MainMethod::WithVariables {
locals: vec![LocalVariable::new(BaseType::class(ctx.class).into())],
main_body: asm! {
body: asm! {
// init static
LoadConstantInt32 -1;
call static_setter;
Expand Down
8 changes: 4 additions & 4 deletions tests/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ pub fn write() {
.resolution
.push_method_reference(method_ref! { static void #console_type::WriteLine(string, object) });

common::WriteTestResult::WithVariables {
common::MainMethod::WithVariables {
locals: vec![LocalVariable::new(enum_class)],
main_body: asm! {
body: asm! {
LoadConstantInt32 5;
call init_class;
call_virtual get_enum;
Expand Down Expand Up @@ -258,12 +258,12 @@ pub fn write_generic_class() {
let string_container: MethodType =
BaseType::class(TypeSource::generic(container, vec![ctype! { string }])).into();

common::WriteTestResult::WithVariables {
common::MainMethod::WithVariables {
locals: vec![
LocalVariable::new(int_container.clone()),
LocalVariable::new(string_container.clone()),
],
main_body: asm! {
body: asm! {
new_object ctx.resolution.push_method_reference(method_ref! { void @int_container::.ctor() });
StoreLocal 0;
new_object ctx.resolution.push_method_reference(method_ref! { void @string_container::.ctor() });
Expand Down
2 changes: 1 addition & 1 deletion tests/hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub fn write() {
.resolution
.push_method_reference(method_ref! { static void #console_type::WriteLine(string) });

common::WriteTestResult::MainBody(
common::MainMethod::Body(
asm! {
load_string "Hello, world!";
call write_line;
Expand Down
4 changes: 2 additions & 2 deletions tests/oop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ pub fn write() {

let console: MethodType = BaseType::class(ctx.console).into();

common::WriteTestResult::WithVariables {
common::MainMethod::WithVariables {
locals: vec![LocalVariable::new(array_list.clone()), LocalVariable::new(enumerator.clone())],
main_body: asm! {
body: asm! {
new_object ctx.resolution.push_method_reference(method_ref! { void @array_list::.ctor() });
StoreLocal 0;
LoadLocal 0;
Expand Down
2 changes: 1 addition & 1 deletion tests/pinvoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub fn write() {

let puts = libc_method("puts", msig! { static void (string) });

common::WriteTestResult::MainBody(
common::MainMethod::Body(
asm! {
load_string "hello from libc";
call puts;
Expand Down
2 changes: 1 addition & 1 deletion tests/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub fn write() {
.push_type_reference(type_ref! { System.Reflection.Assembly in #mscorlib })
).into();

common::WriteTestResult::MainBody(
common::MainMethod::Body(
asm! {
load_string "strings";
load_token_type BaseType::class(ctx.class);
Expand Down

0 comments on commit 92e5dcc

Please sign in to comment.