/
githubmirror
/
tabler
Обзор
Документация
Войти
/
githubmirror
/
tabler
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
core/scss/tests/_divide.test.scss
45 строк
2 KB
Paweł Kuna
Unify workspace lint, format, and type-check quality gates (#2732)
30 июл 2026, 20:36
Не верифицирован
30 июл 2026, 20:36
6db32ea
Код
Авторство
О чём код?
// Priority 1 — unit tests for `divide($dividend, $divisor, $precision: 10)` // from scss/mixins/_functions.scss. This is a hand-rolled long-division // algorithm (sign handling, configurable precision, unit propagation), so it // carries the most branching logic of any function in the file. // // Note: the divide-by-zero path uses Sass `@error`, which aborts compilation // and cannot be caught by sass-true (there is no assert-throws), so it is not // covered here. @use '../mixins/functions' as *; @include describe('divide') { @include it('divides two unitless numbers') { @include assert-equal(divide(4, 2), 2); } @include it('returns a fractional result') { @include assert-equal(divide(10, 4), 2.5); @include assert-equal(divide(1, 2), 0.5); } @include it('returns 0 when the dividend is 0') { @include assert-equal(divide(0, 5), 0); } @include it('keeps the correct sign for mixed-sign operands') { @include assert-equal(divide(-6, 2), -3); @include assert-equal(divide(6, -2), -3); @include assert-equal(divide(-6, -2), 3); } @include it('propagates the dividend unit when the divisor is unitless') { @include assert-equal(divide(10px, 2), 5px); @include assert-equal(divide(5%, 2), 2.5%); } @include it('cancels matching units to a unitless result') { @include assert-equal(divide(10px, 2px), 5); } @include it('rounds to the requested precision') { @include assert-equal(divide(2, 3, 0), 1); @include assert-equal(divide(2, 3, 2), 0.67); } }