koffi 1.1.0-beta.1 → 1.1.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (270) hide show
  1. package/CMakeLists.txt +4 -0
  2. package/README.md +20 -11
  3. package/build/qemu/1.1.0-beta.4/koffi_darwin_x64.tar.gz +0 -0
  4. package/build/qemu/1.1.0-beta.4/koffi_freebsd_arm64.tar.gz +0 -0
  5. package/build/qemu/1.1.0-beta.4/koffi_freebsd_ia32.tar.gz +0 -0
  6. package/build/qemu/1.1.0-beta.4/koffi_freebsd_x64.tar.gz +0 -0
  7. package/build/qemu/1.1.0-beta.4/koffi_linux_arm.tar.gz +0 -0
  8. package/build/qemu/1.1.0-beta.4/koffi_linux_arm64.tar.gz +0 -0
  9. package/build/qemu/1.1.0-beta.4/koffi_linux_ia32.tar.gz +0 -0
  10. package/build/qemu/1.1.0-beta.4/koffi_linux_x64.tar.gz +0 -0
  11. package/build/qemu/1.1.0-beta.4/koffi_win32_ia32.tar.gz +0 -0
  12. package/build/qemu/1.1.0-beta.4/koffi_win32_x64.tar.gz +0 -0
  13. package/package.json +1 -1
  14. package/qemu/qemu.js +1 -0
  15. package/src/abi_arm32.cc +27 -45
  16. package/src/abi_arm64.cc +58 -132
  17. package/src/abi_x64_sysv.cc +24 -7
  18. package/src/abi_x64_win.cc +3 -0
  19. package/src/abi_x86.cc +3 -0
  20. package/src/call.cc +540 -33
  21. package/src/call.hh +5 -3
  22. package/src/ffi.cc +129 -4
  23. package/src/ffi.hh +5 -1
  24. package/src/parser.cc +7 -2
  25. package/src/util.cc +72 -0
  26. package/src/util.hh +2 -0
  27. package/test/misc.c +14 -8
  28. package/vendor/node-addon-api/CODE_OF_CONDUCT.md +4 -0
  29. package/vendor/node-addon-api/CONTRIBUTING.md +93 -0
  30. package/vendor/node-addon-api/appveyor.yml +37 -0
  31. package/vendor/node-addon-api/benchmark/README.md +47 -0
  32. package/vendor/node-addon-api/benchmark/binding.gyp +25 -0
  33. package/vendor/node-addon-api/benchmark/function_args.cc +217 -0
  34. package/vendor/node-addon-api/benchmark/function_args.js +60 -0
  35. package/vendor/node-addon-api/benchmark/index.js +34 -0
  36. package/vendor/node-addon-api/benchmark/property_descriptor.cc +91 -0
  37. package/vendor/node-addon-api/benchmark/property_descriptor.js +37 -0
  38. package/vendor/node-addon-api/doc/addon.md +163 -0
  39. package/vendor/node-addon-api/doc/array.md +81 -0
  40. package/vendor/node-addon-api/doc/array_buffer.md +155 -0
  41. package/vendor/node-addon-api/doc/async_context.md +86 -0
  42. package/vendor/node-addon-api/doc/async_operations.md +31 -0
  43. package/vendor/node-addon-api/doc/async_worker.md +427 -0
  44. package/vendor/node-addon-api/doc/async_worker_variants.md +557 -0
  45. package/vendor/node-addon-api/doc/bigint.md +97 -0
  46. package/vendor/node-addon-api/doc/boolean.md +68 -0
  47. package/vendor/node-addon-api/doc/buffer.md +150 -0
  48. package/vendor/node-addon-api/doc/callback_scope.md +54 -0
  49. package/vendor/node-addon-api/doc/callbackinfo.md +97 -0
  50. package/vendor/node-addon-api/doc/checker-tool.md +32 -0
  51. package/vendor/node-addon-api/doc/class_property_descriptor.md +123 -0
  52. package/vendor/node-addon-api/doc/cmake-js.md +68 -0
  53. package/vendor/node-addon-api/doc/conversion-tool.md +28 -0
  54. package/vendor/node-addon-api/doc/creating_a_release.md +62 -0
  55. package/vendor/node-addon-api/doc/dataview.md +248 -0
  56. package/vendor/node-addon-api/doc/date.md +68 -0
  57. package/vendor/node-addon-api/doc/env.md +196 -0
  58. package/vendor/node-addon-api/doc/error.md +120 -0
  59. package/vendor/node-addon-api/doc/error_handling.md +254 -0
  60. package/vendor/node-addon-api/doc/escapable_handle_scope.md +80 -0
  61. package/vendor/node-addon-api/doc/external.md +63 -0
  62. package/vendor/node-addon-api/doc/function.md +402 -0
  63. package/vendor/node-addon-api/doc/function_reference.md +238 -0
  64. package/vendor/node-addon-api/doc/generator.md +13 -0
  65. package/vendor/node-addon-api/doc/handle_scope.md +63 -0
  66. package/vendor/node-addon-api/doc/hierarchy.md +91 -0
  67. package/vendor/node-addon-api/doc/instance_wrap.md +408 -0
  68. package/vendor/node-addon-api/doc/maybe.md +76 -0
  69. package/vendor/node-addon-api/doc/memory_management.md +27 -0
  70. package/vendor/node-addon-api/doc/name.md +29 -0
  71. package/vendor/node-addon-api/doc/node-gyp.md +82 -0
  72. package/vendor/node-addon-api/doc/number.md +163 -0
  73. package/vendor/node-addon-api/doc/object.md +411 -0
  74. package/vendor/node-addon-api/doc/object_lifetime_management.md +83 -0
  75. package/vendor/node-addon-api/doc/object_reference.md +117 -0
  76. package/vendor/node-addon-api/doc/object_wrap.md +588 -0
  77. package/vendor/node-addon-api/doc/prebuild_tools.md +16 -0
  78. package/vendor/node-addon-api/doc/promises.md +79 -0
  79. package/vendor/node-addon-api/doc/property_descriptor.md +286 -0
  80. package/vendor/node-addon-api/doc/propertylvalue.md +50 -0
  81. package/vendor/node-addon-api/doc/range_error.md +59 -0
  82. package/vendor/node-addon-api/doc/reference.md +113 -0
  83. package/vendor/node-addon-api/doc/setup.md +110 -0
  84. package/vendor/node-addon-api/doc/string.md +93 -0
  85. package/vendor/node-addon-api/doc/symbol.md +61 -0
  86. package/vendor/node-addon-api/doc/threadsafe.md +121 -0
  87. package/vendor/node-addon-api/doc/threadsafe_function.md +290 -0
  88. package/vendor/node-addon-api/doc/type_error.md +59 -0
  89. package/vendor/node-addon-api/doc/typed_array.md +78 -0
  90. package/vendor/node-addon-api/doc/typed_array_of.md +137 -0
  91. package/vendor/node-addon-api/doc/typed_threadsafe_function.md +306 -0
  92. package/vendor/node-addon-api/doc/value.md +340 -0
  93. package/vendor/node-addon-api/doc/version_management.md +43 -0
  94. package/vendor/node-addon-api/package.json +415 -0
  95. package/vendor/node-addon-api/test/README.md +91 -0
  96. package/vendor/node-addon-api/test/addon.cc +36 -0
  97. package/vendor/node-addon-api/test/addon.js +11 -0
  98. package/vendor/node-addon-api/test/addon_build/index.js +49 -0
  99. package/vendor/node-addon-api/test/addon_build/tpl/addon.cc +17 -0
  100. package/vendor/node-addon-api/test/addon_build/tpl/binding.gyp +62 -0
  101. package/vendor/node-addon-api/test/addon_build/tpl/index.js +9 -0
  102. package/vendor/node-addon-api/test/addon_build/tpl/package.json +11 -0
  103. package/vendor/node-addon-api/test/addon_data.cc +99 -0
  104. package/vendor/node-addon-api/test/addon_data.js +46 -0
  105. package/vendor/node-addon-api/test/array_buffer.cc +243 -0
  106. package/vendor/node-addon-api/test/array_buffer.js +69 -0
  107. package/vendor/node-addon-api/test/async_context.cc +36 -0
  108. package/vendor/node-addon-api/test/async_context.js +122 -0
  109. package/vendor/node-addon-api/test/async_progress_queue_worker.cc +83 -0
  110. package/vendor/node-addon-api/test/async_progress_queue_worker.js +46 -0
  111. package/vendor/node-addon-api/test/async_progress_worker.cc +134 -0
  112. package/vendor/node-addon-api/test/async_progress_worker.js +61 -0
  113. package/vendor/node-addon-api/test/async_worker.cc +106 -0
  114. package/vendor/node-addon-api/test/async_worker.js +179 -0
  115. package/vendor/node-addon-api/test/async_worker_nocallback.js +13 -0
  116. package/vendor/node-addon-api/test/async_worker_persistent.cc +63 -0
  117. package/vendor/node-addon-api/test/async_worker_persistent.js +24 -0
  118. package/vendor/node-addon-api/test/basic_types/array.cc +40 -0
  119. package/vendor/node-addon-api/test/basic_types/array.js +35 -0
  120. package/vendor/node-addon-api/test/basic_types/boolean.cc +38 -0
  121. package/vendor/node-addon-api/test/basic_types/boolean.js +35 -0
  122. package/vendor/node-addon-api/test/basic_types/number.cc +99 -0
  123. package/vendor/node-addon-api/test/basic_types/number.js +114 -0
  124. package/vendor/node-addon-api/test/basic_types/value.cc +120 -0
  125. package/vendor/node-addon-api/test/basic_types/value.js +133 -0
  126. package/vendor/node-addon-api/test/bigint.cc +91 -0
  127. package/vendor/node-addon-api/test/bigint.js +53 -0
  128. package/vendor/node-addon-api/test/binding-swallowexcept.cc +12 -0
  129. package/vendor/node-addon-api/test/binding.cc +173 -0
  130. package/vendor/node-addon-api/test/binding.gyp +124 -0
  131. package/vendor/node-addon-api/test/buffer.cc +183 -0
  132. package/vendor/node-addon-api/test/buffer.js +69 -0
  133. package/vendor/node-addon-api/test/callbackscope.cc +22 -0
  134. package/vendor/node-addon-api/test/callbackscope.js +49 -0
  135. package/vendor/node-addon-api/test/common/index.js +114 -0
  136. package/vendor/node-addon-api/test/common/test_helper.h +71 -0
  137. package/vendor/node-addon-api/test/dataview/dataview.cc +48 -0
  138. package/vendor/node-addon-api/test/dataview/dataview.js +35 -0
  139. package/vendor/node-addon-api/test/dataview/dataview_read_write.cc +115 -0
  140. package/vendor/node-addon-api/test/dataview/dataview_read_write.js +90 -0
  141. package/vendor/node-addon-api/test/date.cc +44 -0
  142. package/vendor/node-addon-api/test/date.js +18 -0
  143. package/vendor/node-addon-api/test/env_cleanup.cc +88 -0
  144. package/vendor/node-addon-api/test/env_cleanup.js +56 -0
  145. package/vendor/node-addon-api/test/error.cc +287 -0
  146. package/vendor/node-addon-api/test/error.js +81 -0
  147. package/vendor/node-addon-api/test/error_handling_for_primitives.cc +13 -0
  148. package/vendor/node-addon-api/test/error_handling_for_primitives.js +29 -0
  149. package/vendor/node-addon-api/test/error_terminating_environment.js +95 -0
  150. package/vendor/node-addon-api/test/external.cc +81 -0
  151. package/vendor/node-addon-api/test/external.js +88 -0
  152. package/vendor/node-addon-api/test/function.cc +324 -0
  153. package/vendor/node-addon-api/test/function.js +133 -0
  154. package/vendor/node-addon-api/test/function_reference.cc +202 -0
  155. package/vendor/node-addon-api/test/function_reference.js +157 -0
  156. package/vendor/node-addon-api/test/globalObject/global_object.cc +61 -0
  157. package/vendor/node-addon-api/test/globalObject/global_object_delete_property.cc +31 -0
  158. package/vendor/node-addon-api/test/globalObject/global_object_delete_property.js +61 -0
  159. package/vendor/node-addon-api/test/globalObject/global_object_get_property.cc +40 -0
  160. package/vendor/node-addon-api/test/globalObject/global_object_get_property.js +57 -0
  161. package/vendor/node-addon-api/test/globalObject/global_object_has_own_property.cc +28 -0
  162. package/vendor/node-addon-api/test/globalObject/global_object_has_own_property.js +48 -0
  163. package/vendor/node-addon-api/test/globalObject/global_object_set_property.cc +31 -0
  164. package/vendor/node-addon-api/test/globalObject/global_object_set_property.js +58 -0
  165. package/vendor/node-addon-api/test/handlescope.cc +60 -0
  166. package/vendor/node-addon-api/test/handlescope.js +14 -0
  167. package/vendor/node-addon-api/test/index.js +159 -0
  168. package/vendor/node-addon-api/test/maybe/check.cc +23 -0
  169. package/vendor/node-addon-api/test/maybe/index.js +38 -0
  170. package/vendor/node-addon-api/test/memory_management.cc +17 -0
  171. package/vendor/node-addon-api/test/memory_management.js +9 -0
  172. package/vendor/node-addon-api/test/movable_callbacks.cc +23 -0
  173. package/vendor/node-addon-api/test/movable_callbacks.js +21 -0
  174. package/vendor/node-addon-api/test/name.cc +108 -0
  175. package/vendor/node-addon-api/test/name.js +59 -0
  176. package/vendor/node-addon-api/test/napi_child.js +14 -0
  177. package/vendor/node-addon-api/test/object/delete_property.cc +38 -0
  178. package/vendor/node-addon-api/test/object/delete_property.js +41 -0
  179. package/vendor/node-addon-api/test/object/finalizer.cc +29 -0
  180. package/vendor/node-addon-api/test/object/finalizer.js +28 -0
  181. package/vendor/node-addon-api/test/object/get_property.cc +34 -0
  182. package/vendor/node-addon-api/test/object/get_property.js +40 -0
  183. package/vendor/node-addon-api/test/object/has_own_property.cc +34 -0
  184. package/vendor/node-addon-api/test/object/has_own_property.js +34 -0
  185. package/vendor/node-addon-api/test/object/has_property.cc +38 -0
  186. package/vendor/node-addon-api/test/object/has_property.js +37 -0
  187. package/vendor/node-addon-api/test/object/object.cc +350 -0
  188. package/vendor/node-addon-api/test/object/object.js +217 -0
  189. package/vendor/node-addon-api/test/object/object_deprecated.cc +66 -0
  190. package/vendor/node-addon-api/test/object/object_deprecated.js +47 -0
  191. package/vendor/node-addon-api/test/object/object_freeze_seal.cc +25 -0
  192. package/vendor/node-addon-api/test/object/object_freeze_seal.js +61 -0
  193. package/vendor/node-addon-api/test/object/set_property.cc +45 -0
  194. package/vendor/node-addon-api/test/object/set_property.js +30 -0
  195. package/vendor/node-addon-api/test/object/subscript_operator.cc +58 -0
  196. package/vendor/node-addon-api/test/object/subscript_operator.js +17 -0
  197. package/vendor/node-addon-api/test/object_reference.cc +219 -0
  198. package/vendor/node-addon-api/test/object_reference.js +259 -0
  199. package/vendor/node-addon-api/test/objectwrap.cc +268 -0
  200. package/vendor/node-addon-api/test/objectwrap.js +284 -0
  201. package/vendor/node-addon-api/test/objectwrap_constructor_exception.cc +26 -0
  202. package/vendor/node-addon-api/test/objectwrap_constructor_exception.js +18 -0
  203. package/vendor/node-addon-api/test/objectwrap_function.cc +45 -0
  204. package/vendor/node-addon-api/test/objectwrap_function.js +22 -0
  205. package/vendor/node-addon-api/test/objectwrap_multiple_inheritance.cc +30 -0
  206. package/vendor/node-addon-api/test/objectwrap_multiple_inheritance.js +13 -0
  207. package/vendor/node-addon-api/test/objectwrap_removewrap.cc +45 -0
  208. package/vendor/node-addon-api/test/objectwrap_removewrap.js +40 -0
  209. package/vendor/node-addon-api/test/objectwrap_worker_thread.js +19 -0
  210. package/vendor/node-addon-api/test/promise.cc +29 -0
  211. package/vendor/node-addon-api/test/promise.js +18 -0
  212. package/vendor/node-addon-api/test/reference.cc +24 -0
  213. package/vendor/node-addon-api/test/reference.js +14 -0
  214. package/vendor/node-addon-api/test/run_script.cc +56 -0
  215. package/vendor/node-addon-api/test/run_script.js +45 -0
  216. package/vendor/node-addon-api/test/symbol.cc +79 -0
  217. package/vendor/node-addon-api/test/symbol.js +73 -0
  218. package/vendor/node-addon-api/test/testUtil.js +54 -0
  219. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function.cc +195 -0
  220. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function.js +188 -0
  221. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_ctx.cc +63 -0
  222. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_ctx.js +12 -0
  223. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_existing_tsfn.cc +115 -0
  224. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_existing_tsfn.js +14 -0
  225. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_ptr.cc +26 -0
  226. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_ptr.js +7 -0
  227. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_sum.cc +225 -0
  228. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_sum.js +59 -0
  229. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_unref.cc +42 -0
  230. package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_unref.js +53 -0
  231. package/vendor/node-addon-api/test/thunking_manual.cc +140 -0
  232. package/vendor/node-addon-api/test/thunking_manual.js +17 -0
  233. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function.cc +215 -0
  234. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function.js +188 -0
  235. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_ctx.cc +68 -0
  236. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_ctx.js +12 -0
  237. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_existing_tsfn.cc +127 -0
  238. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_existing_tsfn.js +14 -0
  239. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_ptr.cc +28 -0
  240. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_ptr.js +7 -0
  241. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_sum.cc +237 -0
  242. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_sum.js +59 -0
  243. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_unref.cc +53 -0
  244. package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_unref.js +53 -0
  245. package/vendor/node-addon-api/test/typedarray-bigint.js +58 -0
  246. package/vendor/node-addon-api/test/typedarray.cc +216 -0
  247. package/vendor/node-addon-api/test/typedarray.js +69 -0
  248. package/vendor/node-addon-api/test/version_management.cc +27 -0
  249. package/vendor/node-addon-api/test/version_management.js +31 -0
  250. package/vendor/node-addon-api/unit-test/README.md +28 -0
  251. package/vendor/node-addon-api/unit-test/binding-file-template.js +39 -0
  252. package/vendor/node-addon-api/unit-test/binding.gyp +72 -0
  253. package/vendor/node-addon-api/unit-test/exceptions.js +32 -0
  254. package/vendor/node-addon-api/unit-test/generate-binding-cc.js +61 -0
  255. package/vendor/node-addon-api/unit-test/injectTestParams.js +101 -0
  256. package/vendor/node-addon-api/unit-test/listOfTestModules.js +88 -0
  257. package/vendor/node-addon-api/unit-test/matchModules.js +65 -0
  258. package/vendor/node-addon-api/unit-test/setup.js +13 -0
  259. package/vendor/node-addon-api/unit-test/spawnTask.js +26 -0
  260. package/vendor/node-addon-api/unit-test/test.js +30 -0
  261. package/build/qemu/1.1.0-beta.1/koffi_darwin_x64.tar.gz +0 -0
  262. package/build/qemu/1.1.0-beta.1/koffi_freebsd_arm64.tar.gz +0 -0
  263. package/build/qemu/1.1.0-beta.1/koffi_freebsd_ia32.tar.gz +0 -0
  264. package/build/qemu/1.1.0-beta.1/koffi_freebsd_x64.tar.gz +0 -0
  265. package/build/qemu/1.1.0-beta.1/koffi_linux_arm.tar.gz +0 -0
  266. package/build/qemu/1.1.0-beta.1/koffi_linux_arm64.tar.gz +0 -0
  267. package/build/qemu/1.1.0-beta.1/koffi_linux_ia32.tar.gz +0 -0
  268. package/build/qemu/1.1.0-beta.1/koffi_linux_x64.tar.gz +0 -0
  269. package/build/qemu/1.1.0-beta.1/koffi_win32_ia32.tar.gz +0 -0
  270. package/build/qemu/1.1.0-beta.1/koffi_win32_x64.tar.gz +0 -0
@@ -0,0 +1,81 @@
1
+ #include "napi.h"
2
+
3
+ using namespace Napi;
4
+
5
+ namespace {
6
+
7
+ int testData = 1;
8
+ int finalizeCount = 0;
9
+
10
+ Value CreateExternal(const CallbackInfo& info) {
11
+ finalizeCount = 0;
12
+ return External<int>::New(info.Env(), &testData);
13
+ }
14
+
15
+ Value CreateExternalWithFinalize(const CallbackInfo& info) {
16
+ finalizeCount = 0;
17
+ return External<int>::New(info.Env(), new int(1),
18
+ [](Env /*env*/, int* data) {
19
+ delete data;
20
+ finalizeCount++;
21
+ });
22
+ }
23
+
24
+ Value CreateExternalWithFinalizeHint(const CallbackInfo& info) {
25
+ finalizeCount = 0;
26
+ char* hint = nullptr;
27
+ return External<int>::New(info.Env(), new int(1),
28
+ [](Env /*env*/, int* data, char* /*hint*/) {
29
+ delete data;
30
+ finalizeCount++;
31
+ },
32
+ hint);
33
+ }
34
+
35
+ void CheckExternal(const CallbackInfo& info) {
36
+ Value arg = info[0];
37
+ if (arg.Type() != napi_external) {
38
+ Error::New(info.Env(), "An external argument was expected.").ThrowAsJavaScriptException();
39
+ return;
40
+ }
41
+
42
+ External<int> external = arg.As<External<int>>();
43
+ int* externalData = external.Data();
44
+ if (externalData == nullptr || *externalData != 1) {
45
+ Error::New(info.Env(), "An external value of 1 was expected.").ThrowAsJavaScriptException();
46
+ return;
47
+ }
48
+ }
49
+
50
+ Value GetFinalizeCount(const CallbackInfo& info) {
51
+ return Number::New(info.Env(), finalizeCount);
52
+ }
53
+
54
+ Value CreateExternalWithFinalizeException(const CallbackInfo& info) {
55
+ return External<int>::New(info.Env(), new int(1),
56
+ [](Env env, int* data) {
57
+ Error error = Error::New(env, "Finalizer exception");
58
+ delete data;
59
+ #ifdef NAPI_CPP_EXCEPTIONS
60
+ throw error;
61
+ #else
62
+ error.ThrowAsJavaScriptException();
63
+ #endif
64
+ });
65
+ }
66
+
67
+ } // end anonymous namespace
68
+
69
+ Object InitExternal(Env env) {
70
+ Object exports = Object::New(env);
71
+
72
+ exports["createExternal"] = Function::New(env, CreateExternal);
73
+ exports["createExternalWithFinalize"] = Function::New(env, CreateExternalWithFinalize);
74
+ exports["createExternalWithFinalizeException"] =
75
+ Function::New(env, CreateExternalWithFinalizeException);
76
+ exports["createExternalWithFinalizeHint"] = Function::New(env, CreateExternalWithFinalizeHint);
77
+ exports["checkExternal"] = Function::New(env, CheckExternal);
78
+ exports["getFinalizeCount"] = Function::New(env, GetFinalizeCount);
79
+
80
+ return exports;
81
+ }
@@ -0,0 +1,88 @@
1
+ 'use strict';
2
+
3
+ const assert = require('assert');
4
+ const { spawnSync } = require('child_process');
5
+ const testUtil = require('./testUtil');
6
+
7
+ if (process.argv.length === 3) {
8
+ let interval;
9
+
10
+ // Running as the child process, hook up an `uncaughtException` handler to
11
+ // examine the error thrown by the finalizer.
12
+ process.on('uncaughtException', (error) => {
13
+ // TODO (gabrielschulhof): Use assert.matches() when we drop support for
14
+ // Node.js v10.x.
15
+ assert(!!error.message.match(/Finalizer exception/));
16
+ if (interval) {
17
+ clearInterval(interval);
18
+ }
19
+ process.exit(0);
20
+ });
21
+
22
+ // Create an external whose finalizer throws.
23
+ (() =>
24
+ require(process.argv[2]).external.createExternalWithFinalizeException())();
25
+
26
+ // gc until the external's finalizer throws or until we give up. Since the
27
+ // exception is thrown from a native `SetImmediate()` we cannot catch it
28
+ // anywhere except in the process' `uncaughtException` handler.
29
+ let maxGCTries = 10;
30
+ (function gcInterval() {
31
+ global.gc();
32
+ if (!interval) {
33
+ interval = setInterval(gcInterval, 100);
34
+ } else if (--maxGCTries === 0) {
35
+ throw new Error('Timed out waiting for the gc to throw');
36
+ process.exit(1);
37
+ }
38
+ })();
39
+
40
+ return;
41
+ }
42
+
43
+ module.exports = require('./common').runTestWithBindingPath(test);
44
+
45
+ function test(bindingPath) {
46
+ const binding = require(bindingPath);
47
+
48
+ const child = spawnSync(process.execPath, [
49
+ '--expose-gc', __filename, bindingPath
50
+ ], { stdio: 'inherit' });
51
+ assert.strictEqual(child.status, 0);
52
+ assert.strictEqual(child.signal, null);
53
+
54
+ return testUtil.runGCTests([
55
+ 'External without finalizer',
56
+ () => {
57
+ const test = binding.external.createExternal();
58
+ assert.strictEqual(typeof test, 'object');
59
+ binding.external.checkExternal(test);
60
+ assert.strictEqual(0, binding.external.getFinalizeCount());
61
+ },
62
+ () => {
63
+ assert.strictEqual(0, binding.external.getFinalizeCount());
64
+ },
65
+
66
+ 'External with finalizer',
67
+ () => {
68
+ const test = binding.external.createExternalWithFinalize();
69
+ assert.strictEqual(typeof test, 'object');
70
+ binding.external.checkExternal(test);
71
+ assert.strictEqual(0, binding.external.getFinalizeCount());
72
+ },
73
+ () => {
74
+ assert.strictEqual(1, binding.external.getFinalizeCount());
75
+ },
76
+
77
+ 'External with finalizer hint',
78
+ () => {
79
+ const test = binding.external.createExternalWithFinalizeHint();
80
+ assert.strictEqual(typeof test, 'object');
81
+ binding.external.checkExternal(test);
82
+ assert.strictEqual(0, binding.external.getFinalizeCount());
83
+ },
84
+ () => {
85
+ assert.strictEqual(1, binding.external.getFinalizeCount());
86
+ },
87
+ ]);
88
+ }
@@ -0,0 +1,324 @@
1
+ #include <memory>
2
+ #include "napi.h"
3
+ #include "test_helper.h"
4
+
5
+ using namespace Napi;
6
+
7
+ namespace {
8
+
9
+ int testData = 1;
10
+
11
+ Boolean EmptyConstructor(const CallbackInfo& info) {
12
+ auto env = info.Env();
13
+ bool isEmpty = info[0].As<Boolean>();
14
+ Function function = isEmpty ? Function() : Function(env, Object::New(env));
15
+ return Boolean::New(env, function.IsEmpty());
16
+ }
17
+
18
+ void VoidCallback(const CallbackInfo& info) {
19
+ auto env = info.Env();
20
+ Object obj = info[0].As<Object>();
21
+
22
+ obj["foo"] = String::New(env, "bar");
23
+ }
24
+
25
+ Value ValueCallback(const CallbackInfo& info) {
26
+ auto env = info.Env();
27
+ Object obj = Object::New(env);
28
+
29
+ obj["foo"] = String::New(env, "bar");
30
+
31
+ return obj;
32
+ }
33
+
34
+ void VoidCallbackWithData(const CallbackInfo& info) {
35
+ auto env = info.Env();
36
+ Object obj = info[0].As<Object>();
37
+
38
+ obj["foo"] = String::New(env, "bar");
39
+
40
+ int* data = static_cast<int*>(info.Data());
41
+ obj["data"] = Number::New(env, *data);
42
+ }
43
+
44
+ Value ValueCallbackWithData(const CallbackInfo& info) {
45
+ auto env = info.Env();
46
+ Object obj = Object::New(env);
47
+
48
+ obj["foo"] = String::New(env, "bar");
49
+
50
+ int* data = static_cast<int*>(info.Data());
51
+ obj["data"] = Number::New(env, *data);
52
+
53
+ return obj;
54
+ }
55
+
56
+ Value CallWithArgs(const CallbackInfo& info) {
57
+ Function func = info[0].As<Function>();
58
+ return MaybeUnwrap(
59
+ func.Call(std::initializer_list<napi_value>{info[1], info[2], info[3]}));
60
+ }
61
+
62
+ Value CallWithVector(const CallbackInfo& info) {
63
+ Function func = info[0].As<Function>();
64
+ std::vector<napi_value> args;
65
+ args.reserve(3);
66
+ args.push_back(info[1]);
67
+ args.push_back(info[2]);
68
+ args.push_back(info[3]);
69
+ return MaybeUnwrap(func.Call(args));
70
+ }
71
+
72
+ Value CallWithVectorUsingCppWrapper(const CallbackInfo& info) {
73
+ Function func = info[0].As<Function>();
74
+ std::vector<Value> args;
75
+ args.reserve(3);
76
+ args.push_back(info[1]);
77
+ args.push_back(info[2]);
78
+ args.push_back(info[3]);
79
+ return MaybeUnwrap(func.Call(args));
80
+ }
81
+
82
+ Value CallWithCStyleArray(const CallbackInfo& info) {
83
+ Function func = info[0].As<Function>();
84
+ std::vector<napi_value> args;
85
+ args.reserve(3);
86
+ args.push_back(info[1]);
87
+ args.push_back(info[2]);
88
+ args.push_back(info[3]);
89
+ return MaybeUnwrap(func.Call(args.size(), args.data()));
90
+ }
91
+
92
+ Value CallWithReceiverAndCStyleArray(const CallbackInfo& info) {
93
+ Function func = info[0].As<Function>();
94
+ Value receiver = info[1];
95
+ std::vector<napi_value> args;
96
+ args.reserve(3);
97
+ args.push_back(info[2]);
98
+ args.push_back(info[3]);
99
+ args.push_back(info[4]);
100
+ return MaybeUnwrap(func.Call(receiver, args.size(), args.data()));
101
+ }
102
+
103
+ Value CallWithReceiverAndArgs(const CallbackInfo& info) {
104
+ Function func = info[0].As<Function>();
105
+ Value receiver = info[1];
106
+ return MaybeUnwrap(func.Call(
107
+ receiver, std::initializer_list<napi_value>{info[2], info[3], info[4]}));
108
+ }
109
+
110
+ Value CallWithReceiverAndVector(const CallbackInfo& info) {
111
+ Function func = info[0].As<Function>();
112
+ Value receiver = info[1];
113
+ std::vector<napi_value> args;
114
+ args.reserve(3);
115
+ args.push_back(info[2]);
116
+ args.push_back(info[3]);
117
+ args.push_back(info[4]);
118
+ return MaybeUnwrap(func.Call(receiver, args));
119
+ }
120
+
121
+ Value CallWithReceiverAndVectorUsingCppWrapper(const CallbackInfo& info) {
122
+ Function func = info[0].As<Function>();
123
+ Value receiver = info[1];
124
+ std::vector<Value> args;
125
+ args.reserve(3);
126
+ args.push_back(info[2]);
127
+ args.push_back(info[3]);
128
+ args.push_back(info[4]);
129
+ return MaybeUnwrap(func.Call(receiver, args));
130
+ }
131
+
132
+ Value CallWithInvalidReceiver(const CallbackInfo& info) {
133
+ Function func = info[0].As<Function>();
134
+ return MaybeUnwrapOr(func.Call(Value(), std::initializer_list<napi_value>{}),
135
+ Value());
136
+ }
137
+
138
+ Value CallConstructorWithArgs(const CallbackInfo& info) {
139
+ Function func = info[0].As<Function>();
140
+ return MaybeUnwrap(
141
+ func.New(std::initializer_list<napi_value>{info[1], info[2], info[3]}));
142
+ }
143
+
144
+ Value CallConstructorWithVector(const CallbackInfo& info) {
145
+ Function func = info[0].As<Function>();
146
+ std::vector<napi_value> args;
147
+ args.reserve(3);
148
+ args.push_back(info[1]);
149
+ args.push_back(info[2]);
150
+ args.push_back(info[3]);
151
+ return MaybeUnwrap(func.New(args));
152
+ }
153
+
154
+ Value CallConstructorWithCStyleArray(const CallbackInfo& info) {
155
+ Function func = info[0].As<Function>();
156
+ std::vector<napi_value> args;
157
+ args.reserve(3);
158
+ args.push_back(info[1]);
159
+ args.push_back(info[2]);
160
+ args.push_back(info[3]);
161
+ return MaybeUnwrap(func.New(args.size(), args.data()));
162
+ }
163
+
164
+ void IsConstructCall(const CallbackInfo& info) {
165
+ Function callback = info[0].As<Function>();
166
+ bool isConstructCall = info.IsConstructCall();
167
+ callback({Napi::Boolean::New(info.Env(), isConstructCall)});
168
+ }
169
+
170
+ void MakeCallbackWithArgs(const CallbackInfo& info) {
171
+ Env env = info.Env();
172
+ Function callback = info[0].As<Function>();
173
+ Object resource = info[1].As<Object>();
174
+
175
+ AsyncContext context(env, "function_test_context", resource);
176
+
177
+ callback.MakeCallback(
178
+ resource,
179
+ std::initializer_list<napi_value>{info[2], info[3], info[4]},
180
+ context);
181
+ }
182
+
183
+ void MakeCallbackWithVector(const CallbackInfo& info) {
184
+ Env env = info.Env();
185
+ Function callback = info[0].As<Function>();
186
+ Object resource = info[1].As<Object>();
187
+
188
+ AsyncContext context(env, "function_test_context", resource);
189
+
190
+ std::vector<napi_value> args;
191
+ args.reserve(3);
192
+ args.push_back(info[2]);
193
+ args.push_back(info[3]);
194
+ args.push_back(info[4]);
195
+ callback.MakeCallback(resource, args, context);
196
+ }
197
+
198
+ void MakeCallbackWithCStyleArray(const CallbackInfo& info) {
199
+ Env env = info.Env();
200
+ Function callback = info[0].As<Function>();
201
+ Object resource = info[1].As<Object>();
202
+
203
+ AsyncContext context(env, "function_test_context", resource);
204
+
205
+ std::vector<napi_value> args;
206
+ args.reserve(3);
207
+ args.push_back(info[2]);
208
+ args.push_back(info[3]);
209
+ args.push_back(info[4]);
210
+ callback.MakeCallback(resource, args.size(), args.data(), context);
211
+ }
212
+
213
+ void MakeCallbackWithInvalidReceiver(const CallbackInfo& info) {
214
+ Function callback = info[0].As<Function>();
215
+ callback.MakeCallback(Value(), std::initializer_list<napi_value>{});
216
+ }
217
+
218
+ Value CallWithFunctionOperator(const CallbackInfo& info) {
219
+ Function func = info[0].As<Function>();
220
+ return MaybeUnwrap(func({info[1], info[2], info[3]}));
221
+ }
222
+
223
+ } // end anonymous namespace
224
+
225
+ Object InitFunction(Env env) {
226
+ Object result = Object::New(env);
227
+ Object exports = Object::New(env);
228
+ exports["emptyConstructor"] = Function::New(env, EmptyConstructor);
229
+ exports["voidCallback"] = Function::New(env, VoidCallback, "voidCallback");
230
+ exports["valueCallback"] = Function::New(env, ValueCallback, std::string("valueCallback"));
231
+ exports["voidCallbackWithData"] =
232
+ Function::New(env, VoidCallbackWithData, nullptr, &testData);
233
+ exports["valueCallbackWithData"] =
234
+ Function::New(env, ValueCallbackWithData, nullptr, &testData);
235
+ exports["callWithArgs"] = Function::New(env, CallWithArgs);
236
+ exports["callWithVector"] = Function::New(env, CallWithVector);
237
+ exports["callWithVectorUsingCppWrapper"] =
238
+ Function::New(env, CallWithVectorUsingCppWrapper);
239
+ exports["callWithCStyleArray"] = Function::New(env, CallWithCStyleArray);
240
+ exports["callWithReceiverAndCStyleArray"] =
241
+ Function::New(env, CallWithReceiverAndCStyleArray);
242
+ exports["callWithReceiverAndArgs"] = Function::New(env, CallWithReceiverAndArgs);
243
+ exports["callWithReceiverAndVector"] = Function::New(env, CallWithReceiverAndVector);
244
+ exports["callWithReceiverAndVectorUsingCppWrapper"] =
245
+ Function::New(env, CallWithReceiverAndVectorUsingCppWrapper);
246
+ exports["callWithInvalidReceiver"] = Function::New(env, CallWithInvalidReceiver);
247
+ exports["callConstructorWithArgs"] = Function::New(env, CallConstructorWithArgs);
248
+ exports["callConstructorWithVector"] = Function::New(env, CallConstructorWithVector);
249
+ exports["callConstructorWithCStyleArray"] =
250
+ Function::New(env, CallConstructorWithCStyleArray);
251
+ exports["isConstructCall"] = Function::New(env, IsConstructCall);
252
+ exports["makeCallbackWithArgs"] = Function::New(env, MakeCallbackWithArgs);
253
+ exports["makeCallbackWithVector"] =
254
+ Function::New(env, MakeCallbackWithVector);
255
+ exports["makeCallbackWithCStyleArray"] =
256
+ Function::New(env, MakeCallbackWithCStyleArray);
257
+ exports["makeCallbackWithInvalidReceiver"] =
258
+ Function::New(env, MakeCallbackWithInvalidReceiver);
259
+ exports["callWithFunctionOperator"] =
260
+ Function::New(env, CallWithFunctionOperator);
261
+ result["plain"] = exports;
262
+
263
+ exports = Object::New(env);
264
+ exports["emptyConstructor"] = Function::New(env, EmptyConstructor);
265
+ exports["voidCallback"] = Function::New<VoidCallback>(env, "voidCallback");
266
+ exports["valueCallback"] =
267
+ Function::New<ValueCallback>(env, std::string("valueCallback"));
268
+ exports["voidCallbackWithData"] =
269
+ Function::New<VoidCallbackWithData>(env, nullptr, &testData);
270
+ exports["valueCallbackWithData"] =
271
+ Function::New<ValueCallbackWithData>(env, nullptr, &testData);
272
+ exports["callWithArgs"] = Function::New<CallWithArgs>(env);
273
+ exports["callWithVector"] = Function::New<CallWithVector>(env);
274
+ exports["callWithVectorUsingCppWrapper"] =
275
+ Function::New<CallWithVectorUsingCppWrapper>(env);
276
+ exports["callWithCStyleArray"] = Function::New<CallWithCStyleArray>(env);
277
+ exports["callWithReceiverAndCStyleArray"] =
278
+ Function::New<CallWithReceiverAndCStyleArray>(env);
279
+ exports["callWithReceiverAndArgs"] =
280
+ Function::New<CallWithReceiverAndArgs>(env);
281
+ exports["callWithReceiverAndVector"] =
282
+ Function::New<CallWithReceiverAndVector>(env);
283
+ exports["callWithReceiverAndVectorUsingCppWrapper"] =
284
+ Function::New<CallWithReceiverAndVectorUsingCppWrapper>(env);
285
+ exports["callWithInvalidReceiver"] =
286
+ Function::New<CallWithInvalidReceiver>(env);
287
+ exports["callConstructorWithArgs"] =
288
+ Function::New<CallConstructorWithArgs>(env);
289
+ exports["callConstructorWithVector"] =
290
+ Function::New<CallConstructorWithVector>(env);
291
+ exports["callConstructorWithCStyleArray"] =
292
+ Function::New<CallConstructorWithCStyleArray>(env);
293
+ exports["isConstructCall"] = Function::New<IsConstructCall>(env);
294
+ exports["makeCallbackWithArgs"] = Function::New<MakeCallbackWithArgs>(env);
295
+ exports["makeCallbackWithVector"] =
296
+ Function::New<MakeCallbackWithVector>(env);
297
+ exports["makeCallbackWithCStyleArray"] =
298
+ Function::New<MakeCallbackWithCStyleArray>(env);
299
+ exports["makeCallbackWithInvalidReceiver"] =
300
+ Function::New<MakeCallbackWithInvalidReceiver>(env);
301
+ exports["callWithFunctionOperator"] =
302
+ Function::New<CallWithFunctionOperator>(env);
303
+ result["templated"] = exports;
304
+
305
+ exports = Object::New(env);
306
+ exports["lambdaWithNoCapture"] =
307
+ Function::New(env, [](const CallbackInfo& info) {
308
+ auto env = info.Env();
309
+ return Boolean::New(env, true);
310
+ });
311
+ exports["lambdaWithCapture"] =
312
+ Function::New(env, [data = 42](const CallbackInfo& info) {
313
+ auto env = info.Env();
314
+ return Boolean::New(env, data == 42);
315
+ });
316
+ exports["lambdaWithMoveOnlyCapture"] = Function::New(
317
+ env, [data = std::make_unique<int>(42)](const CallbackInfo& info) {
318
+ auto env = info.Env();
319
+ return Boolean::New(env, *data == 42);
320
+ });
321
+ result["lambda"] = exports;
322
+
323
+ return result;
324
+ }
@@ -0,0 +1,133 @@
1
+ 'use strict';
2
+
3
+ const assert = require('assert');
4
+
5
+ module.exports = require('./common').runTest(binding => {
6
+ test(binding.function.plain);
7
+ test(binding.function.templated);
8
+ testLambda(binding.function.lambda);
9
+ });
10
+
11
+ function test (binding) {
12
+ assert.strictEqual(binding.emptyConstructor(true), true);
13
+ assert.strictEqual(binding.emptyConstructor(false), false);
14
+
15
+ let obj = {};
16
+ assert.deepStrictEqual(binding.voidCallback(obj), undefined);
17
+ assert.deepStrictEqual(obj, { foo: 'bar' });
18
+
19
+ assert.deepStrictEqual(binding.valueCallback(), { foo: 'bar' });
20
+
21
+ let args = null;
22
+ let ret = null;
23
+ let receiver = null;
24
+ function testFunction () {
25
+ receiver = this;
26
+ args = [].slice.call(arguments);
27
+ return ret;
28
+ }
29
+ function testConstructor () {
30
+ args = [].slice.call(arguments);
31
+ }
32
+
33
+ function makeCallbackTestFunction (receiver, expectedOne, expectedTwo, expectedThree) {
34
+ return function callback (one, two, three) {
35
+ assert.strictEqual(this, receiver);
36
+ assert.strictEqual(one, expectedOne);
37
+ assert.strictEqual(two, expectedTwo);
38
+ assert.strictEqual(three, expectedThree);
39
+ };
40
+ }
41
+
42
+ ret = 4;
43
+ assert.strictEqual(binding.callWithArgs(testFunction, 1, 2, 3), 4);
44
+ assert.strictEqual(receiver, undefined);
45
+ assert.deepStrictEqual(args, [1, 2, 3]);
46
+
47
+ ret = 5;
48
+ assert.strictEqual(binding.callWithVector(testFunction, 2, 3, 4), 5);
49
+ assert.strictEqual(receiver, undefined);
50
+ assert.deepStrictEqual(args, [2, 3, 4]);
51
+
52
+ ret = 5;
53
+ assert.strictEqual(binding.callWithVectorUsingCppWrapper(testFunction, 2, 3, 4), 5);
54
+ assert.strictEqual(receiver, undefined);
55
+ assert.deepStrictEqual(args, [2, 3, 4]);
56
+
57
+ ret = 6;
58
+ assert.strictEqual(binding.callWithReceiverAndArgs(testFunction, obj, 3, 4, 5), 6);
59
+ assert.deepStrictEqual(receiver, obj);
60
+ assert.deepStrictEqual(args, [3, 4, 5]);
61
+
62
+ ret = 7;
63
+ assert.strictEqual(binding.callWithReceiverAndVector(testFunction, obj, 4, 5, 6), 7);
64
+ assert.deepStrictEqual(receiver, obj);
65
+ assert.deepStrictEqual(args, [4, 5, 6]);
66
+
67
+ ret = 7;
68
+ assert.strictEqual(binding.callWithReceiverAndVectorUsingCppWrapper(testFunction, obj, 4, 5, 6), 7);
69
+ assert.deepStrictEqual(receiver, obj);
70
+ assert.deepStrictEqual(args, [4, 5, 6]);
71
+
72
+ ret = 8;
73
+ assert.strictEqual(binding.callWithCStyleArray(testFunction, 5, 6, 7), ret);
74
+ assert.deepStrictEqual(receiver, undefined);
75
+ assert.deepStrictEqual(args, [5, 6, 7]);
76
+
77
+ ret = 9;
78
+ assert.strictEqual(binding.callWithReceiverAndCStyleArray(testFunction, obj, 6, 7, 8), ret);
79
+ assert.deepStrictEqual(receiver, obj);
80
+ assert.deepStrictEqual(args, [6, 7, 8]);
81
+
82
+ ret = 10;
83
+ assert.strictEqual(binding.callWithFunctionOperator(testFunction, 7, 8, 9), ret);
84
+ assert.strictEqual(receiver, undefined);
85
+ assert.deepStrictEqual(args, [7, 8, 9]);
86
+
87
+ assert.throws(() => {
88
+ binding.callWithInvalidReceiver();
89
+ }, /Invalid (pointer passed as )?argument/);
90
+
91
+ obj = binding.callConstructorWithArgs(testConstructor, 5, 6, 7);
92
+ assert(obj instanceof testConstructor);
93
+ assert.deepStrictEqual(args, [5, 6, 7]);
94
+
95
+ obj = binding.callConstructorWithVector(testConstructor, 6, 7, 8);
96
+ assert(obj instanceof testConstructor);
97
+ assert.deepStrictEqual(args, [6, 7, 8]);
98
+
99
+ obj = binding.callConstructorWithCStyleArray(testConstructor, 7, 8, 9);
100
+ assert(obj instanceof testConstructor);
101
+ assert.deepStrictEqual(args, [7, 8, 9]);
102
+
103
+ obj = {};
104
+ assert.deepStrictEqual(binding.voidCallbackWithData(obj), undefined);
105
+ assert.deepStrictEqual(obj, { foo: 'bar', data: 1 });
106
+
107
+ assert.deepStrictEqual(binding.valueCallbackWithData(), { foo: 'bar', data: 1 });
108
+
109
+ assert.strictEqual(binding.voidCallback.name, 'voidCallback');
110
+ assert.strictEqual(binding.valueCallback.name, 'valueCallback');
111
+
112
+ let testConstructCall;
113
+ binding.isConstructCall((result) => { testConstructCall = result; });
114
+ assert.ok(!testConstructCall);
115
+ /* eslint-disable no-new, new-cap */
116
+ new binding.isConstructCall((result) => { testConstructCall = result; });
117
+ /* eslint-enable no-new, new-cap */
118
+ assert.ok(testConstructCall);
119
+
120
+ obj = {};
121
+ binding.makeCallbackWithArgs(makeCallbackTestFunction(obj, '1', '2', '3'), obj, '1', '2', '3');
122
+ binding.makeCallbackWithVector(makeCallbackTestFunction(obj, 4, 5, 6), obj, 4, 5, 6);
123
+ binding.makeCallbackWithCStyleArray(makeCallbackTestFunction(obj, 7, 8, 9), obj, 7, 8, 9);
124
+ assert.throws(() => {
125
+ binding.makeCallbackWithInvalidReceiver(() => {});
126
+ });
127
+ }
128
+
129
+ function testLambda (binding) {
130
+ assert.ok(binding.lambdaWithNoCapture());
131
+ assert.ok(binding.lambdaWithCapture());
132
+ assert.ok(binding.lambdaWithMoveOnlyCapture());
133
+ }