diff --git a/jerry-core/ecma/builtin-objects/ecma-builtins.c b/jerry-core/ecma/builtin-objects/ecma-builtins.c index 8b3037a31..8ffc75feb 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtins.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtins.c @@ -446,7 +446,6 @@ ecma_instantiate_builtin (ecma_builtin_id_t obj_builtin_id) /**< built-in id */ } #endif /* ENABLED (JERRY_BUILTIN_ARRAY) */ -#if !ENABLED (JERRY_ESNEXT) #if ENABLED (JERRY_BUILTIN_STRING) case ECMA_BUILTIN_ID_STRING_PROTOTYPE: { @@ -483,6 +482,7 @@ ecma_instantiate_builtin (ecma_builtin_id_t obj_builtin_id) /**< built-in id */ } #endif /* ENABLED (JERRY_BUILTIN_BOOLEAN) */ +#if !ENABLED (JERRY_ESNEXT) #if ENABLED (JERRY_BUILTIN_DATE) case ECMA_BUILTIN_ID_DATE_PROTOTYPE: { diff --git a/jerry-core/ecma/builtin-objects/ecma-builtins.inc.h b/jerry-core/ecma/builtin-objects/ecma-builtins.inc.h index 081be2106..f94190fb8 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtins.inc.h +++ b/jerry-core/ecma/builtin-objects/ecma-builtins.inc.h @@ -47,33 +47,6 @@ BUILTIN_ROUTINE (ECMA_BUILTIN_ID_ARRAY, #endif /* ENABLED (JERRY_BUILTIN_ARRAY) */ #if ENABLED (JERRY_ESNEXT) -# if ENABLED (JERRY_BUILTIN_STRING) -/* The String.prototype object (21.1.3) */ -BUILTIN (ECMA_BUILTIN_ID_STRING_PROTOTYPE, - ECMA_OBJECT_TYPE_GENERAL, - ECMA_BUILTIN_ID_OBJECT_PROTOTYPE, - true, - string_prototype) -# endif /* ENABLED (JERRY_BUILTIN_STRING) */ - -# if ENABLED (JERRY_BUILTIN_BOOLEAN) -/* The Boolean.prototype object (19.3.3) */ -BUILTIN (ECMA_BUILTIN_ID_BOOLEAN_PROTOTYPE, - ECMA_OBJECT_TYPE_GENERAL, - ECMA_BUILTIN_ID_OBJECT_PROTOTYPE, - true, - boolean_prototype) -# endif /* ENABLED (JERRY_BUILTIN_BOOLEAN) */ - -# if ENABLED (JERRY_BUILTIN_NUMBER) -/* The Number.prototype object (20.1.3) */ -BUILTIN (ECMA_BUILTIN_ID_NUMBER_PROTOTYPE, - ECMA_OBJECT_TYPE_GENERAL, - ECMA_BUILTIN_ID_OBJECT_PROTOTYPE, - true, - number_prototype) -# endif /* ENABLED (JERRY_BUILTIN_NUMBER) */ - # if ENABLED (JERRY_BUILTIN_DATE) /* The Date.prototype object (20.3.4) */ BUILTIN (ECMA_BUILTIN_ID_DATE_PROTOTYPE, @@ -92,33 +65,6 @@ BUILTIN (ECMA_BUILTIN_ID_REGEXP_PROTOTYPE, regexp_prototype) # endif /* ENABLED (JERRY_BUILTIN_REGEXP) */ #else /* !ENABLED (JERRY_ESNEXT) */ -# if ENABLED (JERRY_BUILTIN_STRING) -/* The String.prototype object (15.5.4) */ -BUILTIN (ECMA_BUILTIN_ID_STRING_PROTOTYPE, - ECMA_OBJECT_TYPE_CLASS, - ECMA_BUILTIN_ID_OBJECT_PROTOTYPE, - true, - string_prototype) -# endif /* ENABLED (JERRY_BUILTIN_STRING) */ - -# if ENABLED (JERRY_BUILTIN_BOOLEAN) -/* The Boolean.prototype object (15.6.4) */ -BUILTIN (ECMA_BUILTIN_ID_BOOLEAN_PROTOTYPE, - ECMA_OBJECT_TYPE_CLASS, - ECMA_BUILTIN_ID_OBJECT_PROTOTYPE, - true, - boolean_prototype) -# endif /* ENABLED (JERRY_BUILTIN_BOOLEAN) */ - -# if ENABLED (JERRY_BUILTIN_NUMBER) -/* The Number.prototype object (15.7.4) */ -BUILTIN (ECMA_BUILTIN_ID_NUMBER_PROTOTYPE, - ECMA_OBJECT_TYPE_CLASS, - ECMA_BUILTIN_ID_OBJECT_PROTOTYPE, - true, - number_prototype) -# endif /* ENABLED (JERRY_BUILTIN_NUMBER) */ - # if ENABLED (JERRY_BUILTIN_DATE) /* The Date.prototype object (15.9.4) */ BUILTIN (ECMA_BUILTIN_ID_DATE_PROTOTYPE, @@ -139,6 +85,13 @@ BUILTIN (ECMA_BUILTIN_ID_REGEXP_PROTOTYPE, #endif /* !ENABLED (JERRY_ESNEXT) */ #if ENABLED (JERRY_BUILTIN_STRING) +/* The String.prototype object (15.5.4) */ +BUILTIN (ECMA_BUILTIN_ID_STRING_PROTOTYPE, + ECMA_OBJECT_TYPE_CLASS, + ECMA_BUILTIN_ID_OBJECT_PROTOTYPE, + true, + string_prototype) + /* The String object (15.5.1) */ BUILTIN_ROUTINE (ECMA_BUILTIN_ID_STRING, ECMA_OBJECT_TYPE_FUNCTION, @@ -148,6 +101,13 @@ BUILTIN_ROUTINE (ECMA_BUILTIN_ID_STRING, #endif /* ENABLED (JERRY_BUILTIN_STRING) */ #if ENABLED (JERRY_BUILTIN_BOOLEAN) +/* The Boolean.prototype object (15.6.4) */ +BUILTIN (ECMA_BUILTIN_ID_BOOLEAN_PROTOTYPE, + ECMA_OBJECT_TYPE_CLASS, + ECMA_BUILTIN_ID_OBJECT_PROTOTYPE, + true, + boolean_prototype) + /* The Boolean object (15.6.1) */ BUILTIN_ROUTINE (ECMA_BUILTIN_ID_BOOLEAN, ECMA_OBJECT_TYPE_FUNCTION, @@ -157,6 +117,13 @@ BUILTIN_ROUTINE (ECMA_BUILTIN_ID_BOOLEAN, #endif /* ENABLED (JERRY_BUILTIN_BOOLEAN) */ #if ENABLED (JERRY_BUILTIN_NUMBER) +/* The Number.prototype object (15.7.4) */ +BUILTIN (ECMA_BUILTIN_ID_NUMBER_PROTOTYPE, + ECMA_OBJECT_TYPE_CLASS, + ECMA_BUILTIN_ID_OBJECT_PROTOTYPE, + true, + number_prototype) + /* The Number object (15.7.1) */ BUILTIN_ROUTINE (ECMA_BUILTIN_ID_NUMBER, ECMA_OBJECT_TYPE_FUNCTION, diff --git a/jerry-core/ecma/operations/ecma-objects.c b/jerry-core/ecma/operations/ecma-objects.c index cf1ebfeaf..394637ee4 100644 --- a/jerry-core/ecma/operations/ecma-objects.c +++ b/jerry-core/ecma/operations/ecma-objects.c @@ -2648,9 +2648,6 @@ ecma_object_check_class_name_is_object (ecma_object_t *obj_p) /**< object */ || ecma_builtin_is (obj_p, ECMA_BUILTIN_ID_TYPE_ERROR_PROTOTYPE) || ecma_builtin_is (obj_p, ECMA_BUILTIN_ID_URI_ERROR_PROTOTYPE) || ecma_builtin_is (obj_p, ECMA_BUILTIN_ID_ERROR_PROTOTYPE) - || ecma_builtin_is (obj_p, ECMA_BUILTIN_ID_STRING_PROTOTYPE) - || ecma_builtin_is (obj_p, ECMA_BUILTIN_ID_BOOLEAN_PROTOTYPE) - || ecma_builtin_is (obj_p, ECMA_BUILTIN_ID_NUMBER_PROTOTYPE) || ecma_builtin_is (obj_p, ECMA_BUILTIN_ID_DATE_PROTOTYPE) || ecma_builtin_is (obj_p, ECMA_BUILTIN_ID_REGEXP_PROTOTYPE) || ecma_builtin_is (obj_p, ECMA_BUILTIN_ID_SYMBOL_PROTOTYPE) diff --git a/tests/jerry/builtin-prototypes.js b/tests/jerry/builtin-prototypes.js new file mode 100644 index 000000000..b73b701e4 --- /dev/null +++ b/tests/jerry/builtin-prototypes.js @@ -0,0 +1,23 @@ +/* Copyright JS Foundation and other contributors, http://js.foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +assert (Object.prototype.toString.call (String.prototype) === '[object String]'); +assert (String.prototype.toString() === ""); + +assert (Object.prototype.toString.call (Boolean.prototype) === '[object Boolean]'); +assert (Boolean.prototype.valueOf() === false); + +assert (Object.prototype.toString.call (Number.prototype) === '[object Number]'); +assert (Number.prototype.valueOf() === 0); diff --git a/tests/jerry/es.next/builtin-prototypes.js b/tests/jerry/es.next/builtin-prototypes.js index 0a852d0e4..3266c5a94 100644 --- a/tests/jerry/es.next/builtin-prototypes.js +++ b/tests/jerry/es.next/builtin-prototypes.js @@ -14,9 +14,6 @@ */ var prototypes = [ - String.prototype, - Boolean.prototype, - Number.prototype, Date.prototype, RegExp.prototype, Error.prototype, @@ -32,27 +29,6 @@ for (proto of prototypes) { assert (Object.prototype.toString.call (proto) === '[object Object]'); } -try { - String.prototype.toString(); - assert (false); -} catch (e) { - assert (e instanceof TypeError); -} - -try { - Boolean.prototype.valueOf(); - assert (false); -} catch (e) { - assert (e instanceof TypeError); -} - -try { - Number.prototype.valueOf(); - assert (false); -} catch (e) { - assert (e instanceof TypeError); -} - try { Date.prototype.valueOf(); assert (false); diff --git a/tests/jerry/es5.1/builtin-prototypes.js b/tests/jerry/es5.1/builtin-prototypes.js index c4be5bfed..c43ec439e 100644 --- a/tests/jerry/es5.1/builtin-prototypes.js +++ b/tests/jerry/es5.1/builtin-prototypes.js @@ -13,15 +13,6 @@ * limitations under the License. */ -assert (Object.prototype.toString.call (String.prototype) === '[object String]'); -assert (String.prototype.toString() === ""); - -assert (Object.prototype.toString.call (Boolean.prototype) === '[object Boolean]'); -assert (Boolean.prototype.valueOf() === false); - -assert (Object.prototype.toString.call (Number.prototype) === '[object Number]'); -assert (Number.prototype.valueOf() === 0); - assert (Object.prototype.toString.call (Date.prototype) === '[object Date]'); assert (isNaN(Date.prototype.valueOf())); diff --git a/tests/test262-es6-excludelist.xml b/tests/test262-es6-excludelist.xml index b3478cf8c..582256876 100644 --- a/tests/test262-es6-excludelist.xml +++ b/tests/test262-es6-excludelist.xml @@ -28,12 +28,6 @@ - - - - - - @@ -44,51 +38,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -151,9 +100,6 @@ - - -