Skip to content

Commit

Permalink
Fixed some documentation and clippy warnings in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Razican committed Oct 21, 2022
1 parent d51fee7 commit 38f5281
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 47 deletions.
44 changes: 22 additions & 22 deletions boa_engine/src/builtins/intl/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,31 @@ fn best_avail_loc() {
let no_extensions_locale = "en-US";
let available_locales = Vec::new();
assert_eq!(
best_available_locale(&available_locales, &no_extensions_locale,),
best_available_locale(&available_locales, no_extensions_locale),
None
);

let no_extensions_locale = "de-DE";
let available_locales = vec![no_extensions_locale.clone()];
let available_locales = vec![no_extensions_locale];
assert_eq!(
best_available_locale(&available_locales, &no_extensions_locale,),
best_available_locale(&available_locales, no_extensions_locale),
Some(no_extensions_locale)
);

let locale_part = "fr";
let no_extensions_locale = locale_part.to_string() + "-CA";
let available_locales = vec![locale_part];
assert_eq!(
best_available_locale(&available_locales, &no_extensions_locale,),
best_available_locale(&available_locales, &no_extensions_locale),
Some(locale_part)
);

let ja_kana_t = "ja-Kana-JP-t";
let ja_kana = "ja-Kana-JP";
let no_extensions_locale = "ja-Kana-JP-t-it-latn-it";
let available_locales = vec![ja_kana_t, ja_kana.clone()];
let available_locales = vec![ja_kana_t, ja_kana];
assert_eq!(
best_available_locale(&available_locales, &no_extensions_locale,),
best_available_locale(&available_locales, no_extensions_locale),
Some(ja_kana)
);
}
Expand Down Expand Up @@ -98,29 +98,29 @@ fn insert_unicode_ext() {
let locale = "hu-HU";
let ext = "";
assert_eq!(
insert_unicode_extension_and_canonicalize(&locale, &ext, &canonicalizer),
insert_unicode_extension_and_canonicalize(locale, ext, &canonicalizer),
locale
);

let locale = "hu-HU";
let ext = "-u-hc-h12";
assert_eq!(
insert_unicode_extension_and_canonicalize(&locale, &ext, &canonicalizer),
insert_unicode_extension_and_canonicalize(locale, ext, &canonicalizer),
"hu-HU-u-hc-h12"
);

let locale = "hu-HU-x-PRIVATE";
let ext = "-u-hc-h12";
assert_eq!(
insert_unicode_extension_and_canonicalize(&locale, &ext, &canonicalizer),
insert_unicode_extension_and_canonicalize(locale, ext, &canonicalizer),
"hu-HU-u-hc-h12-x-private"
);
}

#[test]
fn uni_ext_comp() {
let ext = "-u-ca-japanese-hc-h12";
let components = unicode_extension_components(&ext);
let components = unicode_extension_components(ext);
assert!(components.attributes.is_empty());
assert_eq!(components.keywords.len(), 2);
assert_eq!(components.keywords[0].key, "ca");
Expand All @@ -129,7 +129,7 @@ fn uni_ext_comp() {
assert_eq!(components.keywords[1].value, "h12");

let ext = "-u-alias-co-phonebk-ka-shifted";
let components = unicode_extension_components(&ext);
let components = unicode_extension_components(ext);
assert_eq!(components.attributes, vec![String::from("alias")]);
assert_eq!(components.keywords.len(), 2);
assert_eq!(components.keywords[0].key, "co");
Expand All @@ -138,7 +138,7 @@ fn uni_ext_comp() {
assert_eq!(components.keywords[1].value, "shifted");

let ext = "-u-ca-buddhist-kk-nu-thai";
let components = unicode_extension_components(&ext);
let components = unicode_extension_components(ext);
assert!(components.attributes.is_empty());
assert_eq!(components.keywords.len(), 3);
assert_eq!(components.keywords[0].key, "ca");
Expand All @@ -149,7 +149,7 @@ fn uni_ext_comp() {
assert_eq!(components.keywords[2].value, "thai");

let ext = "-u-ca-islamic-civil";
let components = unicode_extension_components(&ext);
let components = unicode_extension_components(ext);
assert!(components.attributes.is_empty());
assert_eq!(components.keywords.len(), 1);
assert_eq!(components.keywords[0].key, "ca");
Expand Down Expand Up @@ -478,11 +478,11 @@ fn to_date_time_opts() {
let numeric_jsstring = JsValue::String("numeric".into());
assert_eq!(
date_time_opts.get("year", &mut context).unwrap(),
numeric_jsstring.clone()
numeric_jsstring
);
assert_eq!(
date_time_opts.get("month", &mut context).unwrap(),
numeric_jsstring.clone()
numeric_jsstring
);
assert_eq!(
date_time_opts.get("day", &mut context).unwrap(),
Expand All @@ -500,11 +500,11 @@ fn to_date_time_opts() {
let numeric_jsstring = JsValue::String("numeric".into());
assert_eq!(
date_time_opts.get("hour", &mut context).unwrap(),
numeric_jsstring.clone()
numeric_jsstring
);
assert_eq!(
date_time_opts.get("minute", &mut context).unwrap(),
numeric_jsstring.clone()
numeric_jsstring
);
assert_eq!(
date_time_opts.get("second", &mut context).unwrap(),
Expand All @@ -522,23 +522,23 @@ fn to_date_time_opts() {
let numeric_jsstring = JsValue::String("numeric".into());
assert_eq!(
date_time_opts.get("year", &mut context).unwrap(),
numeric_jsstring.clone()
numeric_jsstring
);
assert_eq!(
date_time_opts.get("month", &mut context).unwrap(),
numeric_jsstring.clone()
numeric_jsstring
);
assert_eq!(
date_time_opts.get("day", &mut context).unwrap(),
numeric_jsstring.clone()
numeric_jsstring
);
assert_eq!(
date_time_opts.get("hour", &mut context).unwrap(),
numeric_jsstring.clone()
numeric_jsstring
);
assert_eq!(
date_time_opts.get("minute", &mut context).unwrap(),
numeric_jsstring.clone()
numeric_jsstring
);
assert_eq!(
date_time_opts.get("second", &mut context).unwrap(),
Expand Down
3 changes: 2 additions & 1 deletion boa_engine/src/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ impl Context {
/// This is more efficient that creating a closure function, since this does not allocate,
/// it is just a function pointer.
///
/// The function will be both `constructable` (call with `new`).
/// The function will be both `constructable` (call with `new <name>()`) and `callable` (call
/// with `<name>()`).
///
/// The function will be bound to the global object with `writable`, `non-enumerable`
/// and `configurable` attributes. The same as when you create a function in JavaScript.
Expand Down
42 changes: 18 additions & 24 deletions boa_engine/src/syntax/parser/statement/iteration/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ fn check_do_while() {
)),
))]
.into(),
)
.into(),
),
Literal::from(true).into(),
))
.into()],
Expand Down Expand Up @@ -83,8 +82,7 @@ fn check_do_while_semicolon_insertion() {
)),
))]
.into(),
)
.into(),
),
Binary::new(
RelationalOp::LessThan.into(),
Unary::new(
Expand Down Expand Up @@ -133,29 +131,25 @@ fn check_do_while_semicolon_insertion_no_space() {
.into(),
Statement::DoWhileLoop(DoWhileLoop::new(
Statement::Block(
vec![
StatementListItem::Statement(Statement::Expression(Expression::from(
Call::new(
PropertyAccess::new(
Identifier::new(
interner.get_or_intern_static("console", utf16!("console")),
)
.into(),
interner.get_or_intern_static("log", utf16!("log")),
)
.into(),
vec![Literal::from(
interner.get_or_intern_static("hello", utf16!("hello")),
vec![StatementListItem::Statement(Statement::Expression(
Expression::from(Call::new(
PropertyAccess::new(
Identifier::new(
interner.get_or_intern_static("console", utf16!("console")),
)
.into()]
.into(),
),
)))
.into(),
]
interner.get_or_intern_static("log", utf16!("log")),
)
.into(),
vec![Literal::from(
interner.get_or_intern_static("hello", utf16!("hello")),
)
.into()]
.into(),
)),
))]
.into(),
)
.into(),
),
Binary::new(
RelationalOp::LessThan.into(),
Unary::new(
Expand Down

0 comments on commit 38f5281

Please sign in to comment.