git.delta.rocks / jrsonnet / refs/commits / aa77bfb39005

difftreelog

fix support integration test with all features

ymqrumloYaroslav Bolyukin2026-05-06parent: #69623ce.patch.diff
in: master

3 files changed

modifiedtests/Cargo.tomldiffbeforeafterboth
--- a/tests/Cargo.toml
+++ b/tests/Cargo.toml
@@ -6,12 +6,20 @@
 
 [features]
 default = ["ir-parser"]
-experimental = ["exp-destruct", "exp-null-coaelse", "exp-preserve-order"]
+experimental = [
+  "exp-destruct",
+  "exp-null-coaelse",
+  "exp-preserve-order",
+  "exp-bigint",
+  "exp-regex",
+]
 ir-parser = ["jrsonnet-evaluator/ir-parser"]
 peg-parser = ["jrsonnet-evaluator/peg-parser"]
 exp-destruct = ["jrsonnet-evaluator/exp-destruct"]
 exp-null-coaelse = ["jrsonnet-evaluator/exp-null-coaelse"]
 exp-preserve-order = ["jrsonnet-stdlib/exp-preserve-order"]
+exp-bigint = ["jrsonnet-stdlib/exp-bigint"]
+exp-regex = ["jrsonnet-stdlib/exp-regex"]
 
 [lints]
 workspace = true
modifiedtests/suite/std_param_names.jsonnetdiffbeforeafterboth
--- a/tests/suite/std_param_names.jsonnet
+++ b/tests/suite/std_param_names.jsonnet
@@ -189,6 +189,14 @@
     objectValues+: ['preserve_order'],
     objectValuesAll+: ['preserve_order'],
     prune+: ['preserve_order'],
+} else {}) + (if test.expBigint then {
+    bigint: ['v'],
+} else {}) + (if test.expRegexp then {
+    regexFullMatch: ['pattern', 'str'],
+    regexGlobalReplace: ['str', 'pattern', 'to'],
+    regexPartialMatch: ['pattern', 'str'],
+    regexQuoteMeta: ['pattern'],
+    regexReplace: ['str', 'pattern', 'to'],
 } else {});
 
 std.all(std.map(function(key) assertNames(key, names[key]), std.objectFields(names)))
modifiedtests/tests/common.rsdiffbeforeafterboth
before · tests/tests/common.rs
1use jrsonnet_evaluator::{2	ContextInitializer as ContextInitializerT, InitialContextBuilder, ObjValueBuilder, Result,3	Source, Thunk, Val, bail,4	function::{FuncVal, builtin},5};6use jrsonnet_gcmodule::Trace;78#[macro_export]9macro_rules! ensure_eq {10	($a:expr, $b:expr $(,)?) => {{11		let a = &$a;12		let b = &$b;13		if a != b {14			::jrsonnet_evaluator::bail!("assertion failed: a != b\na={a:#?}\nb={b:#?}")15		}16	}};17}1819#[macro_export]20macro_rules! ensure {21	($v:expr $(,)?) => {22		if !$v {23			::jrsonnet_evaluator::bail!("assertion failed: {}", stringify!($v))24		}25	};26}2728#[macro_export]29macro_rules! ensure_val_eq {30	($a:expr, $b:expr) => {{31		if !::jrsonnet_evaluator::val::equals(&$a.clone(), &$b.clone())? {32			use jrsonnet_evaluator::manifest::JsonFormat;33			::jrsonnet_evaluator::bail!(34				"assertion failed: a != b\na={:#?}\nb={:#?}",35				$a.manifest(JsonFormat::default())?,36				$b.manifest(JsonFormat::default())?,37			)38		}39	}};40}4142#[builtin]43#[allow(dead_code)]44fn assert_throw(lazy: Thunk<Val>, message: String) -> Result<bool> {45	match lazy.evaluate() {46		Ok(_) => {47			bail!("expected argument to throw on evaluation, but it returned instead")48		}49		Err(e) => {50			let error = format!("{}", e.error());51			ensure_eq!(message, error);52		}53	}54	Ok(true)55}5657#[builtin]58#[allow(dead_code)]59fn param_names(fun: FuncVal) -> Vec<String> {60	fun.params()61		.iter()62		.map(|v| v.name().as_str().unwrap_or("<unnamed>").to_owned())63		.collect()64}6566#[derive(Trace)]67#[allow(dead_code)]68pub struct ContextInitializer;69impl ContextInitializerT for ContextInitializer {70	fn populate(&self, _for_file: Source, builder: &mut InitialContextBuilder) {71		let mut bobj = ObjValueBuilder::new();72		bobj.method("assertThrow", assert_throw {});73		bobj.method("paramNames", param_names {});74		bobj.field("expPreserveOrder")75			.value(cfg!(feature = "exp-preserve-order"));7677		builder.bind("test", Thunk::evaluated(Val::Obj(bobj.build())));78	}7980	fn as_any(&self) -> &dyn std::any::Any {81		self82	}83}
after · tests/tests/common.rs
1use jrsonnet_evaluator::{2	ContextInitializer as ContextInitializerT, InitialContextBuilder, ObjValueBuilder, Result,3	Source, Thunk, Val, bail,4	function::{FuncVal, builtin},5};6use jrsonnet_gcmodule::Trace;78#[macro_export]9macro_rules! ensure_eq {10	($a:expr, $b:expr $(,)?) => {{11		let a = &$a;12		let b = &$b;13		if a != b {14			::jrsonnet_evaluator::bail!("assertion failed: a != b\na={a:#?}\nb={b:#?}")15		}16	}};17}1819#[macro_export]20macro_rules! ensure {21	($v:expr $(,)?) => {22		if !$v {23			::jrsonnet_evaluator::bail!("assertion failed: {}", stringify!($v))24		}25	};26}2728#[macro_export]29macro_rules! ensure_val_eq {30	($a:expr, $b:expr) => {{31		if !::jrsonnet_evaluator::val::equals(&$a.clone(), &$b.clone())? {32			use jrsonnet_evaluator::manifest::JsonFormat;33			::jrsonnet_evaluator::bail!(34				"assertion failed: a != b\na={:#?}\nb={:#?}",35				$a.manifest(JsonFormat::default())?,36				$b.manifest(JsonFormat::default())?,37			)38		}39	}};40}4142#[builtin]43#[allow(dead_code)]44fn assert_throw(lazy: Thunk<Val>, message: String) -> Result<bool> {45	match lazy.evaluate() {46		Ok(_) => {47			bail!("expected argument to throw on evaluation, but it returned instead")48		}49		Err(e) => {50			let error = format!("{}", e.error());51			ensure_eq!(message, error);52		}53	}54	Ok(true)55}5657#[builtin]58#[allow(dead_code)]59fn param_names(fun: FuncVal) -> Vec<String> {60	fun.params()61		.iter()62		.map(|v| v.name().as_str().unwrap_or("<unnamed>").to_owned())63		.collect()64}6566#[derive(Trace)]67#[allow(dead_code)]68pub struct ContextInitializer;69impl ContextInitializerT for ContextInitializer {70	fn populate(&self, _for_file: Source, builder: &mut InitialContextBuilder) {71		let mut bobj = ObjValueBuilder::new();72		bobj.method("assertThrow", assert_throw {});73		bobj.method("paramNames", param_names {});74		bobj.field("expPreserveOrder")75			.value(cfg!(feature = "exp-preserve-order"));76		bobj.field("expBigint").value(cfg!(feature = "exp-bigint"));77		bobj.field("expRegexp").value(cfg!(feature = "exp-regex"));7879		builder.bind("test", Thunk::evaluated(Val::Obj(bobj.build())));80	}8182	fn as_any(&self) -> &dyn std::any::Any {83		self84	}85}