-
Notifications
You must be signed in to change notification settings - Fork 465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: conditional test experimental features with NODE_MAJOR_VERSION #545
Changes from 3 commits
93348b1
890d904
988e5c2
5fae20a
03d6195
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -376,9 +376,9 @@ inline bool Value::IsNumber() const { | |||||
return Type() == napi_number; | ||||||
} | ||||||
|
||||||
// currently experimental guard with version of NAPI_VERSION that it is | ||||||
// currently experimental guard with definition of NAPI_EXPERIMENTAL that it is | ||||||
// released in once it is no longer experimental | ||||||
#if (NAPI_VERSION > 2147483646) | ||||||
#ifdef NAPI_EXPERIMENTAL | ||||||
inline bool Value::IsBigInt() const { | ||||||
return Type() == napi_bigint; | ||||||
} | ||||||
|
@@ -613,9 +613,9 @@ inline double Number::DoubleValue() const { | |||||
return result; | ||||||
} | ||||||
|
||||||
// currently experimental guard with version of NAPI_VERSION that it is | ||||||
// currently experimental guard with definition of NAPI_EXPERIMENTAL that it is | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With commit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What the comment is trying to say is:
Maybe it comment should be // currently experimental, for now guard with definition of NAPI_EXPERIMENTAL. Once it is no |
||||||
// released in once it is no longer experimental | ||||||
#if (NAPI_VERSION > 2147483646) | ||||||
#ifdef NAPI_EXPERIMENTAL | ||||||
//////////////////////////////////////////////////////////////////////////////// | ||||||
// BigInt Class | ||||||
//////////////////////////////////////////////////////////////////////////////// | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -111,9 +111,9 @@ namespace Napi { | |||||
class Value; | ||||||
class Boolean; | ||||||
class Number; | ||||||
// currently experimental guard with version of NAPI_VERSION that it is | ||||||
// currently experimental guard with definition of NAPI_EXPERIMENTAL that it is | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
// released in once it is no longer experimental | ||||||
#if (NAPI_VERSION > 2147483646) | ||||||
#ifdef NAPI_EXPERIMENTAL | ||||||
class BigInt; | ||||||
#endif // NAPI_EXPERIMENTAL | ||||||
#if (NAPI_VERSION > 4) | ||||||
|
@@ -139,9 +139,9 @@ namespace Napi { | |||||
typedef TypedArrayOf<uint32_t> Uint32Array; ///< Typed-array of unsigned 32-bit integers | ||||||
typedef TypedArrayOf<float> Float32Array; ///< Typed-array of 32-bit floating-point values | ||||||
typedef TypedArrayOf<double> Float64Array; ///< Typed-array of 64-bit floating-point values | ||||||
// currently experimental guard with version of NAPI_VERSION that it is | ||||||
// currently experimental guard with definition of NAPI_EXPERIMENTAL that it is | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
// released in once it is no longer experimental | ||||||
#if (NAPI_VERSION > 2147483646) | ||||||
#ifdef NAPI_EXPERIMENTAL | ||||||
typedef TypedArrayOf<int64_t> BigInt64Array; ///< Typed array of signed 64-bit integers | ||||||
typedef TypedArrayOf<uint64_t> BigUint64Array; ///< Typed array of unsigned 64-bit integers | ||||||
#endif // NAPI_EXPERIMENTAL | ||||||
|
@@ -244,9 +244,9 @@ namespace Napi { | |||||
bool IsNull() const; ///< Tests if a value is a null JavaScript value. | ||||||
bool IsBoolean() const; ///< Tests if a value is a JavaScript boolean. | ||||||
bool IsNumber() const; ///< Tests if a value is a JavaScript number. | ||||||
// currently experimental guard with version of NAPI_VERSION that it is | ||||||
// currently experimental guard with definition of NAPI_EXPERIMENTAL that it is | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
// released in once it is no longer experimental | ||||||
#if (NAPI_VERSION > 2147483646) | ||||||
#ifdef NAPI_EXPERIMENTAL | ||||||
bool IsBigInt() const; ///< Tests if a value is a JavaScript bigint. | ||||||
#endif // NAPI_EXPERIMENTAL | ||||||
#if (NAPI_VERSION > 4) | ||||||
|
@@ -321,9 +321,9 @@ namespace Napi { | |||||
double DoubleValue() const; ///< Converts a Number value to a 64-bit floating-point value. | ||||||
}; | ||||||
|
||||||
// currently experimental guard with version of NAPI_VERSION that it is | ||||||
// currently experimental guard with definition of NAPI_EXPERIMENTAL that it is | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
// released in once it is no longer experimental | ||||||
#if (NAPI_VERSION > 2147483646) | ||||||
#ifdef NAPI_EXPERIMENTAL | ||||||
/// A JavaScript bigint value. | ||||||
class BigInt : public Value { | ||||||
public: | ||||||
|
@@ -851,9 +851,9 @@ namespace Napi { | |||||
: std::is_same<T, uint32_t>::value ? napi_uint32_array | ||||||
: std::is_same<T, float>::value ? napi_float32_array | ||||||
: std::is_same<T, double>::value ? napi_float64_array | ||||||
// currently experimental guard with version of NAPI_VERSION that it is | ||||||
// currently experimental guard with definition of NAPI_EXPERIMENTAL that it is | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
// released in once it is no longer experimental | ||||||
#if (NAPI_VERSION > 2147483646) | ||||||
#ifdef NAPI_EXPERIMENTAL | ||||||
: std::is_same<T, int64_t>::value ? napi_bigint64_array | ||||||
: std::is_same<T, uint64_t>::value ? napi_biguint64_array | ||||||
#endif // NAPI_EXPERIMENTAL | ||||||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -1,11 +1,12 @@ | ||||||||||
// currently experimental guard with version of NODE_MAJOR_VERSION that it is | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think experimental feature tests do tell which Node.js versions it could be run on. And we should continuously update the test table on each backport. And experimental features were always temporary status, IMO. It is not necessary to point out that an experimental guard flag is temporary, IMO. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it is important to point out that we should NOT use NODE_MAJOR_VERSION once it is not experimental. I'd be ok with: // currently experimental temporarily guard with NODE_MAJOR_VERISION. |
||||||||||
// released in once it is no longer experimental | ||||||||||
#if (NODE_MAJOR_VERSION >= 10) | ||||||||||
|
||||||||||
#define NAPI_EXPERIMENTAL | ||||||||||
#include "napi.h" | ||||||||||
|
||||||||||
using namespace Napi; | ||||||||||
|
||||||||||
// currently experimental guard with version of NAPI_VERSION that it is | ||||||||||
// released in once it is no longer experimental | ||||||||||
#if (NAPI_VERSION > 2147483646) | ||||||||||
namespace { | ||||||||||
|
||||||||||
Value IsLossless(const CallbackInfo& info) { | ||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -1,4 +1,3 @@ | ||||||||||
#define NAPI_EXPERIMENTAL | ||||||||||
#include "napi.h" | ||||||||||
|
||||||||||
using namespace Napi; | ||||||||||
|
@@ -11,9 +10,9 @@ Object InitBasicTypesArray(Env env); | |||||||||
Object InitBasicTypesBoolean(Env env); | ||||||||||
Object InitBasicTypesNumber(Env env); | ||||||||||
Object InitBasicTypesValue(Env env); | ||||||||||
// currently experimental guard with version of NAPI_VERSION that it is | ||||||||||
// currently experimental guard with version of NODE_MAJOR_VERSION that it is | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
// released in once it is no longer experimental | ||||||||||
#if (NAPI_VERSION > 2147483646) | ||||||||||
#if (NODE_MAJOR_VERSION >= 10) | ||||||||||
Object InitBigInt(Env env); | ||||||||||
#endif | ||||||||||
Object InitBuffer(Env env); | ||||||||||
|
@@ -56,9 +55,9 @@ Object Init(Env env, Object exports) { | |||||||||
exports.Set("basic_types_boolean", InitBasicTypesBoolean(env)); | ||||||||||
exports.Set("basic_types_number", InitBasicTypesNumber(env)); | ||||||||||
exports.Set("basic_types_value", InitBasicTypesValue(env)); | ||||||||||
// currently experimental guard with version of NAPI_VERSION that it is | ||||||||||
// currently experimental guard with version of NODE_MAJOR_VERSION that it is | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
// released in once it is no longer experimental | ||||||||||
#if (NAPI_VERSION > 2147483646) | ||||||||||
#if (NODE_MAJOR_VERSION >= 10) | ||||||||||
exports.Set("bigint", InitBigInt(env)); | ||||||||||
#endif | ||||||||||
#if (NAPI_VERSION > 4) | ||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
#define NAPI_EXPERIMENTAL | ||
#include "napi.h" | ||
|
||
using namespace Napi; | ||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -48,10 +48,12 @@ let testModules = [ | |||||||||
'version_management' | ||||||||||
]; | ||||||||||
|
||||||||||
if ((process.env.npm_config_NAPI_VERSION !== undefined) && | ||||||||||
(process.env.npm_config_NAPI_VERSION < 50000)) { | ||||||||||
// currently experimental only test if NAPI_VERSION | ||||||||||
// is set to experimental. We can't use C max int | ||||||||||
const napiVersion = Number(process.versions.napi) | ||||||||||
const nodeMajorVersion = Number(process.versions.node.match(/\d+/)[0]) | ||||||||||
|
||||||||||
if (nodeMajorVersion < 10) { | ||||||||||
// currently experimental only test if node major version | ||||||||||
// is set to experimental. We can't use napi_experimental here | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
// as that is not supported as a number on earlier | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
// Node.js versions. Once bigint is in a release | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
// this should be guarded on the napi version | ||||||||||
|
@@ -60,25 +62,25 @@ if ((process.env.npm_config_NAPI_VERSION !== undefined) && | |||||||||
testModules.splice(testModules.indexOf('typedarray-bigint'), 1); | ||||||||||
} | ||||||||||
|
||||||||||
if ((process.env.npm_config_NAPI_VERSION !== undefined) && | ||||||||||
(process.env.npm_config_NAPI_VERSION < 3)) { | ||||||||||
if (napiVersion < 3) { | ||||||||||
testModules.splice(testModules.indexOf('callbackscope'), 1); | ||||||||||
testModules.splice(testModules.indexOf('version_management'), 1); | ||||||||||
} | ||||||||||
|
||||||||||
if ((process.env.npm_config_NAPI_VERSION !== undefined) && | ||||||||||
(process.env.npm_config_NAPI_VERSION < 4)) { | ||||||||||
if (napiVersion < 4) { | ||||||||||
testModules.splice(testModules.indexOf('threadsafe_function/threadsafe_function_ptr'), 1); | ||||||||||
testModules.splice(testModules.indexOf('threadsafe_function/threadsafe_function_unref'), 1); | ||||||||||
testModules.splice(testModules.indexOf('threadsafe_function/threadsafe_function'), 1); | ||||||||||
} | ||||||||||
|
||||||||||
if ((process.env.npm_config_NAPI_VERSION !== undefined) && | ||||||||||
(process.env.npm_config_NAPI_VERSION < 5)) { | ||||||||||
if (napiVersion < 5) { | ||||||||||
testModules.splice(testModules.indexOf('date'), 1); | ||||||||||
} | ||||||||||
|
||||||||||
if (typeof global.gc === 'function') { | ||||||||||
console.log(`Testing with N-API Version '${napiVersion}'.`); | ||||||||||
console.log(`Testing with Node.js Major Version '${nodeMajorVersion}'.\n`); | ||||||||||
|
||||||||||
console.log('Starting test suite\n'); | ||||||||||
|
||||||||||
// Requiring each module runs tests in the module. | ||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -1,4 +1,8 @@ | ||||||||||
// currently experimental guard with version of NODE_MAJOR_VERSION that it is | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
// released in once it is no longer experimental | ||||||||||
#if (NODE_MAJOR_VERSION >= 10) | ||||||||||
#define NAPI_EXPERIMENTAL | ||||||||||
#endif | ||||||||||
#include "napi.h" | ||||||||||
|
||||||||||
using namespace Napi; | ||||||||||
|
@@ -65,9 +69,9 @@ Value CreateTypedArray(const CallbackInfo& info) { | |||||||||
NAPI_TYPEDARRAY_NEW(Float64Array, info.Env(), length, napi_float64_array) : | ||||||||||
NAPI_TYPEDARRAY_NEW_BUFFER(Float64Array, info.Env(), length, buffer, bufferOffset, | ||||||||||
napi_float64_array); | ||||||||||
// currently experimental guard with version of NAPI_VERSION that it is | ||||||||||
// currently experimental guard with version of NODE_MAJOR_VERSION that it is | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
// released in once it is no longer experimental | ||||||||||
#if (NAPI_VERSION > 2147483646) | ||||||||||
#if (NODE_MAJOR_VERSION >= 10) | ||||||||||
} else if (arrayType == "bigint64") { | ||||||||||
return buffer.IsUndefined() ? | ||||||||||
NAPI_TYPEDARRAY_NEW(BigInt64Array, info.Env(), length, napi_bigint64_array) : | ||||||||||
|
@@ -101,9 +105,9 @@ Value GetTypedArrayType(const CallbackInfo& info) { | |||||||||
case napi_uint32_array: return String::New(info.Env(), "uint32"); | ||||||||||
case napi_float32_array: return String::New(info.Env(), "float32"); | ||||||||||
case napi_float64_array: return String::New(info.Env(), "float64"); | ||||||||||
// currently experimental guard with version of NAPI_VERSION that it is | ||||||||||
// currently experimental guard with version of NODE_MAJOR_VERSION that it is | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
// released in once it is no longer experimental | ||||||||||
#if (NAPI_VERSION > 2147483646) | ||||||||||
#if (NODE_MAJOR_VERSION >= 10) | ||||||||||
case napi_bigint64_array: return String::New(info.Env(), "bigint64"); | ||||||||||
case napi_biguint64_array: return String::New(info.Env(), "biguint64"); | ||||||||||
#endif | ||||||||||
|
@@ -143,9 +147,9 @@ Value GetTypedArrayElement(const CallbackInfo& info) { | |||||||||
return Number::New(info.Env(), array.As<Float32Array>()[index]); | ||||||||||
case napi_float64_array: | ||||||||||
return Number::New(info.Env(), array.As<Float64Array>()[index]); | ||||||||||
// currently experimental guard with version of NAPI_VERSION that it is | ||||||||||
// currently experimental guard with version of NODE_MAJOR_VERSION that it is | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
// released in once it is no longer experimental | ||||||||||
#if (NAPI_VERSION > 2147483646) | ||||||||||
#if (NODE_MAJOR_VERSION >= 10) | ||||||||||
case napi_bigint64_array: | ||||||||||
return BigInt::New(info.Env(), array.As<BigInt64Array>()[index]); | ||||||||||
case napi_biguint64_array: | ||||||||||
|
@@ -189,9 +193,9 @@ void SetTypedArrayElement(const CallbackInfo& info) { | |||||||||
case napi_float64_array: | ||||||||||
array.As<Float64Array>()[index] = value.DoubleValue(); | ||||||||||
break; | ||||||||||
// currently experimental guard with version of NAPI_VERSION that it is | ||||||||||
// currently experimental guard with version of NODE_MAJOR_VERSION that it is | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
// released in once it is no longer experimental | ||||||||||
#if (NAPI_VERSION > 2147483646) | ||||||||||
#if (NODE_MAJOR_VERSION >= 10) | ||||||||||
case napi_bigint64_array: { | ||||||||||
bool lossless; | ||||||||||
array.As<BigInt64Array>()[index] = value.As<BigInt>().Int64Value(&lossless); | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.