Skip to content
This repository was archived by the owner on Nov 21, 2024. It is now read-only.

Commit 1459c2b

Browse files
author
Lucas Wojciechowski
committed
Add tests for null operands
1 parent 518f834 commit 1459c2b

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

test.js

+46
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@ test('==, number', function(t) {
3030
t.end();
3131
});
3232

33+
test('==, null', function(t) {
34+
var f = filter(['==', 'foo', null]);
35+
t.equal(f({properties: {foo: 0}}), false);
36+
t.equal(f({properties: {foo: 1}}), false);
37+
t.equal(f({properties: {foo: '0'}}), false);
38+
t.equal(f({properties: {foo: true}}), false);
39+
t.equal(f({properties: {foo: false}}), false);
40+
t.equal(f({properties: {foo: null}}), true);
41+
t.equal(f({properties: {foo: undefined}}), false);
42+
t.equal(f({properties: {}}), false);
43+
t.end();
44+
});
45+
3346
test('==, $type', function(t) {
3447
var f = filter(['==', '$type', 'LineString']);
3548
t.equal(f({type: 1}), false);
@@ -57,6 +70,19 @@ test('!=, number', function(t) {
5770
t.end();
5871
});
5972

73+
test('!=, null', function(t) {
74+
var f = filter(['!=', 'foo', null]);
75+
t.equal(f({properties: {foo: 0}}), true);
76+
t.equal(f({properties: {foo: 1}}), true);
77+
t.equal(f({properties: {foo: '0'}}), true);
78+
t.equal(f({properties: {foo: true}}), true);
79+
t.equal(f({properties: {foo: false}}), true);
80+
t.equal(f({properties: {foo: null}}), false);
81+
t.equal(f({properties: {foo: undefined}}), true);
82+
t.equal(f({properties: {}}), true);
83+
t.end();
84+
});
85+
6086
test('!=, $type', function(t) {
6187
var f = filter(['!=', '$type', 'LineString']);
6288
t.equal(f({type: 1}), true);
@@ -217,6 +243,17 @@ test('in, number', function(t) {
217243
t.end();
218244
});
219245

246+
test('in, null', function(t) {
247+
var f = filter(['in', 'foo', null]);
248+
t.equal(f({properties: {foo: 0}}), false);
249+
t.equal(f({properties: {foo: '0'}}), false);
250+
t.equal(f({properties: {foo: true}}), false);
251+
t.equal(f({properties: {foo: false}}), false);
252+
t.equal(f({properties: {foo: null}}), true);
253+
t.equal(f({properties: {foo: undefined}}), false);
254+
t.end();
255+
});
256+
220257
test('in, multiple', function(t) {
221258
var f = filter(['in', 'foo', 0, 1]);
222259
t.equal(f({properties: {foo: 0}}), true);
@@ -273,6 +310,15 @@ test('!in, number', function(t) {
273310
t.end();
274311
});
275312

313+
test('!in, null', function(t) {
314+
var f = filter(['!in', 'foo', null]);
315+
t.equal(f({properties: {foo: 0}}), true);
316+
t.equal(f({properties: {foo: '0'}}), true);
317+
t.equal(f({properties: {foo: null}}), false);
318+
t.equal(f({properties: {foo: undefined}}), true);
319+
t.end();
320+
});
321+
276322
test('!in, multiple', function(t) {
277323
var f = filter(['!in', 'foo', 0, 1]);
278324
t.equal(f({properties: {foo: 0}}), false);

0 commit comments

Comments
 (0)