Skip to content

Commit

Permalink
Fix broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jevancc committed Jan 19, 2021
1 parent 1c170a5 commit e698d16
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 40 deletions.
53 changes: 25 additions & 28 deletions boa/src/builtins/json/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,10 @@ fn json_stringify_pretty_print() {
);
let expected = forward(
&mut context,
r#"'{
"a": "b",
"b": "c"
}'"#,
r#"'{\n'
+' "a": "b",\n'
+' "b": "c"\n'
+'}'"#,
);
assert_eq!(actual, expected);
}
Expand All @@ -235,10 +235,10 @@ fn json_stringify_pretty_print_four_spaces() {
);
let expected = forward(
&mut context,
r#"'{
"a": "b",
"b": "c"
}'"#,
r#"'{\n'
+' "a": "b",\n'
+' "b": "c"\n'
+'}'"#,
);
assert_eq!(actual, expected);
}
Expand All @@ -253,10 +253,10 @@ fn json_stringify_pretty_print_twenty_spaces() {
);
let expected = forward(
&mut context,
r#"'{
"a": "b",
"b": "c"
}'"#,
r#"'{\n'
+' "a": "b",\n'
+' "b": "c"\n'
+'}'"#,
);
assert_eq!(actual, expected);
}
Expand All @@ -271,10 +271,10 @@ fn json_stringify_pretty_print_with_number_object() {
);
let expected = forward(
&mut context,
r#"'{
"a": "b",
"b": "c"
}'"#,
r#"'{\n'
+' "a": "b",\n'
+' "b": "c"\n'
+'}'"#,
);
assert_eq!(actual, expected);
}
Expand All @@ -301,10 +301,10 @@ fn json_stringify_pretty_print_with_too_long_string() {
);
let expected = forward(
&mut context,
r#"'{
abcdefghij"a": "b",
abcdefghij"b": "c"
}'"#,
r#"'{\n'
+'abcdefghij"a": "b",\n'
+'abcdefghij"b": "c"\n'
+'}'"#,
);
assert_eq!(actual, expected);
}
Expand All @@ -319,10 +319,10 @@ fn json_stringify_pretty_print_with_string_object() {
);
let expected = forward(
&mut context,
r#"'{
abcd"a": "b",
abcd"b": "c"
}'"#,
r#"'{\n'
+'abcd"a": "b",\n'
+'abcd"b": "c"\n'
+'}'"#,
);
assert_eq!(actual, expected);
}
Expand Down Expand Up @@ -404,10 +404,7 @@ fn json_parse_object_with_reviver() {
fn json_parse_sets_prototypes() {
let mut context = Context::new();
let init = r#"
const jsonString = "{
\"ob\":{\"ject\":1},
\"arr\": [0,1]
}";
const jsonString = "{\"ob\":{\"ject\":1},\"arr\": [0,1]}";
const jsonObj = JSON.parse(jsonString);
"#;
eprintln!("{}", forward(&mut context, init));
Expand Down
36 changes: 24 additions & 12 deletions boa/src/builtins/string/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,34 +533,46 @@ fn test_match() {
#[test]
fn trim() {
let mut context = Context::new();
assert_eq!(forward(&mut context, "'Hello'.trim()"), "\"Hello\"");
assert_eq!(forward(&mut context, "' \nHello'.trim()"), "\"Hello\"");
assert_eq!(forward(&mut context, "'Hello \n\r'.trim()"), "\"Hello\"");
assert_eq!(forward(&mut context, "' Hello '.trim()"), "\"Hello\"");
assert_eq!(forward(&mut context, r#"'Hello'.trim()"#), "\"Hello\"");
assert_eq!(forward(&mut context, r#"' \nHello'.trim()"#), "\"Hello\"");
assert_eq!(forward(&mut context, r#"'Hello \n\r'.trim()"#), "\"Hello\"");
assert_eq!(forward(&mut context, r#"' Hello '.trim()"#), "\"Hello\"");
}

#[test]
fn trim_start() {
let mut context = Context::new();
assert_eq!(forward(&mut context, "'Hello'.trimStart()"), "\"Hello\"");
assert_eq!(forward(&mut context, "' \nHello'.trimStart()"), "\"Hello\"");
assert_eq!(forward(&mut context, r#"'Hello'.trimStart()"#), "\"Hello\"");
assert_eq!(
forward(&mut context, "'Hello \n'.trimStart()"),
forward(&mut context, r#"' \nHello'.trimStart()"#),
"\"Hello\""
);
assert_eq!(
forward(&mut context, r#"'Hello \n'.trimStart()"#),
"\"Hello \n\""
);
assert_eq!(forward(&mut context, "' Hello '.trimStart()"), "\"Hello \"");
assert_eq!(
forward(&mut context, r#"' Hello '.trimStart()"#),
"\"Hello \""
);
}

#[test]
fn trim_end() {
let mut context = Context::new();
assert_eq!(forward(&mut context, "'Hello'.trimEnd()"), "\"Hello\"");
assert_eq!(forward(&mut context, r#"'Hello'.trimEnd()"#), "\"Hello\"");
assert_eq!(
forward(&mut context, "' \nHello'.trimEnd()"),
forward(&mut context, r#"' \nHello'.trimEnd()"#),
"\" \nHello\""
);
assert_eq!(forward(&mut context, "'Hello \n'.trimEnd()"), "\"Hello\"");
assert_eq!(forward(&mut context, "' Hello '.trimEnd()"), "\" Hello\"");
assert_eq!(
forward(&mut context, r#"'Hello \n'.trimEnd()"#),
"\"Hello\""
);
assert_eq!(
forward(&mut context, r#"' Hello '.trimEnd()"#),
"\" Hello\""
);
}

#[test]
Expand Down

0 comments on commit e698d16

Please sign in to comment.