diff --git a/common/src/float_ops.rs b/common/src/float_ops.rs index c6737fb5c5..fd007bb8e4 100644 --- a/common/src/float_ops.rs +++ b/common/src/float_ops.rs @@ -478,40 +478,32 @@ fn test_to_hex() { #[test] fn test_remove_trailing_zeros() { - assert!(remove_trailing_zeros(String::from("100")) == String::from("1")); - assert!(remove_trailing_zeros(String::from("100.00")) == String::from("100.")); + assert!(remove_trailing_zeros(String::from("100")) == *"1"); + assert!(remove_trailing_zeros(String::from("100.00")) == *"100."); // leave leading zeros untouched - assert!(remove_trailing_zeros(String::from("001")) == String::from("001")); + assert!(remove_trailing_zeros(String::from("001")) == *"001"); // leave strings untouched if they don't end with 0 - assert!(remove_trailing_zeros(String::from("101")) == String::from("101")); + assert!(remove_trailing_zeros(String::from("101")) == *"101"); } #[test] fn test_remove_trailing_decimal_point() { - assert!(remove_trailing_decimal_point(String::from("100.")) == String::from("100")); - assert!(remove_trailing_decimal_point(String::from("1.")) == String::from("1")); + assert!(remove_trailing_decimal_point(String::from("100.")) == *"100"); + assert!(remove_trailing_decimal_point(String::from("1.")) == *"1"); // leave leading decimal points untouched - assert!(remove_trailing_decimal_point(String::from(".5")) == String::from(".5")); + assert!(remove_trailing_decimal_point(String::from(".5")) == *".5"); } #[test] fn test_maybe_remove_trailing_redundant_chars() { - assert!( - maybe_remove_trailing_redundant_chars(String::from("100."), true) == String::from("100.") - ); - assert!( - maybe_remove_trailing_redundant_chars(String::from("100."), false) == String::from("100") - ); - assert!(maybe_remove_trailing_redundant_chars(String::from("1."), false) == String::from("1")); - assert!( - maybe_remove_trailing_redundant_chars(String::from("10.0"), false) == String::from("10") - ); + assert!(maybe_remove_trailing_redundant_chars(String::from("100."), true) == *"100."); + assert!(maybe_remove_trailing_redundant_chars(String::from("100."), false) == *"100"); + assert!(maybe_remove_trailing_redundant_chars(String::from("1."), false) == *"1"); + assert!(maybe_remove_trailing_redundant_chars(String::from("10.0"), false) == *"10"); // don't truncate integers - assert!( - maybe_remove_trailing_redundant_chars(String::from("1000"), false) == String::from("1000") - ); + assert!(maybe_remove_trailing_redundant_chars(String::from("1000"), false) == *"1000"); } diff --git a/jit/tests/common.rs b/jit/tests/common.rs index 289093f843..762170e44b 100644 --- a/jit/tests/common.rs +++ b/jit/tests/common.rs @@ -141,7 +141,7 @@ impl StackMachine { instruction ), } - return false; + false } pub fn get_function(&self, name: &str) -> Function { diff --git a/parser/src/fstring.rs b/parser/src/fstring.rs index e7eb831f42..b0ebef7f3d 100644 --- a/parser/src/fstring.rs +++ b/parser/src/fstring.rs @@ -306,7 +306,7 @@ mod tests { #[test] fn test_parse_fstring() { let source = "{a}{ b }{{foo}}"; - let parse_ast = parse_fstring(&source).unwrap(); + let parse_ast = parse_fstring(source).unwrap(); insta::assert_debug_snapshot!(parse_ast); } @@ -314,7 +314,7 @@ mod tests { #[test] fn test_parse_fstring_nested_spec() { let source = "{foo:{spec}}"; - let parse_ast = parse_fstring(&source).unwrap(); + let parse_ast = parse_fstring(source).unwrap(); insta::assert_debug_snapshot!(parse_ast); } @@ -322,7 +322,7 @@ mod tests { #[test] fn test_parse_fstring_not_nested_spec() { let source = "{foo:spec}"; - let parse_ast = parse_fstring(&source).unwrap(); + let parse_ast = parse_fstring(source).unwrap(); insta::assert_debug_snapshot!(parse_ast); } @@ -335,7 +335,7 @@ mod tests { #[test] fn test_fstring_parse_selfdocumenting_base() { let src = "{user=}"; - let parse_ast = parse_fstring(&src).unwrap(); + let parse_ast = parse_fstring(src).unwrap(); insta::assert_debug_snapshot!(parse_ast); } @@ -343,7 +343,7 @@ mod tests { #[test] fn test_fstring_parse_selfdocumenting_base_more() { let src = "mix {user=} with text and {second=}"; - let parse_ast = parse_fstring(&src).unwrap(); + let parse_ast = parse_fstring(src).unwrap(); insta::assert_debug_snapshot!(parse_ast); } @@ -351,7 +351,7 @@ mod tests { #[test] fn test_fstring_parse_selfdocumenting_format() { let src = "{user=:>10}"; - let parse_ast = parse_fstring(&src).unwrap(); + let parse_ast = parse_fstring(src).unwrap(); insta::assert_debug_snapshot!(parse_ast); } @@ -384,35 +384,35 @@ mod tests { #[test] fn test_parse_fstring_not_equals() { let source = "{1 != 2}"; - let parse_ast = parse_fstring(&source).unwrap(); + let parse_ast = parse_fstring(source).unwrap(); insta::assert_debug_snapshot!(parse_ast); } #[test] fn test_parse_fstring_equals() { let source = "{42 == 42}"; - let parse_ast = parse_fstring(&source).unwrap(); + let parse_ast = parse_fstring(source).unwrap(); insta::assert_debug_snapshot!(parse_ast); } #[test] fn test_parse_fstring_selfdoc_prec_space() { let source = "{x =}"; - let parse_ast = parse_fstring(&source).unwrap(); + let parse_ast = parse_fstring(source).unwrap(); insta::assert_debug_snapshot!(parse_ast); } #[test] fn test_parse_fstring_selfdoc_trailing_space() { let source = "{x= }"; - let parse_ast = parse_fstring(&source).unwrap(); + let parse_ast = parse_fstring(source).unwrap(); insta::assert_debug_snapshot!(parse_ast); } #[test] fn test_parse_fstring_yield_expr() { let source = "{yield}"; - let parse_ast = parse_fstring(&source).unwrap(); + let parse_ast = parse_fstring(source).unwrap(); insta::assert_debug_snapshot!(parse_ast); } } diff --git a/parser/src/parser.rs b/parser/src/parser.rs index 02845f775f..6169ec00ae 100644 --- a/parser/src/parser.rs +++ b/parser/src/parser.rs @@ -122,7 +122,7 @@ mod tests { #[test] fn test_parse_lambda() { let source = "lambda x, y: x * y"; // lambda(x, y): x * y"; - let parse_ast = parse_program(&source).unwrap(); + let parse_ast = parse_program(source).unwrap(); insta::assert_debug_snapshot!(parse_ast); } @@ -130,7 +130,7 @@ mod tests { fn test_parse_tuples() { let source = "a, b = 4, 5"; - insta::assert_debug_snapshot!(parse_program(&source).unwrap()); + insta::assert_debug_snapshot!(parse_program(source).unwrap()); } #[test] @@ -141,7 +141,7 @@ class Foo(A, B): pass def method_with_default(self, arg='default'): pass"; - insta::assert_debug_snapshot!(parse_program(&source).unwrap()); + insta::assert_debug_snapshot!(parse_program(source).unwrap()); } #[test] diff --git a/vm/src/builtins/str.rs b/vm/src/builtins/str.rs index a1dcddecb7..42f59389d5 100644 --- a/vm/src/builtins/str.rs +++ b/vm/src/builtins/str.rs @@ -1592,23 +1592,19 @@ mod tests { Interpreter::without_stdlib(Default::default()).enter(|vm| { let table = vm.ctx.new_dict(); table - .set_item("a", vm.ctx.new_str("🎅").into(), &vm) + .set_item("a", vm.ctx.new_str("🎅").into(), vm) .unwrap(); - table.set_item("b", vm.ctx.none(), &vm).unwrap(); + table.set_item("b", vm.ctx.none(), vm).unwrap(); table - .set_item("c", vm.ctx.new_str(ascii!("xda")).into(), &vm) + .set_item("c", vm.ctx.new_str(ascii!("xda")).into(), vm) .unwrap(); - let translated = PyStr::maketrans( - table.into(), - OptionalArg::Missing, - OptionalArg::Missing, - &vm, - ) - .unwrap(); + let translated = + PyStr::maketrans(table.into(), OptionalArg::Missing, OptionalArg::Missing, vm) + .unwrap(); let text = PyStr::from("abc"); - let translated = text.translate(translated, &vm).unwrap(); + let translated = text.translate(translated, vm).unwrap(); assert_eq!(translated, "🎅xda".to_owned()); - let translated = text.translate(vm.ctx.new_int(3).into(), &vm); + let translated = text.translate(vm.ctx.new_int(3).into(), vm); assert_eq!( translated.unwrap_err().class().name().deref(), "TypeError".to_owned() diff --git a/vm/src/builtins/type.rs b/vm/src/builtins/type.rs index 2ac9b0740a..6647cdba71 100644 --- a/vm/src/builtins/type.rs +++ b/vm/src/builtins/type.rs @@ -990,7 +990,7 @@ mod tests { vec![object.clone()], PyAttributes::default(), Default::default(), - type_type.clone(), + type_type, ) .unwrap(); @@ -1006,7 +1006,7 @@ mod tests { vec![a.clone(), object.clone()], vec![b.clone(), object.clone()], ])), - map_ids(Ok(vec![a.clone(), b.clone(), object.clone()])) + map_ids(Ok(vec![a, b, object])) ); } } diff --git a/vm/src/dictdatatype.rs b/vm/src/dictdatatype.rs index b7f0850467..d9f68a7976 100644 --- a/vm/src/dictdatatype.rs +++ b/vm/src/dictdatatype.rs @@ -922,27 +922,27 @@ mod tests { let key1 = vm.new_pyobj(true); let value1 = vm.new_pyobj(ascii!("abc")); - dict.insert(&vm, &*key1, value1.clone()).unwrap(); + dict.insert(vm, &*key1, value1).unwrap(); assert_eq!(1, dict.len()); let key2 = vm.new_pyobj(ascii!("x")); let value2 = vm.new_pyobj(ascii!("def")); - dict.insert(&vm, &*key2, value2.clone()).unwrap(); + dict.insert(vm, &*key2, value2.clone()).unwrap(); assert_eq!(2, dict.len()); - dict.insert(&vm, &*key1, value2.clone()).unwrap(); + dict.insert(vm, &*key1, value2.clone()).unwrap(); assert_eq!(2, dict.len()); - dict.delete(&vm, &*key1).unwrap(); + dict.delete(vm, &*key1).unwrap(); assert_eq!(1, dict.len()); - dict.insert(&vm, &*key1, value2.clone()).unwrap(); + dict.insert(vm, &*key1, value2.clone()).unwrap(); assert_eq!(2, dict.len()); - assert_eq!(true, dict.contains(&vm, &*key1).unwrap()); - assert_eq!(true, dict.contains(&vm, "x").unwrap()); + assert_eq!(true, dict.contains(vm, &*key1).unwrap()); + assert_eq!(true, dict.contains(vm, "x").unwrap()); - let val = dict.get(&vm, "x").unwrap().unwrap(); + let val = dict.get(vm, "x").unwrap().unwrap(); vm.bool_eq(&val, &value2) .expect("retrieved value must be equal to inserted value."); }) @@ -969,8 +969,8 @@ mod tests { let value1 = text; let value2 = vm.new_pyobj(value1.to_owned()); - let hash1 = value1.key_hash(&vm).expect("Hash should not fail."); - let hash2 = value2.key_hash(&vm).expect("Hash should not fail."); + let hash1 = value1.key_hash(vm).expect("Hash should not fail."); + let hash2 = value2.key_hash(vm).expect("Hash should not fail."); assert_eq!(hash1, hash2); }) } diff --git a/vm/src/eval.rs b/vm/src/eval.rs index 39637323d3..e9576fbce1 100644 --- a/vm/src/eval.rs +++ b/vm/src/eval.rs @@ -23,7 +23,7 @@ mod tests { Interpreter::without_stdlib(Default::default()).enter(|vm| { let source = String::from("print('Hello world')"); let vars = vm.new_scope_with_builtins(); - let result = eval(&vm, &source, vars, "").expect("this should pass"); + let result = eval(vm, &source, vars, "").expect("this should pass"); assert!(vm.is_none(&result)); }) } diff --git a/vm/src/vm/mod.rs b/vm/src/vm/mod.rs index bcec61d3dd..a4e7bad49c 100644 --- a/vm/src/vm/mod.rs +++ b/vm/src/vm/mod.rs @@ -760,8 +760,8 @@ fn test_nested_frozen() { .map_err(|err| vm.new_syntax_error(&err)) .unwrap(); - if let Err(e) = vm.run_code_obj(code_obj, scope.clone()) { - vm.print_exception(e.clone()); + if let Err(e) = vm.run_code_obj(code_obj, scope) { + vm.print_exception(e); assert!(false); } })