difftreelog
test update for split stdlib
100 files changed
Cargo.lockdiffbeforeafterboth517517518[[package]]518[[package]]519name = "serde"519name = "serde"520version = "1.0.137"520version = "1.0.142"521source = "registry+https://github.com/rust-lang/crates.io-index"521source = "registry+https://github.com/rust-lang/crates.io-index"522checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1"522checksum = "e590c437916fb6b221e1d00df6e3294f3fccd70ca7e92541c475d6ed6ef5fee2"523dependencies = [523dependencies = [524 "serde_derive",524 "serde_derive",525]525]526526527[[package]]527[[package]]528name = "serde_derive"528name = "serde_derive"529version = "1.0.137"529version = "1.0.142"530source = "registry+https://github.com/rust-lang/crates.io-index"530source = "registry+https://github.com/rust-lang/crates.io-index"531checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be"531checksum = "34b5b8d809babe02f538c2cfec6f2c1ed10804c0e5a6a041a049a4f5588ccc2e"532dependencies = [532dependencies = [533 "proc-macro2",533 "proc-macro2",534 "quote",534 "quote",619 "winapi-util",619 "winapi-util",620]620]621622[[package]]623name = "tests"624version = "0.1.0"625dependencies = [626 "jrsonnet-evaluator",627 "jrsonnet-gcmodule",628 "jrsonnet-stdlib",629 "serde",630]621631622[[package]]632[[package]]623name = "textwrap"633name = "textwrap"Cargo.tomldiffbeforeafterboth1[workspace]1[workspace]2members = ["crates/*", "bindings/jsonnet", "cmds/jrsonnet"]2members = ["crates/*", "bindings/jsonnet", "cmds/jrsonnet", "tests"]334[profile.test]4[profile.test]5opt-level = 15opt-level = 1crates/jrsonnet-evaluator/src/ctx.rsdiffbeforeafterboth139 }139 }140}140}141141142#[derive(Default)]143pub struct ContextBuilder {142pub struct ContextBuilder {144 bindings: GcHashMap<IStr, Thunk<Val>>,143 bindings: GcHashMap<IStr, Thunk<Val>>,144 extend: Option<Context>,145}145}146146impl ContextBuilder {147impl ContextBuilder {147 pub fn new() -> Self {148 pub fn new() -> Self {148 Self::default()149 Self::with_capacity(0)149 }150 }150 pub fn with_capacity(capacity: usize) -> Self {151 pub fn with_capacity(capacity: usize) -> Self {151 Self {152 Self {152 bindings: GcHashMap::with_capacity(capacity),153 bindings: GcHashMap::with_capacity(capacity),154 extend: None,153 }155 }154 }156 }157 pub fn extend(parent: Context) -> Self {158 Self {159 bindings: GcHashMap::new(),160 extend: Some(parent),161 }162 }155 pub fn bind(&mut self, name: IStr, value: Thunk<Val>) -> &mut Self {163 pub fn bind(&mut self, name: IStr, value: Thunk<Val>) -> &mut Self {156 self.bindings.insert(name, value);164 self.bindings.insert(name, value);157 self165 self158 }166 }159 pub fn build(self) -> Context {167 pub fn build(self) -> Context {168 if let Some(parent) = self.extend {169 parent.extend(self.bindings, None, None, None)170 } else {160 Context(Cc::new(ContextInternals {171 Context(Cc::new(ContextInternals {161 bindings: LayeredHashMap::new(self.bindings),172 bindings: LayeredHashMap::new(self.bindings),162 dollar: None,173 dollar: None,163 sup: None,174 sup: None,164 this: None,175 this: None,165 }))176 }))166 }177 }178 }167}179}180181impl Default for ContextBuilder {182 fn default() -> Self {183 Self::new()184 }185}168186crates/jrsonnet-evaluator/src/dynamic.rsdiffbeforeafterboth223use jrsonnet_gcmodule::{Cc, Trace};3use jrsonnet_gcmodule::{Cc, Trace};445// TODO: Replace with OnceCell once in std5#[derive(Clone, Trace)]6#[derive(Clone, Trace)]6pub struct Pending<V: Trace + 'static>(pub Cc<RefCell<Option<V>>>);7pub struct Pending<V: Trace + 'static>(pub Cc<RefCell<Option<V>>>);7impl<T: Trace + 'static> Pending<T> {8impl<T: Trace + 'static> Pending<T> {crates/jrsonnet-evaluator/tests/as_native.rsdiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/builtin.rsdiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/common.rsdiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/golden.rsdiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/golden/array_comp.jsonnetdiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/golden/array_comp.jsonnet.goldendiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/golden/builtin_json.jsonnetdiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/golden/builtin_json.jsonnet.goldendiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/golden/builtin_json_minified.jsonnetdiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/golden/builtin_json_minified.jsonnet.goldendiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/golden/builtin_parseJson.jsonnetdiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/golden/builtin_parseJson.jsonnet.goldendiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/golden/issue23.jsonnetdiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/golden/issue23.jsonnet.goldendiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/golden/issue40.jsonnetdiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/golden/issue40.jsonnet.goldendiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/golden/missing_binding.jsonnetdiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/golden/missing_binding.jsonnet.goldendiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/golden/object_comp.jsonnetdiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/golden/object_comp.jsonnet.goldendiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/golden/test_assertThrow.jsonnetdiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/golden/test_assertThrow.jsonnet.goldendiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/sanity.rsdiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/suite.rsdiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/suite/builtin_ascii.jsonnetdiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/suite/builtin_base64.jsonnetdiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/suite/builtin_chars.jsonnetdiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/suite/builtin_constant.jsonnetdiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/suite/builtin_count.jsonnetdiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/suite/builtin_join.jsonnetdiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/suite/builtin_member.jsonnetdiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/suite/function_args.jsonnetdiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/suite/function_context.jsonnetdiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/suite/function_lazy_args.jsonnetdiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/suite/local.jsonnetdiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/suite/math.jsonnetdiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/suite/object_assertion.jsonnetdiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/suite/object_comp_self.jsonnetdiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/suite/object_context.jsonnetdiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/suite/object_fields.jsonnetdiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/suite/object_inheritance.jsonnetdiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/suite/object_locals.jsonnetdiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/suite/object_super_standalone.jsonnetdiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/suite/sjsonnet_issue_127.jsonnetdiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/suite/string_concat.jsonnetdiffbeforeafterbothno changes
crates/jrsonnet-evaluator/tests/typed_obj.rsdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/lib.rsdiffbeforeafterboth362pub mod tests {362pub mod tests {363 use std::borrow::Cow;363 use std::borrow::Cow;364364365 use jrsonnet_interner::IStr;365 use BinaryOpType::*;366 use BinaryOpType::*;366367367 use super::{expr::*, parse};368 use super::{expr::*, parse};372 parse(373 parse(373 $s,374 $s,374 &ParserSettings {375 &ParserSettings {375 file_name: Source::new_virtual(Cow::Borrowed("<test>")),376 file_name: Source::new_virtual(Cow::Borrowed("<test>"), IStr::empty()),376 },377 },377 )378 )378 .unwrap()379 .unwrap()384 LocExpr(385 LocExpr(385 std::rc::Rc::new($expr),386 std::rc::Rc::new($expr),386 ExprLocation(Source::new_virtual(Cow::Borrowed("<test>")), $from, $to),387 ExprLocation(388 Source::new_virtual(Cow::Borrowed("<test>"), IStr::empty()),389 $from,390 $to,391 ),712 parse!("local x(foo = 'foo', bar) = null; null");717 parse!("local x(foo = 'foo', bar) = null; null");713 }718 }714715 #[test]716 fn can_parse_stdlib() {717 parse!(jrsonnet_stdlib::STDLIB_STR);718 }719719720 #[test]720 #[test]721 fn add_location_info_to_all_sub_expressions() {721 fn add_location_info_to_all_sub_expressions() {722 use Expr::*;722 use Expr::*;723723724 let file_name = Source::new_virtual(Cow::Borrowed("<test>"));724 let file_name = Source::new_virtual(Cow::Borrowed("<test>"), IStr::empty());725 let expr = parse(725 let expr = parse(726 "{} { local x = 1, x: x } + {}",726 "{} { local x = 1, x: x } + {}",727 &ParserSettings { file_name },727 &ParserSettings { file_name },crates/jrsonnet-stdlib/src/lib.rsdiffbeforeafterboth8use jrsonnet_evaluator::{8use jrsonnet_evaluator::{9 error::{Error::*, Result},9 error::{Error::*, Result},10 function::{builtin::Builtin, ArgLike, CallLocation, FuncVal, TlaArg},10 function::{builtin::Builtin, ArgLike, CallLocation, FuncVal, TlaArg},11 gc::TraceBox,11 gc::{GcHashMap, TraceBox},12 tb, throw_runtime,12 tb, throw_runtime,13 typed::{Any, Either, Either2, Either4, VecVal, M1},13 typed::{Any, Either, Either2, Either4, VecVal, M1},14 val::{equals, ArrValue},14 val::{equals, ArrValue},201 pub ext_vars: HashMap<IStr, TlaArg>,201 pub ext_vars: HashMap<IStr, TlaArg>,202 /// Used for `std.native`202 /// Used for `std.native`203 pub ext_natives: HashMap<IStr, Cc<TraceBox<dyn Builtin>>>,203 pub ext_natives: HashMap<IStr, Cc<TraceBox<dyn Builtin>>>,204 /// Helper to add globals without implementing custom ContextInitializer205 pub globals: GcHashMap<IStr, Thunk<Val>>,204 /// Used for `std.trace`206 /// Used for `std.trace`205 pub trace_printer: Box<dyn TracePrinter>,207 pub trace_printer: Box<dyn TracePrinter>,206}208}210 Self {212 Self {211 ext_vars: Default::default(),213 ext_vars: Default::default(),212 ext_natives: Default::default(),214 ext_natives: Default::default(),215 globals: Default::default(),213 trace_printer: Box::new(StdTracePrinter),216 trace_printer: Box::new(StdTracePrinter),214 }217 }215 }218 }289impl jrsonnet_evaluator::ContextInitializer for ContextInitializer {292impl jrsonnet_evaluator::ContextInitializer for ContextInitializer {290 #[cfg(not(feature = "legacy-this-file"))]293 #[cfg(not(feature = "legacy-this-file"))]291 fn initialize(&self, _s: State, _source: Source) -> jrsonnet_evaluator::Context {294 fn initialize(&self, _s: State, _source: Source) -> jrsonnet_evaluator::Context {292 self.context.clone()295 let out = self.context.clone();296 let globals = &self.settings().globals;297 if globals.is_empty() {298 return out;299 }300301 let mut out = ContextBuilder::extend(out);302 for (k, v) in globals.iter() {303 out.bind(k.clone(), v.clone());304 }305 out.build()293 }306 }294 #[cfg(feature = "legacy-this-file")]307 #[cfg(feature = "legacy-this-file")]295 fn initialize(&self, s: State, source: Source) -> jrsonnet_evaluator::Context {308 fn initialize(&self, s: State, source: Source) -> jrsonnet_evaluator::Context {316 "std".into(),329 "std".into(),317 Thunk::evaluated(Val::Obj(stdlib_with_this_file)),330 Thunk::evaluated(Val::Obj(stdlib_with_this_file)),318 );331 );332 for (k, v) in &self.settings().globals {333 context.bind(k.clone(), v.clone())334 }319 context.build()335 context.build()320 }336 }321 unsafe fn as_any(&self) -> &dyn std::any::Any {337 unsafe fn as_any(&self) -> &dyn std::any::Any {514 })530 })515}531}532533pub trait StateExt {534 /// This method was previously implemented in jrsonnet-evaluator itself535 fn with_stdlib(&self);536 fn add_global(&self, name: IStr, value: Thunk<Val>);537}538539impl StateExt for State {540 fn with_stdlib(&self) {541 let initializer = ContextInitializer::new(self.clone());542 self.settings_mut().context_initializer = Box::new(initializer)543 }544 fn add_global(&self, name: IStr, value: Thunk<Val>) {545 // Safety:546 unsafe { self.settings().context_initializer.as_any() }547 .downcast_ref::<ContextInitializer>()548 .expect("not standard context initializer")549 .settings_mut()550 .globals551 .insert(name, value);552 }553}516554tests/Cargo.tomldiffbeforeafterbothno changes
tests/golden/array_comp.jsonnetdiffbeforeafterbothno changes
tests/golden/array_comp.jsonnet.goldendiffbeforeafterbothno changes
tests/golden/builtin_json.jsonnetdiffbeforeafterbothno changes
tests/golden/builtin_json.jsonnet.goldendiffbeforeafterbothno changes
tests/golden/builtin_json_minified.jsonnetdiffbeforeafterbothno changes
tests/golden/builtin_json_minified.jsonnet.goldendiffbeforeafterbothno changes
tests/golden/builtin_parseJson.jsonnetdiffbeforeafterbothno changes
tests/golden/builtin_parseJson.jsonnet.goldendiffbeforeafterbothno changes
tests/golden/issue23.jsonnetdiffbeforeafterbothno changes
tests/golden/issue23.jsonnet.goldendiffbeforeafterbothno changes
tests/golden/issue40.jsonnetdiffbeforeafterbothno changes
tests/golden/issue40.jsonnet.goldendiffbeforeafterbothno changes
tests/golden/missing_binding.jsonnetdiffbeforeafterbothno changes
tests/golden/missing_binding.jsonnet.goldendiffbeforeafterbothno changes
tests/golden/object_comp.jsonnetdiffbeforeafterbothno changes
tests/golden/object_comp.jsonnet.goldendiffbeforeafterbothno changes
tests/golden/test_assertThrow.jsonnetdiffbeforeafterbothno changes
tests/golden/test_assertThrow.jsonnet.goldendiffbeforeafterbothno changes
tests/src/lib.rsdiffbeforeafterbothno changes
tests/suite/builtin_ascii.jsonnetdiffbeforeafterbothno changes
tests/suite/builtin_base64.jsonnetdiffbeforeafterbothno changes
tests/suite/builtin_chars.jsonnetdiffbeforeafterbothno changes
tests/suite/builtin_constant.jsonnetdiffbeforeafterbothno changes
tests/suite/builtin_count.jsonnetdiffbeforeafterbothno changes
tests/suite/builtin_join.jsonnetdiffbeforeafterbothno changes
tests/suite/builtin_member.jsonnetdiffbeforeafterbothno changes
tests/suite/function_args.jsonnetdiffbeforeafterbothno changes
tests/suite/function_context.jsonnetdiffbeforeafterbothno changes
tests/suite/function_lazy_args.jsonnetdiffbeforeafterbothno changes
tests/suite/local.jsonnetdiffbeforeafterbothno changes
tests/suite/math.jsonnetdiffbeforeafterbothno changes
tests/suite/object_assertion.jsonnetdiffbeforeafterbothno changes
tests/suite/object_comp_self.jsonnetdiffbeforeafterbothno changes
tests/suite/object_context.jsonnetdiffbeforeafterbothno changes
tests/suite/object_fields.jsonnetdiffbeforeafterbothno changes
tests/suite/object_inheritance.jsonnetdiffbeforeafterbothno changes
tests/suite/object_locals.jsonnetdiffbeforeafterbothno changes
tests/suite/object_super_standalone.jsonnetdiffbeforeafterbothno changes
tests/suite/sjsonnet_issue_127.jsonnetdiffbeforeafterbothno changes
tests/suite/string_concat.jsonnetdiffbeforeafterbothno changes
tests/tests/as_native.rsdiffbeforeafterbothno changes
tests/tests/builtin.rsdiffbeforeafterbothno changes
tests/tests/common.rsdiffbeforeafterbothno changes
tests/tests/golden.rsdiffbeforeafterbothno changes
tests/tests/sanity.rsdiffbeforeafterbothno changes
tests/tests/suite.rsdiffbeforeafterbothno changes
tests/tests/typed_obj.rsdiffbeforeafterbothno changes