use std::collections::HashMap;
use std::path::{Path, PathBuf};
use std::time::Instant;
use bock_air::{
lower_module, resolve_names_with_registry, Binding, ModuleRegistry, NameKind, NodeIdGen,
NodeKind, ResolvedName, SymbolTable,
};
use bock_ast::Visibility;
use bock_build::dep_graph::{self, DepGraph};
use bock_errors::{Diagnostic, DiagnosticBag, FileId, Severity, Span};
use bock_interp::Interpreter;
use bock_lexer::Lexer;
use bock_parser::Parser;
use bock_source::SourceMap;
use bock_types::{
collect_exports, seed_imports, seed_prelude, FnType, PrimitiveType, Strictness, Type,
TypeChecker,
};
struct TestResult {
name: String,
passed: bool,
error: Option<String>,
duration: std::time::Duration,
}
struct CompiledTestFile {
air_modules_in_order: Vec<bock_air::AIRNode>,
test_items: Vec<bock_air::AIRNode>,
}
pub async fn run(filter: Option<String>, files: Vec<PathBuf>) -> anyhow::Result<()> {
let files = if files.is_empty() {
discover_bock_files(Path::new("."))?
} else {
files
};
if files.is_empty() {
println!("No .bock files found.");
return Ok(());
}
let total_start = Instant::now();
let mut results: Vec<TestResult> = Vec::new();
for file_path in &files {
match run_tests_in_file(file_path, &filter).await {
Ok(mut file_results) => results.append(&mut file_results),
Err(e) => {
eprintln!("error: {}: {e}", file_path.display());
results.push(TestResult {
name: file_path.display().to_string(),
passed: false,
error: Some(format!("compilation error: {e}")),
duration: std::time::Duration::ZERO,
});
}
}
}
let total_duration = total_start.elapsed();
if results.is_empty() {
println!("No tests found.");
return Ok(());
}
println!();
let mut passed = 0usize;
let mut failed = 0usize;
for result in &results {
if result.passed {
passed += 1;
println!(
" \x1b[32mPASS\x1b[0m {} ({:.1}ms)",
result.name,
result.duration.as_secs_f64() * 1000.0
);
} else {
failed += 1;
println!(
" \x1b[31mFAIL\x1b[0m {} ({:.1}ms)",
result.name,
result.duration.as_secs_f64() * 1000.0
);
if let Some(ref err) = result.error {
println!(" {err}");
}
}
}
let total = passed + failed;
println!();
println!(
"Tests: {passed} passed, {failed} failed, {total} total ({:.2}s)",
total_duration.as_secs_f64()
);
if failed > 0 {
std::process::exit(1);
}
Ok(())
}
async fn run_tests_in_file(
path: &Path,
filter: &Option<String>,
) -> anyhow::Result<Vec<TestResult>> {
let compiled = compile_test_file(path)?;
let test_fns = discover_test_functions(&compiled.test_items, filter);
if test_fns.is_empty() {
return Ok(Vec::new());
}
let filename = path.display().to_string();
let file_stem = path
.file_stem()
.map(|s| s.to_string_lossy().to_string())
.unwrap_or_else(|| filename.clone());
let mut results = Vec::new();
for (test_name, _test_node_idx) in &test_fns {
let qualified_name = format!("{file_stem}::{test_name}");
let start = Instant::now();
let result = run_single_test(&compiled.air_modules_in_order, test_name).await;
let duration = start.elapsed();
match result {
Ok(()) => results.push(TestResult {
name: qualified_name,
passed: true,
error: None,
duration,
}),
Err(e) => results.push(TestResult {
name: qualified_name,
passed: false,
error: Some(e),
duration,
}),
}
}
Ok(results)
}
fn compile_test_file(path: &Path) -> anyhow::Result<CompiledTestFile> {
let content =
std::fs::read_to_string(path).map_err(|e| anyhow::anyhow!("{}: {e}", path.display()))?;
let mut source_map = SourceMap::new();
let mut parsed_files: Vec<ParsedFile> = Vec::new();
for src in crate::stdlib::core_sources() {
let pf = parse_stdlib_source(&src, &mut source_map)?;
parsed_files.push(pf);
}
let entry_canonical = path.canonicalize().unwrap_or_else(|_| path.to_path_buf());
if let Some(root) = find_project_root(path) {
for sibling in discover_bock_files(&root)? {
let sibling_canonical = sibling.canonicalize().unwrap_or_else(|_| sibling.clone());
if sibling_canonical == entry_canonical {
continue;
}
let sibling_content = std::fs::read_to_string(&sibling)
.map_err(|e| anyhow::anyhow!("{}: {e}", sibling.display()))?;
let pf = parse_user_file(&sibling, &sibling_content, &mut source_map)?;
parsed_files.push(pf);
}
}
let test_pf = parse_user_file(path, &content, &mut source_map)?;
let test_idx = parsed_files.len();
parsed_files.push(test_pf);
let mut dep_graph = DepGraph::new();
let mut id_to_index: HashMap<String, usize> = HashMap::new();
let core_module_ids: Vec<String> = parsed_files
.iter()
.enumerate()
.filter(|(_, pf)| pf.is_stdlib)
.map(|(i, pf)| dep_graph::module_id_from_module(&pf.module, i))
.collect();
for (i, pf) in parsed_files.iter().enumerate() {
let module_id = dep_graph::module_id_from_module(&pf.module, i);
let mut deps = dep_graph::extract_dependencies(&pf.module.imports);
if !pf.is_stdlib {
dep_graph::add_prelude_deps(&mut deps, &module_id, &core_module_ids);
}
dep_graph.add_module_with_deps(module_id.clone(), deps);
id_to_index.insert(module_id, i);
}
let topo_order = dep_graph
.topological_order()
.ok_or_else(|| anyhow::anyhow!("circular module dependency detected"))?;
let mut registry = ModuleRegistry::new();
let mut air_modules: HashMap<usize, bock_air::AIRNode> = HashMap::new();
for module_id in &topo_order {
let Some(&idx) = id_to_index.get(module_id) else {
continue; };
let pf = &parsed_files[idx];
let source_file = source_map.get_file(pf.file_id);
let mut all_diagnostics: Vec<Diagnostic> = Vec::new();
let mut symbols = SymbolTable::new();
register_builtins(&mut symbols);
let resolve_diags = resolve_names_with_registry(&pf.module, &mut symbols, ®istry);
collect_diagnostics(&mut all_diagnostics, &resolve_diags);
if has_errors(&all_diagnostics) {
return Err(format_errors(
&all_diagnostics,
&pf.filename,
&source_file.content,
));
}
let id_gen = NodeIdGen::new();
let mut air_module = lower_module(&pf.module, &id_gen, &symbols);
let mut checker = TypeChecker::new();
register_type_builtins(&mut checker);
seed_prelude(&mut checker, ®istry);
seed_imports(&mut checker, &pf.module.imports, ®istry);
checker.check_module(&mut air_module);
collect_diagnostics(&mut all_diagnostics, &checker.diags);
if has_errors(&all_diagnostics) {
return Err(format_errors(
&all_diagnostics,
&pf.filename,
&source_file.content,
));
}
let ownership_diags = bock_types::analyze_ownership(&air_module);
collect_as_warnings(&mut all_diagnostics, &ownership_diags);
let strictness = Strictness::Development;
let effect_diags = bock_types::track_effects(&air_module, strictness);
collect_as_warnings(&mut all_diagnostics, &effect_diags);
let capability_diags = bock_types::verify_capabilities(&air_module, strictness);
collect_as_warnings(&mut all_diagnostics, &capability_diags);
if !pf.is_stdlib {
let warnings: Vec<&Diagnostic> = all_diagnostics
.iter()
.filter(|d| d.severity == Severity::Warning)
.collect();
if !warnings.is_empty() {
let to_render: Vec<Diagnostic> = warnings.into_iter().cloned().collect();
let rendered = bock_errors::render(&to_render, &pf.filename, &source_file.content);
eprint!("{rendered}");
}
}
let exports = collect_exports(module_id, &pf.path, &checker, &air_module);
registry.register(exports);
air_modules.insert(idx, air_module);
}
let mut air_modules_in_order: Vec<bock_air::AIRNode> = Vec::new();
let mut test_items: Option<Vec<bock_air::AIRNode>> = None;
for module_id in &topo_order {
let Some(&idx) = id_to_index.get(module_id) else {
continue;
};
if let Some(m) = air_modules.remove(&idx) {
if idx == test_idx {
let items = match &m.kind {
NodeKind::Module { items, .. } => items.clone(),
_ => return Err(anyhow::anyhow!("internal: expected Module node")),
};
test_items = Some(items);
}
air_modules_in_order.push(m);
}
}
let test_items = test_items
.ok_or_else(|| anyhow::anyhow!("internal: test module not found among compiled modules"))?;
Ok(CompiledTestFile {
air_modules_in_order,
test_items,
})
}
async fn run_single_test(
air_modules_in_order: &[bock_air::AIRNode],
test_name: &str,
) -> Result<(), String> {
let mut interp = Interpreter::new();
bock_core::register_core(&mut interp.builtins);
interp.builtins.register_test_builtins();
for air_module in air_modules_in_order {
register_module_in_interpreter(&mut interp, air_module).await?;
}
let test_val = match interp.env.get(test_name) {
Some(v) => v.clone(),
None => {
return Err(format!(
"test function '{test_name}' not found in environment"
))
}
};
match interp.call_fn_value(&test_val, vec![]).await {
Ok(_) => Ok(()),
Err(e) => Err(e.to_string()),
}
}
async fn register_module_in_interpreter(
interp: &mut Interpreter,
air_module: &bock_air::AIRNode,
) -> Result<(), String> {
let items = match &air_module.kind {
NodeKind::Module { items, .. } => items.clone(),
_ => return Ok(()),
};
for item in &items {
match &item.kind {
NodeKind::FnDecl {
name,
params,
body,
is_async,
..
} => {
let param_names: Vec<String> =
params.iter().filter_map(extract_param_name).collect();
interp.register_fn_with_async(&name.name, param_names, *body.clone(), *is_async);
}
NodeKind::EnumDecl { name, variants, .. } => {
interp.register_enum(&name.name, variants);
}
NodeKind::ConstDecl { name, value, .. } => match interp.eval_expr(value).await {
Ok(val) => interp.env.define(&name.name, val),
Err(e) => return Err(format!("setup error: {e}")),
},
NodeKind::ImplBlock {
target, methods, ..
} => {
interp.register_impl(target, methods);
}
NodeKind::EffectDecl {
name, operations, ..
} => {
interp.register_effect(&name.name, operations);
}
NodeKind::LetBinding { .. } | NodeKind::ModuleHandle { .. } => {
if let Err(e) = interp.eval_expr(item).await {
return Err(format!("setup error: {e}"));
}
}
_ => {}
}
}
Ok(())
}
fn discover_test_functions(
items: &[bock_air::AIRNode],
filter: &Option<String>,
) -> Vec<(String, usize)> {
let mut tests = Vec::new();
for (idx, item) in items.iter().enumerate() {
if let NodeKind::FnDecl {
name, annotations, ..
} = &item.kind
{
let is_test = annotations.iter().any(|a| a.name.name == "test");
if is_test {
let fn_name = name.name.clone();
if let Some(ref pattern) = filter {
if !fn_name.contains(pattern.as_str()) {
continue;
}
}
tests.push((fn_name, idx));
}
}
}
tests
}
fn extract_param_name(param: &bock_air::AIRNode) -> Option<String> {
if let NodeKind::Param { pattern, .. } = ¶m.kind {
if let NodeKind::BindPat { name, .. } = &pattern.kind {
return Some(name.name.clone());
}
}
None
}
struct ParsedFile {
path: PathBuf,
filename: String,
file_id: bock_errors::FileId,
module: bock_ast::Module,
is_stdlib: bool,
}
fn parse_user_file(
path: &Path,
content: &str,
source_map: &mut SourceMap,
) -> anyhow::Result<ParsedFile> {
let filename = path.display().to_string();
let file_id = source_map.add_file(path.to_path_buf(), content.to_string());
let source_file = source_map.get_file(file_id);
let mut diags: Vec<Diagnostic> = Vec::new();
let mut lexer = Lexer::new(source_file);
let tokens = lexer.tokenize();
collect_diagnostics(&mut diags, lexer.diagnostics());
if has_errors(&diags) {
return Err(format_errors(&diags, &filename, &source_file.content));
}
let mut parser = Parser::new(tokens, source_file);
let module = parser.parse_module();
collect_diagnostics(&mut diags, parser.diagnostics());
if has_errors(&diags) {
return Err(format_errors(&diags, &filename, &source_file.content));
}
Ok(ParsedFile {
path: path.to_path_buf(),
filename,
file_id,
module,
is_stdlib: false,
})
}
fn parse_stdlib_source(
src: &crate::stdlib::StdlibSource,
source_map: &mut SourceMap,
) -> anyhow::Result<ParsedFile> {
let filename = src.logical_path.display().to_string();
let file_id = source_map.add_file(src.logical_path.clone(), src.source.clone());
let source_file = source_map.get_file(file_id);
let mut diags: Vec<Diagnostic> = Vec::new();
let mut lexer = Lexer::new(source_file);
let tokens = lexer.tokenize();
collect_diagnostics(&mut diags, lexer.diagnostics());
if has_errors(&diags) {
return Err(format_errors(&diags, &filename, &source_file.content));
}
let mut parser = Parser::new(tokens, source_file);
let module = parser.parse_module();
collect_diagnostics(&mut diags, parser.diagnostics());
if has_errors(&diags) {
return Err(format_errors(&diags, &filename, &source_file.content));
}
Ok(ParsedFile {
path: src.logical_path.clone(),
filename,
file_id,
module,
is_stdlib: true,
})
}
fn collect_diagnostics(acc: &mut Vec<Diagnostic>, bag: &DiagnosticBag) {
for diag in bag.iter() {
acc.push(diag.clone());
}
}
fn collect_as_warnings(acc: &mut Vec<Diagnostic>, bag: &DiagnosticBag) {
for diag in bag.iter() {
let mut d = diag.clone();
if d.severity == Severity::Error {
d.severity = Severity::Warning;
}
acc.push(d);
}
}
fn has_errors(diagnostics: &[Diagnostic]) -> bool {
diagnostics.iter().any(|d| d.severity == Severity::Error)
}
fn format_errors(diagnostics: &[Diagnostic], filename: &str, source: &str) -> anyhow::Error {
let rendered = bock_errors::render(diagnostics, filename, source);
anyhow::anyhow!("{rendered}")
}
fn register_type_builtins(checker: &mut TypeChecker) {
let io_fn_ty = Type::Function(FnType {
params: vec![Type::Primitive(PrimitiveType::String)],
ret: Box::new(Type::Primitive(PrimitiveType::Void)),
effects: vec![],
});
for name in ["print", "println", "debug"] {
checker.env.define(name, io_fn_ty.clone());
}
for name in ["Duration", "Instant", "Channel"] {
checker.env.define(name, Type::Error);
}
let sleep_fn_ty = Type::Function(FnType {
params: vec![Type::Error],
ret: Box::new(Type::Primitive(PrimitiveType::Void)),
effects: vec![],
});
checker.env.define("sleep", sleep_fn_ty);
let spawn_fn_ty = Type::Function(FnType {
params: vec![Type::Error],
ret: Box::new(Type::Error),
effects: vec![],
});
checker.env.define("spawn", spawn_fn_ty);
let assert_ty = Type::Function(FnType {
params: vec![Type::Primitive(PrimitiveType::Bool)],
ret: Box::new(Type::Primitive(PrimitiveType::Void)),
effects: vec![],
});
checker.env.define("assert", assert_ty);
let expect_fn_ty = Type::Function(FnType {
params: vec![Type::Error],
ret: Box::new(Type::Error),
effects: vec![],
});
checker.env.define("expect", expect_fn_ty);
let never_fn_ty = Type::Function(FnType {
params: vec![],
ret: Box::new(Type::Primitive(PrimitiveType::Never)),
effects: vec![],
});
for name in ["todo", "unreachable"] {
checker.env.define(name, never_fn_ty.clone());
}
let constructor_fn_ty = Type::Function(FnType {
params: vec![Type::Error],
ret: Box::new(Type::Error),
effects: vec![],
});
for name in ["Ok", "Err", "Some"] {
checker.env.define(name, constructor_fn_ty.clone());
}
checker.env.define("None", Type::Error);
}
fn register_builtins(symbols: &mut SymbolTable) {
let builtin_span = Span {
file: FileId(0),
start: 0,
end: 0,
};
let builtins = [
("print", u32::MAX - 1),
("println", u32::MAX - 2),
("debug", u32::MAX - 3),
("expect", u32::MAX - 4),
];
for (name, def_id) in builtins {
symbols.define(
name.to_string(),
Binding {
name: name.to_string(),
resolved: ResolvedName {
def_id,
kind: NameKind::Function,
},
visibility: Visibility::Public,
span: builtin_span,
used: true,
is_import: false,
},
);
}
}
fn find_project_root(entry: &Path) -> Option<PathBuf> {
let canonical = entry.canonicalize().ok()?;
let mut current = canonical.parent()?;
loop {
if current.join("bock.project").is_file() {
return Some(current.to_path_buf());
}
current = current.parent()?;
}
}
fn discover_bock_files(dir: &Path) -> anyhow::Result<Vec<PathBuf>> {
let mut files = Vec::new();
discover_bock_files_recursive(dir, &mut files, true)?;
files.sort();
Ok(files)
}
fn discover_bock_files_recursive(
dir: &Path,
files: &mut Vec<PathBuf>,
is_root: bool,
) -> anyhow::Result<()> {
let entries = match std::fs::read_dir(dir) {
Ok(entries) => entries,
Err(e) if !is_root => {
eprintln!(
"warning: skipping unreadable directory '{}': {e}",
dir.display()
);
return Ok(());
}
Err(e) => {
return Err(anyhow::anyhow!(
"could not read directory '{}': {e}",
dir.display()
));
}
};
for entry in entries {
let entry = match entry {
Ok(entry) => entry,
Err(e) if !is_root => {
eprintln!(
"warning: skipping unreadable entry under '{}': {e}",
dir.display()
);
continue;
}
Err(e) => {
return Err(anyhow::anyhow!(
"could not read entry under '{}': {e}",
dir.display()
));
}
};
let path = entry.path();
if path.is_dir() {
let name = entry.file_name();
let name_str = name.to_string_lossy();
if !name_str.starts_with('.') && name_str != "target" && name_str != "node_modules" {
discover_bock_files_recursive(&path, files, false)?;
}
} else if path.is_file() {
if let Some(ext) = path.extension() {
if ext == "bock" {
files.push(path);
}
}
}
}
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;
use std::fs;
async fn run_test_on_source(source: &str) -> Vec<TestResult> {
let dir = tempfile::tempdir().unwrap();
fs::write(dir.path().join("bock.project"), "[project]\nname = \"t\"\n").unwrap();
let file_path = dir.path().join("test.bock");
fs::write(&file_path, source).unwrap();
run_tests_in_file(&file_path, &None).await.unwrap()
}
#[tokio::test]
async fn test_passing_test() {
let source = r#"
@test
fn test_addition() {
expect(1 + 1).to_equal(2)
}
"#;
let results = run_test_on_source(source).await;
assert_eq!(results.len(), 1);
assert!(
results[0].passed,
"test should pass: {:?}",
results[0].error
);
}
#[tokio::test]
async fn test_failing_test() {
let source = r#"
@test
fn test_bad_math() {
expect(1 + 1).to_equal(3)
}
"#;
let results = run_test_on_source(source).await;
assert_eq!(results.len(), 1);
assert!(!results[0].passed);
assert!(results[0]
.error
.as_ref()
.unwrap()
.contains("assertion failed"));
}
#[tokio::test]
async fn test_multiple_tests() {
let source = r#"
@test
fn test_one() {
expect(true).to_be_true()
}
@test
fn test_two() {
expect(false).to_be_false()
}
fn helper() {
println("not a test")
}
"#;
let results = run_test_on_source(source).await;
assert_eq!(results.len(), 2);
assert!(results.iter().all(|r| r.passed));
}
#[tokio::test]
async fn test_filter_matches() {
let source = r#"
@test
fn test_alpha() {
expect(1).to_equal(1)
}
@test
fn test_beta() {
expect(2).to_equal(2)
}
"#;
let dir = tempfile::tempdir().unwrap();
fs::write(dir.path().join("bock.project"), "[project]\nname = \"t\"\n").unwrap();
let file_path = dir.path().join("test.bock");
fs::write(&file_path, source).unwrap();
let compiled = compile_test_file(&file_path).unwrap();
let filter = Some("alpha".to_string());
let tests = discover_test_functions(&compiled.test_items, &filter);
assert_eq!(tests.len(), 1);
assert_eq!(tests[0].0, "test_alpha");
}
#[tokio::test]
async fn test_no_test_functions() {
let source = r#"
fn not_a_test() {
println("hello")
}
"#;
let results = run_test_on_source(source).await;
assert!(results.is_empty());
}
#[tokio::test]
async fn test_discover_bock_files_recursive() {
let dir = tempfile::tempdir().unwrap();
let sub = dir.path().join("sub");
fs::create_dir(&sub).unwrap();
fs::write(dir.path().join("a.bock"), "").unwrap();
fs::write(sub.join("b.bock"), "").unwrap();
fs::write(dir.path().join("c.txt"), "").unwrap();
let files = discover_bock_files(dir.path()).unwrap();
assert_eq!(files.len(), 2);
assert!(files.iter().all(|f| f.extension().unwrap() == "bock"));
}
#[cfg(unix)]
#[tokio::test]
async fn test_discover_skips_unreadable_subdir() {
use std::os::unix::fs::PermissionsExt;
let dir = tempfile::tempdir().unwrap();
fs::write(dir.path().join("a.bock"), "").unwrap();
let locked = dir.path().join("snap-private");
fs::create_dir(&locked).unwrap();
fs::write(locked.join("hidden.bock"), "").unwrap();
fs::set_permissions(&locked, fs::Permissions::from_mode(0o000)).unwrap();
let result = discover_bock_files(dir.path());
fs::set_permissions(&locked, fs::Permissions::from_mode(0o755)).unwrap();
let files = result.expect("unreadable subdir must not abort discovery");
assert_eq!(
files.len(),
1,
"only the readable root .bock should be found: {files:?}"
);
assert!(files[0].ends_with("a.bock"));
}
#[cfg(unix)]
#[tokio::test]
async fn test_run_tests_in_file_skips_unreadable_sibling() {
use std::os::unix::fs::PermissionsExt;
let root = tempfile::tempdir().unwrap();
fs::write(
root.path().join("bock.project"),
"[project]\nname = \"t\"\n",
)
.unwrap();
let test_file = root.path().join("sample_test.bock");
fs::write(
&test_file,
"@test\nfn test_ok() {\n expect(1 + 1).to_equal(2)\n}\n",
)
.unwrap();
let locked = root.path().join("snap-private");
fs::create_dir(&locked).unwrap();
fs::set_permissions(&locked, fs::Permissions::from_mode(0o000)).unwrap();
let result = run_tests_in_file(&test_file, &None).await;
fs::set_permissions(&locked, fs::Permissions::from_mode(0o755)).unwrap();
let results = result.expect("unreadable sibling dir must not abort the test run");
assert_eq!(results.len(), 1, "the sample test should have run");
assert!(
results[0].passed,
"sample test should pass: {:?}",
results[0].error
);
}
#[tokio::test]
async fn test_expect_to_be_some() {
let source = r#"
@test
fn test_some() {
let xs = [1, 2, 3]
expect(xs.get(0)).to_be_some()
}
"#;
let results = run_test_on_source(source).await;
assert_eq!(results.len(), 1);
assert!(
results[0].passed,
"test should pass: {:?}",
results[0].error
);
}
#[tokio::test]
async fn test_expect_to_be_none() {
let source = r#"
@test
fn test_none() {
let xs = [1, 2, 3]
expect(xs.get(10)).to_be_none()
}
"#;
let results = run_test_on_source(source).await;
assert_eq!(results.len(), 1);
assert!(
results[0].passed,
"test should pass: {:?}",
results[0].error
);
}
#[tokio::test]
async fn test_isolated_environments() {
let source = r#"
@test
fn test_a() {
expect(1 + 1).to_equal(2)
}
@test
fn test_b() {
expect(2 + 2).to_equal(4)
}
"#;
let results = run_test_on_source(source).await;
assert_eq!(results.len(), 2);
assert!(
results.iter().all(|r| r.passed),
"all tests should pass in isolated envs: {:?}",
results
.iter()
.map(|r| (&r.name, &r.error))
.collect::<Vec<_>>()
);
}
#[tokio::test]
async fn test_use_core_option_resolves_and_runs() {
let source = r#"module mytest
use core.option.{count}
@test
fn test_core_option_count() {
expect(count(Some(5))).to_equal(1)
expect(count(None)).to_equal(0)
}
"#;
let results = run_test_on_source(source).await;
assert_eq!(results.len(), 1);
assert!(
results[0].passed,
"test using core.option should pass: {:?}",
results[0].error
);
}
}