summaryrefslogtreecommitdiff
path: root/test/harness
diff options
context:
space:
mode:
authorRick Waldron <waldron.rick@gmail.com>2017-06-23 11:08:11 -0400
committerRick Waldron <waldron.rick@gmail.com>2017-06-28 11:53:59 -0400
commit27f3452b33cb3f35c2d28d61a47a3add2007dec7 (patch)
treef909fe057385f572a57fe78547b08db03a203f5a /test/harness
parentc9f3ab5610e4cedf84aed497087286638ae7e58d (diff)
downloadqtdeclarative-testsuites-27f3452b33cb3f35c2d28d61a47a3add2007dec7.tar.gz
harness test: arrayContains.js
Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
Diffstat (limited to 'test/harness')
-rw-r--r--test/harness/arrayContains.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/harness/arrayContains.js b/test/harness/arrayContains.js
new file mode 100644
index 000000000..3f83e3087
--- /dev/null
+++ b/test/harness/arrayContains.js
@@ -0,0 +1,24 @@
+// Copyright (c) 2017 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Assert that the contents of an array contains another array as a slice or sub-array
+includes: [arrayContains.js]
+---*/
+
+const willMatch = [0, 1, 2];
+
+assert(arrayContains([0, 1, 2, 3], willMatch));
+assert(arrayContains([null, 0, 1, 2, 3], willMatch));
+assert(arrayContains([undefined, 0, 1, 2, 3], willMatch));
+assert(arrayContains([false, 0, 1, 2, 3], willMatch));
+assert(arrayContains([NaN, 0, 1, 2, 3], willMatch));
+
+const willNotMatch = [1, 0, 2];
+
+assert(!arrayContains([1, /* intentional hole */, 2], willNotMatch), '[1, /* intentional hole */, 2], willNotMatch)');
+assert(!arrayContains([1, null, 2], willNotMatch), '[1, null, 2], willNotMatch)');
+assert(!arrayContains([1, undefined, 2], willNotMatch), '[1, undefined, 2], willNotMatch)');
+assert(!arrayContains([1, false, 2], willNotMatch), '[1, false, 2], willNotMatch)');
+assert(!arrayContains([1, NaN, 2], willNotMatch), '[1, NaN, 2], willNotMatch)');