Skip to content

Commit

Permalink
fix rust format
Browse files Browse the repository at this point in the history
  • Loading branch information
n14little committed May 18, 2020
1 parent 3f1d992 commit 7653375
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
10 changes: 9 additions & 1 deletion boa/src/builtins/json/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,15 @@ pub fn stringify(_: &mut Value, args: &[Value], interpreter: &mut Interpreter) -
let mut this_arg = object.clone();
object_to_return.set_property(
String::from(key),
Property::default().value(interpreter.call(arg, &mut this_arg, &[Value::string(key), Value::from(value)]).unwrap()),
Property::default().value(
interpreter
.call(
arg,
&mut this_arg,
&[Value::string(key), Value::from(value)],
)
.unwrap(),
),
);
}
}
Expand Down
10 changes: 8 additions & 2 deletions boa/src/builtins/json/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ fn json_stringify_remove_undefined_values_from_objects() {
let realm = Realm::create();
let mut engine = Executor::new(realm);

let actual = forward(&mut engine, r#"JSON.stringify({ aaa: undefined, bbb: 'ccc' })"#);
let actual = forward(
&mut engine,
r#"JSON.stringify({ aaa: undefined, bbb: 'ccc' })"#,
);
let expected = r#"{"bbb":"ccc"}"#;

assert_eq!(actual, expected);
Expand All @@ -33,7 +36,10 @@ fn json_stringify_remove_function_values_from_objects() {
let realm = Realm::create();
let mut engine = Executor::new(realm);

let actual = forward(&mut engine, r#"JSON.stringify({ aaa: () => {}, bbb: 'ccc' })"#);
let actual = forward(
&mut engine,
r#"JSON.stringify({ aaa: () => {}, bbb: 'ccc' })"#,
);
let expected = r#"{"bbb":"ccc"}"#;

assert_eq!(actual, expected);
Expand Down
18 changes: 7 additions & 11 deletions boa/src/builtins/value/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -686,17 +686,13 @@ impl ValueData {
Self::Boolean(b) => JSONValue::Bool(b),
Self::Object(ref obj) => {
let mut new_obj = Map::new();
obj
.borrow()
.properties
.iter()
.for_each(|(k, _)| {
let key = k.clone();
let value = self.get_field_slice(k);
if !value.is_undefined() && !value.is_function() {
new_obj.insert(key, value.to_json());
}
});
obj.borrow().properties.iter().for_each(|(k, _)| {
let key = k.clone();
let value = self.get_field_slice(k);
if !value.is_undefined() && !value.is_function() {
new_obj.insert(key, value.to_json());
}
});
JSONValue::Object(new_obj)
}
Self::String(ref str) => JSONValue::String(str.clone()),
Expand Down

0 comments on commit 7653375

Please sign in to comment.