Skip to content

Commit

Permalink
Merged create into init
Browse files Browse the repository at this point in the history
  • Loading branch information
HalidOdat committed Jul 24, 2020
1 parent c4ce592 commit e2ff60e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
19 changes: 8 additions & 11 deletions boa/src/builtins/regexp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,11 @@ impl RegExp {
Ok(result)
}

/// Create a new `RegExp` object.
pub(crate) fn create(global: &Value) -> Value {
/// Initialise the `RegExp` object on the global object.
#[inline]
pub(crate) fn init(global: &Value) -> (&str, Value) {
let _timer = BoaProfiler::global().start_event(Self::NAME, "init");

// Create prototype
let prototype = Value::new_object(Some(global));
prototype
Expand All @@ -497,22 +500,16 @@ impl RegExp {
// make_builtin_fn(Self::get_sticky, "sticky", &prototype, 0);
// make_builtin_fn(Self::get_unicode, "unicode", &prototype, 0);

make_constructor_fn(
let regexp = make_constructor_fn(
Self::NAME,
Self::LENGTH,
Self::make_regexp,
global,
prototype,
true,
true,
)
}

/// Initialise the `RegExp` object on the global object.
#[inline]
pub(crate) fn init(global: &Value) -> (&str, Value) {
let _timer = BoaProfiler::global().start_event(Self::NAME, "init");
);

(Self::NAME, Self::create(global))
(Self::NAME, regexp)
}
}
8 changes: 0 additions & 8 deletions boa/src/builtins/regexp/tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use super::*;
use crate::{exec::Interpreter, forward, realm::Realm};

#[test]
Expand All @@ -17,13 +16,6 @@ fn constructors() {
assert_eq!(forward(&mut engine, "ctor_literal.test('1.0')"), "true");
}

#[test]
fn check_regexp_constructor_is_function() {
let global = Value::new_object(None);
let regexp_constructor = RegExp::create(&global);
assert_eq!(regexp_constructor.is_function(), true);
}

// TODO: uncomment this test when property getters are supported

// #[test]
Expand Down

0 comments on commit e2ff60e

Please sign in to comment.