Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup #1276

Merged
merged 3 commits into from
May 23, 2021
Merged

Cleanup #1276

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,29 @@ jobs:
command: clippy
args: -- --verbose

examples:
name: Examples
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
- uses: actions-rs/toolchain@v1.0.7
with:
toolchain: stable
override: true
profile: minimal
- name: Cache cargo
uses: actions/cache@v2.1.5
with:
path: |
target
~/.cargo/git
~/.cargo/registry
key: ${{ runner.os }}-cargo-examples-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/cargo@v1
with:
command: build
args: --examples -v

doc:
name: Documentation check
runs-on: ubuntu-latest
Expand Down
84 changes: 48 additions & 36 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion boa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ chrono = "0.4.19"
fast-float = "0.2.0"

# Optional Dependencies
measureme = { version = "9.1.1", optional = true }
measureme = { version = "9.1.2", optional = true }
once_cell = { version = "1.7.2", optional = true }

[dev-dependencies]
Expand Down
5 changes: 4 additions & 1 deletion boa/src/builtins/array/array_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ impl ArrayIterator {
array_iterator.set_prototype_instance(iterator_prototype);

let to_string_tag = WellKnownSymbols::to_string_tag();
let to_string_tag_property = DataDescriptor::new("Array Iterator", Attribute::CONFIGURABLE);
let to_string_tag_property = DataDescriptor::new(
"Array Iterator",
Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE,
);
array_iterator.insert(to_string_tag, to_string_tag_property);
array_iterator
}
Expand Down
2 changes: 1 addition & 1 deletion boa/src/builtins/bigint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl BuiltIn for BigInt {
.constructable(false)
.property(
to_string_tag,
"BigInt",
Self::NAME,
Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE,
)
.build();
Expand Down
2 changes: 1 addition & 1 deletion boa/src/builtins/json/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl BuiltIn for Json {
let attribute = Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE;

let json_object = ObjectInitializer::new(context)
.property(to_string_tag, "JSON", attribute)
.property(to_string_tag, Self::NAME, attribute)
.function(Self::parse, "parse", 2)
.function(Self::stringify, "stringify", 3)
.build();
Expand Down
5 changes: 4 additions & 1 deletion boa/src/builtins/map/map_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ impl MapIterator {
map_iterator.set_prototype_instance(iterator_prototype);

let to_string_tag = WellKnownSymbols::to_string_tag();
let to_string_tag_property = DataDescriptor::new("Map Iterator", Attribute::CONFIGURABLE);
let to_string_tag_property = DataDescriptor::new(
"Map Iterator",
Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE,
);
map_iterator.insert(to_string_tag, to_string_tag_property);
map_iterator
}
Expand Down
3 changes: 1 addition & 2 deletions boa/src/builtins/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ impl BuiltIn for Map {
let _timer = BoaProfiler::global().start_event(Self::NAME, "init");

let to_string_tag = WellKnownSymbols::to_string_tag();

let iterator_symbol = WellKnownSymbols::iterator();

let entries_function = FunctionBuilder::new(context, Self::entries)
Expand All @@ -66,7 +65,7 @@ impl BuiltIn for Map {
)
.property(
to_string_tag,
"Map",
Self::NAME,
Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE,
)
.property(
Expand Down
2 changes: 1 addition & 1 deletion boa/src/builtins/math/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl BuiltIn for Math {
.property("PI", f64::consts::PI, attribute)
.property(
to_string_tag,
"Math",
Self::NAME,
Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE,
)
.function(Self::abs, "abs", 1)
Expand Down
6 changes: 4 additions & 2 deletions boa/src/builtins/object/for_in_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,10 @@ impl ForInIterator {
for_in_iterator.set_prototype_instance(iterator_prototype);

let to_string_tag = WellKnownSymbols::to_string_tag();
let to_string_tag_property =
DataDescriptor::new("For In Iterator", Attribute::CONFIGURABLE);
let to_string_tag_property = DataDescriptor::new(
"For In Iterator",
Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE,
);
for_in_iterator.insert(to_string_tag, to_string_tag_property);
for_in_iterator
}
Expand Down
2 changes: 1 addition & 1 deletion boa/src/builtins/reflect/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl BuiltIn for Reflect {
.function(Self::set_prototype_of, "setPrototypeOf", 3)
.property(
to_string_tag,
Reflect::NAME,
Self::NAME,
Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE,
)
.build();
Expand Down
6 changes: 5 additions & 1 deletion boa/src/builtins/set/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ impl BuiltIn for Set {
values_function,
Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE,
)
.property(to_string_tag, "Set", Attribute::CONFIGURABLE)
.property(
to_string_tag,
Self::NAME,
Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE,
)
.build();

(Self::NAME, set_object.into(), Self::attribute())
Expand Down
5 changes: 4 additions & 1 deletion boa/src/builtins/set/set_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ impl SetIterator {
set_iterator.set_prototype_instance(iterator_prototype);

let to_string_tag = WellKnownSymbols::to_string_tag();
let to_string_tag_property = DataDescriptor::new("Set Iterator", Attribute::CONFIGURABLE);
let to_string_tag_property = DataDescriptor::new(
"Set Iterator",
Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE,
);
set_iterator.insert(to_string_tag, to_string_tag_property);
set_iterator
}
Expand Down
4 changes: 2 additions & 2 deletions boa/src/builtins/string/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ impl String {

// Fast path returning NaN when pos is obviously out of range
if pos < 0 || pos >= primitive_val.len() as i32 {
return Ok(Value::from(f64::NAN));
return Ok(Value::nan());
}

// Calling .len() on a string would give the wrong result, as they are bytes not the number of unicode code points
Expand All @@ -344,7 +344,7 @@ impl String {
if let Some(utf16_val) = primitive_val.encode_utf16().nth(pos as usize) {
Ok(Value::from(f64::from(utf16_val)))
} else {
Ok(Value::from(f64::NAN))
Ok(Value::nan())
}
}

Expand Down
Loading