| 39 | |
| 40 | template <typename T> |
| 41 | void test_value(T value) { |
| 42 | static_assert(sizeof(T) == 8 || sizeof(T) == 4); |
| 43 | cout << " testing value " << value << endl; |
| 44 | cout << " setting properties preserves the expected value" << endl; |
| 45 | val::global().set("a", val(value)); |
| 46 | ensure_js(compare_a_number_or_bigint_js(value)); |
| 47 | cout << " getting properties returns the original value intact" << endl; |
| 48 | assert(val::global()["a"].as<T>() == value); |
| 49 | cout << " function calls roundtrip the value correctly" << endl; |
| 50 | const char* typeName; |
| 51 | if constexpr (sizeof(T) == 8) { |
| 52 | typeName = "BigInt"; |
| 53 | } else { |
| 54 | typeName = "Number"; |
| 55 | } |
| 56 | assert(val::global(typeName)(value).template as<T>() == value); |
| 57 | cout << " method calls roundtrip the value correctly" << endl; |
| 58 | assert(val::global().call<T>(typeName, value) == value); |
| 59 | } |
| 60 | |
| 61 | int main() { |
| 62 | const int64_t max_int64_t = numeric_limits<int64_t>::max(); |