Repository: jerryscript-project/jerryscript
File: tests/unit-core/test-api-objecttype.c (C)

Code before:
{
  jerry_object_type_t type_info;
  jerry_value_t value;
  bool active;
} test_entry_t;

#define ENTRY(TYPE, VALUE) { TYPE, VALUE, true }
#define ENTRY_IF(TYPE, VALUE, FEATURE) { TYPE, VALUE, jerry_is_feature_enabled (FEATURE) }
#define EVALUATE(BUFF) (jerry_eval ((BUFF), sizeof ((BUFF)) - 1, JERRY_PARSE_NO_OPTS))
#define PARSE(OPTS) (jerry_parse ((const jerry_char_t *) "", 0, (OPTS)))
static jerry_value_t
test_ext_function (const jerry_call_info_t *call_info_p, /**< call information */
                   const jerry_value_t args_p[], /**< array of arguments */
                   const jerry_length_t args_cnt) /**< number of arguments */
{
  (void) call_info_p;
  (void) args_p;
  (void) args_cnt;
  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_module_link (module, NULL, NULL);
  jerry_object_type_t namespace = jerry_module_get_namespace (module);
  jerry_release_value (module);
  return namespace;
} /* test_namespace */

int
main (void)
{
  TEST_INIT ();

  jerry_init (JERRY_INIT_EMPTY);

  const jerry_char_t proxy_object[] = "new Proxy({}, {})";
  const jerry_char_t typedarray_object[] = "new Uint8Array()";
  const jerry_char_t container_object[] = "new Map()";
  const jerry_char_t iterator_object[] = "[1, 2, 3].values()";
  const jerry_char_t arrow_function[] = "_ => 5";
  const jerry_char_t async_arrow_function[] = "async _ => 5";
  const jerry_char_t generator_function[] = "function *f() {}; f";
  const jerry_char_t async_generator_function[] = "async function *f() {}; f";
  const jerry_char_t getter_function[] = "Object.getOwnPropertyDescriptor({get a(){}}, 'a').get";
  const jerry_char_t setter_function[] = "Object.getOwnPropertyDescriptor({set a(b){}}, 'a').set";
  const jerry_char_t method_function[] = "Object.getOwnPropertyDescriptor({a(){}}, 'a').value";

  const jerry_char_t symbol_object[] = "new Object(Symbol('foo'))";

Review comment (suggestion):
`jerry_release_value (jerry_module_link (module, NULL, NULL))`

Code after:
{
  jerry_object_type_t type_info;
  jerry_value_t value;
  bool active;
} test_entry_t;

#define ENTRY(TYPE, VALUE) { TYPE, VALUE, true }
#define ENTRY_IF(TYPE, VALUE, FEATURE) { TYPE, VALUE, jerry_is_feature_enabled (FEATURE) }
#define EVALUATE(BUFF) (jerry_eval ((BUFF), sizeof ((BUFF)) - 1, JERRY_PARSE_NO_OPTS))
#define PARSE(OPTS) (jerry_parse ((const jerry_char_t *) "", 0, (OPTS)))
static jerry_value_t
test_ext_function (const jerry_call_info_t *call_info_p, /**< call information */
                   const jerry_value_t args_p[], /**< array of arguments */
                   const jerry_length_t args_cnt) /**< number of arguments */
{
  (void) call_info_p;
  (void) args_p;
  (void) args_cnt;
  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)
{
  TEST_INIT ();

  jerry_init (JERRY_INIT_EMPTY);

  const jerry_char_t proxy_object[] = "new Proxy({}, {})";