blob: 180d3deaf4ae594cee5dcef6ab4172e80bf7eaba [file] [log] [blame]
<meta charset="utf-8">
<title>CSSNumericValue.equals tests</title>
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#dom-cssnumericvalue-equals">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../resources/testhelper.js"></script>
<script>
'use strict';
test(() => {
assert_true(CSS.px(1).equals(CSS.px(1)));
}, 'Two CSSUnitValues with same value and unit are equal');
test(() => {
assert_false(CSS.px(0).equals(CSS.px(1)));
}, 'Two CSSUnitValues with different values are not equal');
test(() => {
assert_false(CSS.px(1).equals(CSS.number(1)));
}, 'Two CSSUnitValues with different units are not equal');
test(() => {
const a = new CSSMathSum(0, new CSSMathNegate(0));
const b = new CSSMathProduct(0, new CSSMathNegate(0));
assert_false(a.equals(b));
}, 'Two CSSMathValues with different types are not equal');
test(() => {
const a = new CSSMathSum(0, new CSSMathNegate(0));
const b = new CSSMathSum(0);
assert_false(a.equals(b));
}, 'Two CSSMathValues with different number of values are not equal');
test(() => {
const a = new CSSMathSum(0, new CSSMathNegate(0));
const b = new CSSMathSum(0, new CSSMathNegate(1));
assert_false(a.equals(b));
}, 'Two CSSMathValues with different values are not equal');
test(() => {
const a = new CSSMathSum(0, new CSSMathNegate(0));
const b = new CSSMathSum(0, new CSSMathNegate(0));
assert_true(a.equals(b));
}, 'Two CSSMathValues with same structure are equal');
test(() => {
const a = new CSSMathSum(0, new CSSMathNegate(0));
const b = new CSSMathSum(0, new CSSMathNegate(0));
const c = new CSSMathSum(0, new CSSMathNegate(0));
const d = new CSSMathSum(0, new CSSMathNegate(0));
assert_true(a.equals(b, c, d));
}, 'Multiple CSSMathValues with same structure are equal');
test(() => {
const a = new CSSMathSum(0, new CSSMathNegate(0));
const b = new CSSMathSum(0, new CSSMathNegate(0));
const c = new CSSMathSum(0, new CSSMathNegate(1));
const d = new CSSMathSum(0, new CSSMathNegate(0));
assert_false(a.equals(b, c, d));
}, 'Multiple CSSMathValues with one different are not equal');
</script>