mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-11 23:04:29 +00:00
Merge pull request #89 from realm/al-null
Test/fix setting all primitive types to null/undefined
This commit is contained in:
commit
33edd04897
@ -127,6 +127,10 @@ static inline JSObjectRef RJSValidatedValueToFunction(JSContextRef ctx, JSValueR
|
||||
}
|
||||
|
||||
static inline double RJSValidatedValueToNumber(JSContextRef ctx, JSValueRef value) {
|
||||
if (JSValueIsNull(ctx, value)) {
|
||||
throw std::invalid_argument("`null` is not a number.");
|
||||
}
|
||||
|
||||
JSValueRef exception = NULL;
|
||||
double number = JSValueToNumber(ctx, value, &exception);
|
||||
if (exception) {
|
||||
|
@ -73,10 +73,52 @@ module.exports = BaseTest.extend({
|
||||
TestCase.assertThrows(function() {
|
||||
obj.boolCol = 'cat';
|
||||
});
|
||||
|
||||
TestCase.assertThrows(function() {
|
||||
obj.intCol = 'dog';
|
||||
});
|
||||
|
||||
TestCase.assertThrows(function() {
|
||||
obj.boolCol = null;
|
||||
});
|
||||
TestCase.assertThrows(function() {
|
||||
obj.boolCol = undefined;
|
||||
});
|
||||
TestCase.assertThrows(function() {
|
||||
obj.intCol = null;
|
||||
});
|
||||
TestCase.assertThrows(function() {
|
||||
obj.intCol = undefined;
|
||||
});
|
||||
TestCase.assertThrows(function() {
|
||||
obj.floatCol = null;
|
||||
});
|
||||
TestCase.assertThrows(function() {
|
||||
obj.floatCol = undefined;
|
||||
});
|
||||
TestCase.assertThrows(function() {
|
||||
obj.doubleCol = null;
|
||||
});
|
||||
TestCase.assertThrows(function() {
|
||||
obj.doubleCol = undefined;
|
||||
});
|
||||
TestCase.assertThrows(function() {
|
||||
obj.stringCol = null;
|
||||
});
|
||||
TestCase.assertThrows(function() {
|
||||
obj.stringCol = undefined;
|
||||
});
|
||||
TestCase.assertThrows(function() {
|
||||
obj.dateCol = null;
|
||||
});
|
||||
TestCase.assertThrows(function() {
|
||||
obj.dateCol = undefined;
|
||||
});
|
||||
TestCase.assertThrows(function() {
|
||||
obj.dataCol = null;
|
||||
});
|
||||
TestCase.assertThrows(function() {
|
||||
obj.dataCol = undefined;
|
||||
});
|
||||
});
|
||||
|
||||
TestCase.assertThrows(function() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user