Add test_dataview (#4677)
JerryScript-DCO-1.0-Signed-off-by: Gergo Csizi csgergo92@gmail.com
This commit is contained in:
@@ -39,14 +39,19 @@ Enum that contains JerryScript **object** value types:
|
||||
|
||||
- JERRY_OBJECT_TYPE_NONE - Non-object type
|
||||
- JERRY_OBJECT_TYPE_GENERIC - Generic JavaScript object without any internal property
|
||||
- JERRY_OBJECT_TYPE_MODULE_NAMESPACE - Module namespace object
|
||||
- JERRY_OBJECT_TYPE_ARRAY - Array object
|
||||
- JERRY_OBJECT_TYPE_PROXY - Proxy object
|
||||
- JERRY_OBJECT_TYPE_SCRIPT - Script object (see [jerry_parse](#jerry_parse))
|
||||
- JERRY_OBJECT_TYPE_MODULE - Module object (see [jerry_parse](#jerry_parse))
|
||||
- JERRY_OBJECT_TYPE_PROMISE - Promise object
|
||||
- JERRY_OBJECT_TYPE_DATAVIEW - Dataview object
|
||||
- JERRY_OBJECT_TYPE_FUNCTION - Function object (see [jerry_function_get_type](#jerry_function_get_type))
|
||||
- JERRY_OBJECT_TYPE_TYPEDARRAY - %TypedArray% object (see [jerry_get_typedarray_type](#jerry_get_typedarray_type))
|
||||
- JERRY_OBJECT_TYPE_ITERATOR - Iterator object (see [jerry_iterator_get_type](#jerry_get_typedarray_type))
|
||||
- JERRY_OBJECT_TYPE_CONTAINER - Container object (see [jerry_get_container_type](#jerry_get_container_type))
|
||||
- JERRY_OBJECT_TYPE_ERROR - Error object
|
||||
- JERRY_OBJECT_TYPE_ARRAYBUFFER - Array buffer object
|
||||
|
||||
- JERRY_OBJECT_TYPE_ARGUMENTS - Arguments object
|
||||
- JERRY_OBJECT_TYPE_BOOLEAN - Boolean object
|
||||
|
||||
@@ -1513,7 +1513,7 @@ static const uint8_t jerry_class_object_type[] =
|
||||
JERRY_OBJECT_TYPE_TYPEDARRAY, /**< type of ECMA_OBJECT_CLASS_TYPEDARRAY */
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
JERRY_OBJECT_TYPE_GENERIC, /**< type of ECMA_OBJECT_CLASS_MODULE_NAMESPACE */
|
||||
JERRY_OBJECT_TYPE_MODULE_NAMESPACE, /**< type of ECMA_OBJECT_CLASS_MODULE_NAMESPACE */
|
||||
#endif
|
||||
|
||||
/* These objects are marked by Garbage Collector. */
|
||||
@@ -1524,18 +1524,18 @@ static const uint8_t jerry_class_object_type[] =
|
||||
JERRY_OBJECT_TYPE_ITERATOR, /**< type of ECMA_OBJECT_CLASS_SET_ITERATOR */
|
||||
JERRY_OBJECT_TYPE_ITERATOR, /**< type of ECMA_OBJECT_CLASS_MAP_ITERATOR */
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
JERRY_OBJECT_TYPE_GENERIC, /**< type of ECMA_OBJECT_CLASS_REGEXP_STRING_ITERATOR */
|
||||
JERRY_OBJECT_TYPE_ITERATOR, /**< type of ECMA_OBJECT_CLASS_REGEXP_STRING_ITERATOR */
|
||||
#endif /* JERRY_BUILTIN_REGEXP */
|
||||
#endif /* JERRY_ESNEXT */
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
JERRY_OBJECT_TYPE_MODULE, /**< type of ECMA_OBJECT_CLASS_MODULE */
|
||||
#endif
|
||||
#if JERRY_BUILTIN_PROMISE
|
||||
JERRY_OBJECT_TYPE_GENERIC, /**< type of ECMA_OBJECT_CLASS_PROMISE */
|
||||
JERRY_OBJECT_TYPE_PROMISE, /**< type of ECMA_OBJECT_CLASS_PROMISE */
|
||||
JERRY_OBJECT_TYPE_GENERIC, /**< type of ECMA_OBJECT_CLASS_PROMISE_CAPABILITY */
|
||||
#endif /* JERRY_BUILTIN_PROMISE */
|
||||
#if JERRY_BUILTIN_DATAVIEW
|
||||
JERRY_OBJECT_TYPE_GENERIC, /**< type of ECMA_OBJECT_CLASS_DATAVIEW */
|
||||
JERRY_OBJECT_TYPE_DATAVIEW, /**< type of ECMA_OBJECT_CLASS_DATAVIEW */
|
||||
#endif /* JERRY_BUILTIN_DATAVIEW */
|
||||
#if JERRY_BUILTIN_CONTAINER
|
||||
JERRY_OBJECT_TYPE_CONTAINER, /**< type of ECMA_OBJECT_CLASS_CONTAINER */
|
||||
@@ -1544,7 +1544,7 @@ static const uint8_t jerry_class_object_type[] =
|
||||
/* Normal objects. */
|
||||
JERRY_OBJECT_TYPE_BOOLEAN, /**< type of ECMA_OBJECT_CLASS_BOOLEAN */
|
||||
JERRY_OBJECT_TYPE_NUMBER, /**< type of ECMA_OBJECT_CLASS_NUMBER */
|
||||
JERRY_OBJECT_TYPE_GENERIC, /**< type of ECMA_OBJECT_CLASS_ERROR */
|
||||
JERRY_OBJECT_TYPE_ERROR, /**< type of ECMA_OBJECT_CLASS_ERROR */
|
||||
JERRY_OBJECT_TYPE_GENERIC, /**< type of ECMA_OBJECT_CLASS_INTERNAL_OBJECT */
|
||||
#if JERRY_PARSER
|
||||
JERRY_OBJECT_TYPE_SCRIPT, /**< type of ECMA_OBJECT_CLASS_SCRIPT */
|
||||
@@ -1560,7 +1560,7 @@ static const uint8_t jerry_class_object_type[] =
|
||||
JERRY_OBJECT_TYPE_ITERATOR, /**< type of ECMA_OBJECT_CLASS_STRING_ITERATOR */
|
||||
#endif /* JERRY_ESNEXT */
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
JERRY_OBJECT_TYPE_GENERIC, /**< type of ECMA_OBJECT_CLASS_ARRAY_BUFFER */
|
||||
JERRY_OBJECT_TYPE_ARRAYBUFFER, /**< type of ECMA_OBJECT_CLASS_ARRAY_BUFFER */
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
JERRY_OBJECT_TYPE_BIGINT, /**< type of ECMA_OBJECT_CLASS_BIGINT */
|
||||
|
||||
@@ -473,27 +473,32 @@ typedef enum
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
JERRY_OBJECT_TYPE_NONE = 0u, /**< Non object type */
|
||||
JERRY_OBJECT_TYPE_GENERIC, /**< Generic JavaScript object without any internal property */
|
||||
JERRY_OBJECT_TYPE_ARRAY, /**< Array object */
|
||||
JERRY_OBJECT_TYPE_PROXY, /**< Proxy object */
|
||||
JERRY_OBJECT_TYPE_SCRIPT, /**< Script object (see jerry_parse) */
|
||||
JERRY_OBJECT_TYPE_MODULE, /**< Module object (see jerry_parse) */
|
||||
JERRY_OBJECT_TYPE_FUNCTION, /**< Function object (see jerry_function_get_type) */
|
||||
JERRY_OBJECT_TYPE_TYPEDARRAY, /**< %TypedArray% object (see jerry_get_typedarray_type) */
|
||||
JERRY_OBJECT_TYPE_ITERATOR, /**< Iterator object (see jerry_iterator_get_type) */
|
||||
JERRY_OBJECT_TYPE_CONTAINER, /**< Container object (see jerry_container_get_type) */
|
||||
JERRY_OBJECT_TYPE_NONE = 0u, /**< Non object type */
|
||||
JERRY_OBJECT_TYPE_GENERIC, /**< Generic JavaScript object without any internal property */
|
||||
JERRY_OBJECT_TYPE_MODULE_NAMESPACE, /**< Namespace object */
|
||||
JERRY_OBJECT_TYPE_ARRAY, /**< Array object */
|
||||
JERRY_OBJECT_TYPE_PROXY, /**< Proxy object */
|
||||
JERRY_OBJECT_TYPE_SCRIPT, /**< Script object (see jerry_parse) */
|
||||
JERRY_OBJECT_TYPE_MODULE, /**< Module object (see jerry_parse) */
|
||||
JERRY_OBJECT_TYPE_PROMISE, /**< Promise object */
|
||||
JERRY_OBJECT_TYPE_DATAVIEW, /**< Dataview object */
|
||||
JERRY_OBJECT_TYPE_FUNCTION, /**< Function object (see jerry_function_get_type) */
|
||||
JERRY_OBJECT_TYPE_TYPEDARRAY, /**< %TypedArray% object (see jerry_get_typedarray_type) */
|
||||
JERRY_OBJECT_TYPE_ITERATOR, /**< Iterator object (see jerry_iterator_get_type) */
|
||||
JERRY_OBJECT_TYPE_CONTAINER, /**< Container object (see jerry_container_get_type) */
|
||||
JERRY_OBJECT_TYPE_ERROR, /**< Error object */
|
||||
JERRY_OBJECT_TYPE_ARRAYBUFFER, /**< Array buffer object */
|
||||
|
||||
JERRY_OBJECT_TYPE_ARGUMENTS, /**< Arguments object */
|
||||
JERRY_OBJECT_TYPE_BOOLEAN, /**< Boolean object */
|
||||
JERRY_OBJECT_TYPE_DATE, /**< Date object */
|
||||
JERRY_OBJECT_TYPE_NUMBER, /**< Number object */
|
||||
JERRY_OBJECT_TYPE_REGEXP, /**< RegExp object */
|
||||
JERRY_OBJECT_TYPE_STRING, /**< String object */
|
||||
JERRY_OBJECT_TYPE_SYMBOL, /**< Symbol object */
|
||||
JERRY_OBJECT_TYPE_GENERATOR, /**< Generator object */
|
||||
JERRY_OBJECT_TYPE_BIGINT, /**< BigInt object */
|
||||
JERRY_OBJECT_TYPE_WEAKREF, /**< WeakRef object */
|
||||
JERRY_OBJECT_TYPE_ARGUMENTS, /**< Arguments object */
|
||||
JERRY_OBJECT_TYPE_BOOLEAN, /**< Boolean object */
|
||||
JERRY_OBJECT_TYPE_DATE, /**< Date object */
|
||||
JERRY_OBJECT_TYPE_NUMBER, /**< Number object */
|
||||
JERRY_OBJECT_TYPE_REGEXP, /**< RegExp object */
|
||||
JERRY_OBJECT_TYPE_STRING, /**< String object */
|
||||
JERRY_OBJECT_TYPE_SYMBOL, /**< Symbol object */
|
||||
JERRY_OBJECT_TYPE_GENERATOR, /**< Generator object */
|
||||
JERRY_OBJECT_TYPE_BIGINT, /**< BigInt object */
|
||||
JERRY_OBJECT_TYPE_WEAKREF, /**< WeakRef object */
|
||||
} jerry_object_type_t;
|
||||
|
||||
/**
|
||||
|
||||
@@ -40,6 +40,28 @@ test_ext_function (const jerry_call_info_t *call_info_p, /**< call information *
|
||||
return jerry_create_boolean (true);
|
||||
} /* test_ext_function */
|
||||
|
||||
static jerry_object_type_t
|
||||
test_namespace (const jerry_parse_options_t module_parse_options) /** module options */
|
||||
{
|
||||
jerry_value_t module = jerry_parse ((const jerry_char_t *) "", 0, &module_parse_options);
|
||||
jerry_value_t module_linked = jerry_module_link (module, NULL, NULL);
|
||||
jerry_object_type_t namespace = jerry_module_get_namespace (module);
|
||||
jerry_release_value (module_linked);
|
||||
jerry_release_value (module);
|
||||
return namespace;
|
||||
} /* test_namespace */
|
||||
|
||||
static jerry_value_t
|
||||
test_dataview (void)
|
||||
{
|
||||
jerry_value_t arraybuffer = jerry_create_arraybuffer (10);
|
||||
jerry_value_t dataview = jerry_create_dataview (arraybuffer, 0, 4);
|
||||
|
||||
jerry_release_value (arraybuffer);
|
||||
|
||||
return dataview;
|
||||
} /* test_dataview */
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
@@ -74,6 +96,7 @@ main (void)
|
||||
const jerry_char_t regexp_object[] = "new RegExp()";
|
||||
const jerry_char_t string_object[] = "new String('foo')";
|
||||
const jerry_char_t weak_ref_object[] = "new WeakRef({})";
|
||||
const jerry_char_t error_object[] = "new Error()";
|
||||
|
||||
jerry_parse_options_t module_parse_options;
|
||||
module_parse_options.options = JERRY_PARSE_MODULE;
|
||||
@@ -88,6 +111,7 @@ main (void)
|
||||
ENTRY (JERRY_OBJECT_TYPE_NONE, jerry_create_error (JERRY_ERROR_TYPE, (const jerry_char_t *) "error")),
|
||||
|
||||
ENTRY (JERRY_OBJECT_TYPE_GENERIC, jerry_create_object ()),
|
||||
ENTRY_IF (JERRY_OBJECT_TYPE_MODULE_NAMESPACE, test_namespace (module_parse_options), JERRY_FEATURE_MODULE),
|
||||
ENTRY (JERRY_OBJECT_TYPE_ARRAY, jerry_create_array (10)),
|
||||
|
||||
ENTRY_IF (JERRY_OBJECT_TYPE_PROXY, EVALUATE (proxy_object), JERRY_FEATURE_PROXY),
|
||||
@@ -97,6 +121,8 @@ main (void)
|
||||
|
||||
ENTRY (JERRY_OBJECT_TYPE_SCRIPT, PARSE (NULL)),
|
||||
ENTRY_IF (JERRY_OBJECT_TYPE_MODULE, PARSE (&module_parse_options), JERRY_FEATURE_MODULE),
|
||||
ENTRY_IF (JERRY_OBJECT_TYPE_PROMISE, jerry_create_promise (), JERRY_FEATURE_PROMISE),
|
||||
ENTRY_IF (JERRY_OBJECT_TYPE_DATAVIEW, test_dataview (), JERRY_FEATURE_DATAVIEW),
|
||||
ENTRY_IF (JERRY_OBJECT_TYPE_FUNCTION, EVALUATE (arrow_function), JERRY_FEATURE_SYMBOL),
|
||||
ENTRY_IF (JERRY_OBJECT_TYPE_FUNCTION, EVALUATE (async_arrow_function), JERRY_FEATURE_SYMBOL),
|
||||
ENTRY_IF (JERRY_OBJECT_TYPE_FUNCTION, EVALUATE (generator_function), JERRY_FEATURE_SYMBOL),
|
||||
@@ -108,6 +134,8 @@ main (void)
|
||||
ENTRY (JERRY_OBJECT_TYPE_FUNCTION, jerry_create_external_function (test_ext_function)),
|
||||
ENTRY (JERRY_OBJECT_TYPE_FUNCTION, EVALUATE (getter_function)),
|
||||
ENTRY (JERRY_OBJECT_TYPE_FUNCTION, EVALUATE (setter_function)),
|
||||
ENTRY_IF (JERRY_OBJECT_TYPE_ERROR, EVALUATE (error_object), JERRY_FEATURE_ERROR_MESSAGES),
|
||||
ENTRY_IF (JERRY_OBJECT_TYPE_ARRAYBUFFER, jerry_create_arraybuffer (10), JERRY_FEATURE_TYPEDARRAY),
|
||||
|
||||
ENTRY (JERRY_OBJECT_TYPE_ARGUMENTS, EVALUATE (mapped_arguments)),
|
||||
ENTRY (JERRY_OBJECT_TYPE_ARGUMENTS, EVALUATE (unmapped_arguments)),
|
||||
@@ -125,6 +153,7 @@ main (void)
|
||||
for (size_t idx = 0; idx < sizeof (entries) / sizeof (entries[0]); idx++)
|
||||
{
|
||||
jerry_object_type_t type_info = jerry_object_get_type (entries[idx].value);
|
||||
|
||||
TEST_ASSERT (!entries[idx].active || type_info == entries[idx].type_info);
|
||||
jerry_release_value (entries[idx].value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user