Repository: nodejs/node
File: test/js-native-api/test_general/test_general.c (C)

Code before:
#include <js_native_api.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "../common.h"
#include "../entry_point.h"

static napi_value testStrictEquals(napi_env env, napi_callback_info info) {
  size_t argc = 2;
  napi_value args[2];
  NODE_API_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));

  bool bool_result;
  napi_value result;
  NODE_API_CALL(env, napi_strict_equals(env, args[0], args[1], &bool_result));
  NODE_API_CALL(env, napi_get_boolean(env, bool_result, &result));

  return result;
}

static napi_value testSetPrototype(napi_env env, napi_callback_info info) {
  size_t argc = 2;
  napi_value args[2];
  NODE_API_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));

  NODE_API_CALL(env, napi_set_prototype(env, args[0], args[1]));

  return NULL;
}

static napi_value testGetPrototype(napi_env env, napi_callback_info info) {
  size_t argc = 1;
  napi_value args[1];
  NODE_API_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));

  napi_value result;
  NODE_API_CALL(env, napi_get_prototype(env, args[0], &result));

  return result;
}

static napi_value testGetVersion(napi_env env, napi_callback_info info) {
  uint32_t version;
  napi_value result;
  NODE_API_CALL(env, napi_get_version(env, &version));
  NODE_API_CALL(env, napi_create_uint32(env, version, &result));
  return result;
}

static napi_value doInstanceOf(napi_env env, napi_callback_info info) {
  size_t argc = 2;

Review comment (suggestion):
The `NAPI_EXPERIMENTAL` has to be defined in https://github.com/nodejs/node/blob/8716146d5b21652eb529cde4c500be1a863389f2/test/js-native-api/test_general/binding.gyp#L4 in order to build with this new API.

Code after:
#include <js_native_api.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "../common.h"
#include "../entry_point.h"

static napi_value testStrictEquals(napi_env env, napi_callback_info info) {
  size_t argc = 2;
  napi_value args[2];
  NODE_API_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));

  bool bool_result;
  napi_value result;
  NODE_API_CALL(env, napi_strict_equals(env, args[0], args[1], &bool_result));
  NODE_API_CALL(env, napi_get_boolean(env, bool_result, &result));

  return result;
}

static napi_value testSetPrototype(napi_env env, napi_callback_info info) {
  size_t argc = 2;
  napi_value args[2];
  NODE_API_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));

  NODE_API_CALL(env, node_api_set_prototype(env, args[0], args[1]));

  return NULL;
}

static napi_value testGetPrototype(napi_env env, napi_callback_info info) {
  size_t argc = 1;
  napi_value args[1];
  NODE_API_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));

  napi_value result;
  NODE_API_CALL(env, napi_get_prototype(env, args[0], &result));

  return result;
}

static napi_value testGetVersion(napi_env env, napi_callback_info info) {
  uint32_t version;
  napi_value result;
  NODE_API_CALL(env, napi_get_version(env, &version));
  NODE_API_CALL(env, napi_create_uint32(env, version, &result));
  return result;
}

static napi_value doInstanceOf(napi_env env, napi_callback_info info) {
  size_t argc = 2;