aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJulien Gilli <julien.gilli@joyent.com>2014-08-11 15:15:21 -0700
committerTimothy J Fontaine <tjfontaine@gmail.com>2014-08-13 11:43:09 -0700
commit7d1860a6788621111381bd63d3e486bb15c01485 (patch)
treee92361534ca5d7ba1a1bd9135250c1e56e51f2f2 /test
parent44743eaf24b0c0a7fbaa8d9aa04b4a211d8ec5e2 (diff)
downloadandroid-node-v8-7d1860a6788621111381bd63d3e486bb15c01485.tar.gz
android-node-v8-7d1860a6788621111381bd63d3e486bb15c01485.tar.bz2
android-node-v8-7d1860a6788621111381bd63d3e486bb15c01485.zip
tests: fix invalid hints flags dns test.
1 is actually a valid flag on SmartOS. More generally, hints flags' values are defined by the underlying native flags, and these can have different values on different systems. Using (ADDRCONFIG | V4MAPPED) + 1 ensure that the flag will be invalid, since it will always be different from ADDRCONFIG, V4MAPPED, ADDRCONFIG | V4MAPPED, 0 and any other combination of even flags. Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/simple/test-dns.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/test/simple/test-dns.js b/test/simple/test-dns.js
index 48f7d5f40a..c62a3c889c 100644
--- a/test/simple/test-dns.js
+++ b/test/simple/test-dns.js
@@ -69,8 +69,18 @@ assert.throws(function() {
return !(err instanceof TypeError);
}, 'Unexpected error');
+/*
+ * Make sure that dns.lookup throws if hints does not represent a valid flag.
+ * (dns.V4MAPPED | dns.ADDRCONFIG) + 1 is invalid because:
+ * - it's different from dns.V4MAPPED and dns.ADDRCONFIG.
+ * - it's different from them bitwise ored.
+ * - it's different from 0.
+ * - it's an odd number different than 1, and thus is invalid, because
+ * flags are either === 1 or even.
+ */
assert.throws(function() {
- dns.lookup('www.google.com', { hints: 1 }, noop);
+ dns.lookup('www.google.com', { hints: (dns.V4MAPPED | dns.ADDRCONFIG) + 1 },
+ noop);
});
assert.throws(function() {