MCPcopy
hub / github.com/meteor/meteor / equal

Method equal

packages/tinytest/tinytest.js:113–153  ·  view source on GitHub ↗
(actual, expected, message, not)

Source from the content-addressed store, hash-verified

111
112 // XXX eliminate 'message' and 'not' arguments
113 equal(actual, expected, message, not) {
114 if ((! not) && (typeof actual === 'string') &&
115 (typeof expected === 'string')) {
116 this._stringEqual(actual, expected, message);
117 return;
118 }
119
120 /* If expected is a DOM node, do a literal '===' comparison with
121 * actual. Otherwise do a deep comparison, as implemented by _.isEqual.
122 */
123
124 var matched;
125 // XXX remove cruft specific to liverange
126 if (typeof expected === "object" && expected && expected.nodeType) {
127 matched = expected === actual;
128 expected = "[Node]";
129 actual = "[Unknown]";
130 } else if (typeof Uint8Array !== 'undefined' && expected instanceof Uint8Array) {
131 // I have no idea why but _.isEqual on Chrome horks completely on Uint8Arrays.
132 // and the symptom is the chrome renderer taking up an entire CPU and freezing
133 // your web page, but not pausing anywhere in _.isEqual. I don't understand it
134 // but we fall back to a manual comparison
135 if (!(actual instanceof Uint8Array))
136 this.fail({type: "assert_equal", message: "found object is not a typed array",
137 expected: "A typed array", actual: actual.constructor.toString()});
138 if (expected.length !== actual.length)
139 this.fail({type: "assert_equal", message: "lengths of typed arrays do not match",
140 expected: expected.length, actual: actual.length});
141 for (var i = 0; i < expected.length; i++) {
142 this.equal(actual[i], expected[i]);
143 }
144 } else {
145 matched = EJSON.equals(expected, actual);
146 }
147
148 if (matched === !!not) {
149 this.fail({type: "assert_equal", message: message,
150 expected: JSON.stringify(expected), actual: JSON.stringify(actual), not: !!not});
151 } else
152 this.ok();
153 }
154
155 notEqual(actual, expected, message) {
156 this.equal(actual, expected, message, true);

Callers 15

notEqualMethod · 0.95
methods.tests.jsFile · 0.80
links.tests.jsFile · 0.80
~fs-name~-tests.jsFile · 0.80
walkFunction · 0.80

Calls 5

_stringEqualMethod · 0.95
failMethod · 0.95
okMethod · 0.95
toStringMethod · 0.45
equalsMethod · 0.45

Tested by

no test coverage detected