|
18 | 18 | @import 'sass-utils';
|
19 | 19 |
|
20 | 20 | @function assert($result, $expected: true) {
|
21 |
| - @if $result != $expected { |
| 21 | + @if (type-of($result) == 'color' and type-of($expected) == 'color') { |
| 22 | + $result: #{$result}; |
| 23 | + $expected: #{$expected}; |
| 24 | + } |
| 25 | + |
| 26 | + @if ($result != $expected or type-of($result) != type-of($expected)) { |
22 | 27 | $result: if($result == null, 'null', $result);
|
23 | 28 | $expected: if($expected == null, 'null', $expected);
|
24 | 29 | @error "Assertion failed, expected '" + $expected + "', got '" + $result + "'";
|
|
96 | 101 | @debug test('list-index, Three, valid', list-index([1, '2', false], 1), 0);
|
97 | 102 | @debug test('list-index, Three, valid', list-index([1, '2', false], '2'), 1);
|
98 | 103 | @debug test('list-index, Three, valid', list-index([1, '2', false], false), 2);
|
| 104 | + |
| 105 | +@debug test('nth-root 1-root of 0', nth-root(0, 1), 0); |
| 106 | +@debug test('nth-root 0-root of 0', nth-root(0, 20), 0); |
| 107 | +@debug test('nth-root 2-root of 4', nth-root(4, 2), 2); |
| 108 | +@debug test('nth-root 4-root of 256', nth-root(256, 4), 4); |
| 109 | +@debug test('nth-root 5-root of 4096', nth-root(4096.0, 5), 5.278031643091578); |
| 110 | + |
| 111 | +@debug test('pow 0^0', pow(0, 0), 1); |
| 112 | +@debug test('pow 1^0', pow(1, 0), 1); |
| 113 | +@debug test('pow 10^0', pow(10, 0), 1); |
| 114 | + |
| 115 | +@debug test('pow 0^10', pow(0, 10), 0); |
| 116 | +@debug test('pow 1^20', pow(1, 20), 1); |
| 117 | +@debug test('pow 2^8', pow(2, 8), 256); |
| 118 | +@debug test('pow 10^3', pow(10, 3), 1000); |
| 119 | + |
| 120 | +@debug test('pow 2^-2', pow(2, -2), 1/4); |
| 121 | +@debug test('pow 3^-3', pow(3, -3), 1/27); |
| 122 | + |
| 123 | +@debug test('pow 2^(2/2)', pow(2, 2, 2), 2); |
| 124 | +@debug test('pow 2^(4/2)', pow(2, 4, 2), 4); |
| 125 | +@debug test('pow 2^(12/5)', pow(2, 12, 5), 5.278031643091582); |
| 126 | + |
| 127 | +@debug test('truncate 0.1234567890123456789', truncate(0.123456789123456789), 0.1234567891); |
| 128 | +@debug test('truncate 5 0.12345678901234', truncate(0.12345678901234, 5), 0.12345); |
| 129 | +@debug test('truncate 5 0.12345678901234', truncate(0.12345678901234, 1), 0.1); |
| 130 | +@debug test('truncate 5 5.12345678901234', truncate(5.12345678901234, 0), 5); |
| 131 | + |
| 132 | +@debug test('luminance white', luminance(white), 1); |
| 133 | +@debug test('luminance black', luminance(black), 0); |
| 134 | +@debug test('luminance red', luminance(#f00), 0.2126); |
| 135 | +@debug test('luminance green', luminance(#0f0), 0.7152); |
| 136 | +@debug test('luminance blue', luminance(#00f), 0.0722); |
| 137 | +@debug test('luminance Ubuntu orange', truncate(luminance(#dd4814), 6), 0.200573); |
| 138 | + |
| 139 | +@debug test('color contrast black/white', color-contrast(white, black), 21); |
| 140 | +@debug test('color contrast blue/blue', color-contrast(blue, blue), 1); |
| 141 | + |
| 142 | +@debug test('optimize-contrast black/blue', optimize-contrast(black, blue), #5e5eff); |
| 143 | +@debug test('optimize-contrast white/blue', optimize-contrast(white, lightgray), #767676); |
0 commit comments