Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Test step_type and step_type_def
Browse files Browse the repository at this point in the history
  • Loading branch information
nullbitx8 committed Nov 7, 2023
1 parent 099324c commit d5a6354
Showing 1 changed file with 56 additions and 1 deletion.
57 changes: 56 additions & 1 deletion src/frontend/dsl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,61 @@ mod tests {
assert_eq!(
context.circuit.annotations[&handler.uuid()],
"fibo_first_step"
)
);
}

#[test]
fn test_step_type_def() {
// create circuit context
let circuit: Circuit<i32, i32> = Circuit::default();
let mut context = CircuitContext {
circuit,
tables: Default::default(),
};

// create a step type including its definition
let simple_step = context.step_type_def("simple_step", |context| {
context.setup(|_| {});
context.wg(|_, _: u32| {})
});

// assert step type was created and added to the circuit
assert_eq!(
context.circuit.annotations[&simple_step.uuid()],
"simple_step"
);
assert_eq!(
simple_step.uuid(),
context.circuit.step_types[&simple_step.uuid()].uuid()
);
}

#[test]
fn test_step_type_def_pass_handler() {
// create circuit context
let circuit: Circuit<i32, i32> = Circuit::default();
let mut context = CircuitContext {
circuit,
tables: Default::default(),
};

// create a step type handler
let handler: StepTypeHandler = context.step_type("simple_step");

// create a step type including its definition
let simple_step = context.step_type_def(handler, |context| {
context.setup(|_| {});
context.wg(|_, _: u32| {})
});

// assert step type was created and added to the circuit
assert_eq!(
context.circuit.annotations[&simple_step.uuid()],
"simple_step"
);
assert_eq!(
simple_step.uuid(),
context.circuit.step_types[&simple_step.uuid()].uuid()
);
}
}

0 comments on commit d5a6354

Please sign in to comment.