diff --git a/tests/extend-zi/ref.typ b/tests/extend-zi/ref.typ new file mode 100644 index 0000000..43f41fb --- /dev/null +++ b/tests/extend-zi/ref.typ @@ -0,0 +1,5 @@ +#set page(width: auto, height: auto, margin: .5em) + + +$1#sym.space.thin"fs"$ \ +$1#sym.space.thin"µZero"$ \ \ No newline at end of file diff --git a/tests/extend-zi/ref/1.png b/tests/extend-zi/ref/1.png deleted file mode 100644 index d33f1ec..0000000 Binary files a/tests/extend-zi/ref/1.png and /dev/null differ diff --git a/tests/extend-zi/test.typ b/tests/extend-zi/test.typ index 90d568f..80f726f 100644 --- a/tests/extend-zi/test.typ +++ b/tests/extend-zi/test.typ @@ -1,6 +1,5 @@ #set page(width: auto, height: auto, margin: .5em) #import "zi.typ" -#zi.fs[1] - -#zi.µZ[1] +#zi.fs[1] \ +#zi.µZ[1] \ diff --git a/tests/assertions/.gitignore b/tests/internal/assertions/.gitignore similarity index 100% rename from tests/assertions/.gitignore rename to tests/internal/assertions/.gitignore diff --git a/tests/assertions/test.typ b/tests/internal/assertions/test.typ similarity index 100% rename from tests/assertions/test.typ rename to tests/internal/assertions/test.typ diff --git a/tests/formatting/.gitignore b/tests/internal/formatting/.gitignore similarity index 100% rename from tests/formatting/.gitignore rename to tests/internal/formatting/.gitignore diff --git a/tests/formatting/test.typ b/tests/internal/formatting/test.typ similarity index 100% rename from tests/formatting/test.typ rename to tests/internal/formatting/test.typ diff --git a/tests/parsing/.gitignore b/tests/internal/parsing/.gitignore similarity index 100% rename from tests/parsing/.gitignore rename to tests/internal/parsing/.gitignore diff --git a/tests/parsing/test.typ b/tests/internal/parsing/test.typ similarity index 100% rename from tests/parsing/test.typ rename to tests/internal/parsing/test.typ diff --git a/tests/rounding/.gitignore b/tests/num/digits/.gitignore similarity index 100% rename from tests/rounding/.gitignore rename to tests/num/digits/.gitignore diff --git a/tests/num/digits/ref.typ b/tests/num/digits/ref.typ new file mode 100644 index 0000000..5a3fa19 --- /dev/null +++ b/tests/num/digits/ref.typ @@ -0,0 +1,9 @@ +#set page(width: auto, height: auto, margin: 2pt) + + +$1.23$ \ +$1.20$ \ +$1$ \ +$3$ \ +$-1.23$ \ +$-1.20$ \ diff --git a/tests/num/digits/test.typ b/tests/num/digits/test.typ new file mode 100644 index 0000000..2261f92 --- /dev/null +++ b/tests/num/digits/test.typ @@ -0,0 +1,10 @@ +#import "/src/zero.typ": * +#set page(width: auto, height: auto, margin: 2pt) + + +#num("1.234", digits: 2) \ +#num("1.2", digits: 2) \ +#num("1.234", digits: 0) \ +#num("3.2", digits: 0) \ +#num("-1.234", digits: 2) \ +#num("-1.2", digits: 2) \ diff --git a/tests/num/grouping/.gitignore b/tests/num/grouping/.gitignore new file mode 100644 index 0000000..2e4c5d8 --- /dev/null +++ b/tests/num/grouping/.gitignore @@ -0,0 +1,5 @@ +# generated by tytanic, do not edit + +/diff/ +/out/ +/ref/ diff --git a/tests/num/grouping/ref.typ b/tests/num/grouping/ref.typ new file mode 100644 index 0000000..fa8b7b6 --- /dev/null +++ b/tests/num/grouping/ref.typ @@ -0,0 +1,19 @@ +#set page(width: auto, height: auto, margin: 2pt) + +#let th = sym.space.thin + + +$10.10$ \ +$123.321$ \ +$1234.4321$ \ +$12th 345.543th 21$ \ +$1th 234th 567$ \ +$1234567$ \ +$1th 234.432th 1$ \ +$1"'"23"'"45.54"'"32"'"1$ \ + +#pagebreak() + +$23th 232.2323$ \ +$23232.232th 3$ \ +$23th 232.2323$ \ diff --git a/tests/num/grouping/test.typ b/tests/num/grouping/test.typ new file mode 100644 index 0000000..c76ebc1 --- /dev/null +++ b/tests/num/grouping/test.typ @@ -0,0 +1,34 @@ +#import "/src/zero.typ": * +#set page(width: auto, height: auto, margin: 2pt) + + + +#num("10.10") \ +#num("123.321") \ +#num("1234.4321") \ +#num("12345.54321") \ +#num("1234567") \ +#set-group(threshold: calc.inf) +#num("1234567") \ +#set-group(threshold: 3) +#num("1234.4321") \ +#set-group(separator: "'", size: 2) +#num("12345.54321") \ +#set-group(separator: sym.space.thin, size: 3, threshold: 5) + + +#pagebreak() + +// Asymmetric thresholds +#num( + group: (threshold: (fractional: 5, integer: 3)), + [23232.2323], +) \ +#num( + group: (threshold: (fractional: 3, integer: calc.inf)), + [23232.2323], +) \ +#num( + group: (threshold: (integer: 3, fractional: calc.inf)), + [23232.2323], +) diff --git a/tests/num/identical/.gitignore b/tests/num/identical/.gitignore deleted file mode 100644 index db843b2..0000000 --- a/tests/num/identical/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/ref \ No newline at end of file diff --git a/tests/num/identical/ref.typ b/tests/num/identical/ref.typ deleted file mode 100644 index 73894b0..0000000 --- a/tests/num/identical/ref.typ +++ /dev/null @@ -1,14 +0,0 @@ -#set page(width: auto, height: auto, margin: .5em) - -#let th = sym.space.thin -#table( - $10th 220th 001$, - $1times 10^3$, - $-1times 10^(−3)$, - $1 plus.minus 2$, - $(1 plus.minus 2) times 10^1$, - $+2$, - $1.00^(+0.20)_(-0.10)$, - $1(2)$, - $(-2 plus.minus 1) times 10^1$, -) diff --git a/tests/num/identical/test.typ b/tests/num/identical/test.typ deleted file mode 100644 index dd860b2..0000000 --- a/tests/num/identical/test.typ +++ /dev/null @@ -1,15 +0,0 @@ -#set page(width: auto, height: auto, margin: .5em) -#import "/src/zero.typ": num, set-unit, zi - - -#table( - num[10220001], - num[1e3], - num[-1e-3], - num[1+-2], - num[1+-2e1], - num(positive-sign: true)[+2], - num[1.00+.2-0.1], - num(uncertainty-mode: "compact")[1+-2], - num[-2+-1e1], -) diff --git a/tests/num/input-formats/ref.typ b/tests/num/input-formats/ref.typ index 035ef7c..d1ee3a2 100644 --- a/tests/num/input-formats/ref.typ +++ b/tests/num/input-formats/ref.typ @@ -1,9 +1,25 @@ -#import "/src/zero.typ": * #set page(width: auto, height: auto, margin: 2pt) - +$0$ \ +$-0$ \ +$-2.23$ \ +$-2.23$ \ $-2.23$ \ $-2.23$ \ $-2.23$ \ $-112.3$ \ $23×10^2$ + +#pagebreak() + +$0.1$ \ +$0.1$ \ +$2×10^(-1.2)$ \ + +#pagebreak() + +$1$ $2$ + +#pagebreak() + +$+1$ $+2$ diff --git a/tests/num/input-formats/test.typ b/tests/num/input-formats/test.typ index a14b174..6163466 100644 --- a/tests/num/input-formats/test.typ +++ b/tests/num/input-formats/test.typ @@ -1,9 +1,42 @@ #import "/src/zero.typ": * #set page(width: auto, height: auto, margin: 2pt) - +#num[0] \ +#num[-0] \ #num[-2.23] \ +#num[-2,23] \ #num(-2.23) \ #num("-2.23") \ +#num("-2,23") \ #num((mantissa: "-112.3", e: none, pm: none)) \ #num((mantissa: 23, e: "2", pm: none)) + +#pagebreak() + +#num[.1] \ +#num[,1] \ +#num[2e-1,2] \ + + + +#pagebreak() + +// Advanced input + + + +// num with array input +#context { + num(("1", "2")).join(" ") +} + +#pagebreak() + +// num with state input +#context { + let state = impl.num-state.get() + state.positive-sign = true + num("1", state: state) + [ ] + num("2", state: state) +} diff --git a/tests/num/omit-unity-mantissa/.gitignore b/tests/num/omit-unity-mantissa/.gitignore new file mode 100644 index 0000000..2e4c5d8 --- /dev/null +++ b/tests/num/omit-unity-mantissa/.gitignore @@ -0,0 +1,5 @@ +# generated by tytanic, do not edit + +/diff/ +/out/ +/ref/ diff --git a/tests/num/omit-unity-mantissa/ref.typ b/tests/num/omit-unity-mantissa/ref.typ new file mode 100644 index 0000000..dfd297c --- /dev/null +++ b/tests/num/omit-unity-mantissa/ref.typ @@ -0,0 +1,19 @@ +#set page(width: auto, height: auto, margin: 2pt) + +$1×10^9$ \ +$10^9$ \ +$2×10^9$ \ +$(1plus.minus 1)×10^9$ \ +$1$ \ +$10^3$ \ +$1×10^3$ \ + +#pagebreak() + +$1.00×10^2$ \ +$10^2$ \ + +#pagebreak() + +$+10^3$ \ +$-10^3$ \ \ No newline at end of file diff --git a/tests/num/omit-unity-mantissa/test.typ b/tests/num/omit-unity-mantissa/test.typ new file mode 100644 index 0000000..97e9b88 --- /dev/null +++ b/tests/num/omit-unity-mantissa/test.typ @@ -0,0 +1,28 @@ +#import "/src/zero.typ": * +#set page(width: auto, height: auto, margin: 2pt) + + +#num("1e9", omit-unity-mantissa: false) \ +#num("1e9", omit-unity-mantissa: true) \ +#num("2e9", omit-unity-mantissa: true) \ +#num("1+-1e9", omit-unity-mantissa: true) \ +#num("1", omit-unity-mantissa: true) \ +#set-num(omit-unity-mantissa: true) +#num("1e3") \ +#set-num(omit-unity-mantissa: false) +#num("1e3") \ + +#pagebreak() + +// not omitted because mantissa is 1.00 +#num(omit-unity-mantissa: true, exponent: "sci")[100] \ +// but omitted when trailing zeros are trimmed +#num(omit-unity-mantissa: true, exponent: "sci", trim-zeros: true)[100] + + + +#pagebreak() + +// combine signs and omit-unity-mantissa +#num("1e3", positive-sign: true, omit-unity-mantissa: true) \ +#num("-1e3", positive-sign: true, omit-unity-mantissa: true) \ diff --git a/tests/num/positive-sign-exponent/.gitignore b/tests/num/positive-sign-exponent/.gitignore new file mode 100644 index 0000000..2e4c5d8 --- /dev/null +++ b/tests/num/positive-sign-exponent/.gitignore @@ -0,0 +1,5 @@ +# generated by tytanic, do not edit + +/diff/ +/out/ +/ref/ diff --git a/tests/num/positive-sign-exponent/ref.typ b/tests/num/positive-sign-exponent/ref.typ new file mode 100644 index 0000000..c324aab --- /dev/null +++ b/tests/num/positive-sign-exponent/ref.typ @@ -0,0 +1,8 @@ +#set page(width: auto, height: auto, margin: 2pt) + +$1×10^3$ \ +$1×10^(+3)$ \ +$1×10^(-1)$ \ +$1×10^(-1)$ \ +$1×10^(+9)$ \ +$1×10^(9)$ \ diff --git a/tests/num/positive-sign-exponent/test.typ b/tests/num/positive-sign-exponent/test.typ new file mode 100644 index 0000000..ae95e09 --- /dev/null +++ b/tests/num/positive-sign-exponent/test.typ @@ -0,0 +1,12 @@ +#import "/src/zero.typ": * +#set page(width: auto, height: auto, margin: 2pt) + + +#num("1e3", positive-sign-exponent: false) \ +#num("1e3", positive-sign-exponent: true) \ +#num("1e-1", positive-sign-exponent: false) \ +#num("1e-1", positive-sign-exponent: true) \ +#set-num(positive-sign-exponent: true) +#num("1e9") \ +#set-num(positive-sign-exponent: false) +#num("1e9") diff --git a/tests/num/positive-sign/.gitignore b/tests/num/positive-sign/.gitignore new file mode 100644 index 0000000..2e4c5d8 --- /dev/null +++ b/tests/num/positive-sign/.gitignore @@ -0,0 +1,5 @@ +# generated by tytanic, do not edit + +/diff/ +/out/ +/ref/ diff --git a/tests/num/positive-sign/ref.typ b/tests/num/positive-sign/ref.typ new file mode 100644 index 0000000..7720e48 --- /dev/null +++ b/tests/num/positive-sign/ref.typ @@ -0,0 +1,8 @@ +#set page(width: auto, height: auto, margin: 2pt) + +$1$ \ +$+1$ \ +$-1$ \ +$-1$ \ +$+9$ \ +$9$ \ diff --git a/tests/num/positive-sign/test.typ b/tests/num/positive-sign/test.typ new file mode 100644 index 0000000..70ca4ae --- /dev/null +++ b/tests/num/positive-sign/test.typ @@ -0,0 +1,14 @@ +#import "/src/zero.typ": * +#set page(width: auto, height: auto, margin: 2pt) + + + +#num("1", positive-sign: false) \ +#num("1", positive-sign: true) \ +#num("-1", positive-sign: false) \ +#num("-1", positive-sign: true) \ +#set-num(positive-sign: true) +#num("9") \ +#set-num(positive-sign: false) +#num("9") \ + diff --git a/tests/num/power/.gitignore b/tests/num/power/.gitignore new file mode 100644 index 0000000..2e4c5d8 --- /dev/null +++ b/tests/num/power/.gitignore @@ -0,0 +1,5 @@ +# generated by tytanic, do not edit + +/diff/ +/out/ +/ref/ diff --git a/tests/num/power/ref.typ b/tests/num/power/ref.typ new file mode 100644 index 0000000..a92311b --- /dev/null +++ b/tests/num/power/ref.typ @@ -0,0 +1,19 @@ +#set page(width: auto, height: auto, margin: 2pt) + +$2.3×10^3$ \ +$-1.1×10^(-3)$ \ + +#pagebreak() + +$2×10^9$ \ +$2·10^9$ \ +$2·10^9$ \ +$2×10^9$ \ + +#pagebreak() + +$1×2^2$ \ +$1×e^2$ \ +$1×pi^2$ \ +$1×4^2$ \ +$1×10^2$ \ diff --git a/tests/num/power/test.typ b/tests/num/power/test.typ new file mode 100644 index 0000000..eed5d9d --- /dev/null +++ b/tests/num/power/test.typ @@ -0,0 +1,27 @@ +#import "/src/zero.typ": * +#set page(width: auto, height: auto, margin: 2pt) + +#num[2.3e3] \ +#num[-1.1e-3] \ + +#pagebreak() + +// multiplication symbol +#num("2e9") \ +#num("2e9", product: math.dot) \ +#set-num(product: math.dot) +#num("2e9") \ +#set-num(product: math.times) +#num("2e9") \ + +#pagebreak() + + +// base +#num("1e2", base: 2) \ +#num("1e2", base: $e$) \ +#num("1e2", base: $π$) \ +#set-num(base: "4") +#num("1e2") \ +#set-num(base: 10) +#num("1e2") diff --git a/tests/num/rounding/.gitignore b/tests/num/rounding/.gitignore new file mode 100644 index 0000000..2e4c5d8 --- /dev/null +++ b/tests/num/rounding/.gitignore @@ -0,0 +1,5 @@ +# generated by tytanic, do not edit + +/diff/ +/out/ +/ref/ diff --git a/tests/num/rounding/ref.typ b/tests/num/rounding/ref.typ new file mode 100644 index 0000000..e60e111 --- /dev/null +++ b/tests/num/rounding/ref.typ @@ -0,0 +1,44 @@ + +#set page(width: auto, height: auto, margin: .5em) + +$1.23$ \ +$1.24$ \ +$1.1$ \ +$1.10$ \ +$1.19$ \ +$1.20$ \ +$1.19$ \ + +#pagebreak() + +$1.3$ \ +$0.000#sym.space.thin 012$ \ +$9900$ \ +$10#sym.space.thin 000$ \ + +#pagebreak() + +$1.23plus.minus 0.03$ \ +$1.2342plus.minus 0.0003$ \ +$9plus.minus 2$ + +#pagebreak() + +$1.234$ \ + +#pagebreak() + +$1$ + +#pagebreak() + +$0.000$ \ +$0.000$ \ +$0$ \ +$0.000$ \ + +#pagebreak() + +$423.4×10^2$ \ +$4.2×10^4$ \ +$42×10^3$ \ diff --git a/tests/rounding/test.typ b/tests/num/rounding/test.typ similarity index 91% rename from tests/rounding/test.typ rename to tests/num/rounding/test.typ index f85f9d5..5a008d5 100644 --- a/tests/rounding/test.typ +++ b/tests/num/rounding/test.typ @@ -1,5 +1,5 @@ #import "/src/rounding.typ": * -#import "/src/zero.typ": num +#import "/src/zero.typ": num, set-round @@ -286,6 +286,63 @@ #set page(width: auto, height: auto, margin: .5em) +// Places +#set-round(mode: "places", precision: 2) +#num("1.234") \ +#num("1.236") \ +#set-round(pad: false) +#num("1.1") \ +#set-round(pad: true) +#num("1.1") \ +#set-round(direction: "towards-negative-infinity") +#num("1.199") \ +#set-round(direction: "towards-infinity") +#num("1.192") \ +#num("1.190") \ +#set-round(direction: "nearest") + + +#pagebreak() + +// Figures +#set-round(mode: "figures", precision: 2) +#num("1.27") \ +#num("0.00001227") \ +#num("9876") \ +#num("9976") \ + + +#pagebreak() + + +// Uncertainty +#set-round(mode: "uncertainty", precision: 1) +#num("1.234(34)") \ +#num("1.23422(34)") \ +#num("8.8+-2") \ + + +#pagebreak() + + +// Turning off rounding +#set-round(mode: "places") +#num(round: (precision: none), "1.234") \ + + +#pagebreak() + + +// Tie to odd +#set-round(precision: none) +#num(round: (precision: 0, ties: "to-odd"))[.5] + + + +#pagebreak() + + + // Rounding zero #num(round: (precision: 3, mode: "places"))[0] \ #num(round: (precision: 3, mode: "places"))[0.0] \ diff --git a/tests/num/self/ref/1.png b/tests/num/self/ref/1.png deleted file mode 100644 index 927f9de..0000000 Binary files a/tests/num/self/ref/1.png and /dev/null differ diff --git a/tests/num/self/ref/10.png b/tests/num/self/ref/10.png deleted file mode 100644 index 913ad07..0000000 Binary files a/tests/num/self/ref/10.png and /dev/null differ diff --git a/tests/num/self/ref/11.png b/tests/num/self/ref/11.png deleted file mode 100644 index 93b4a71..0000000 Binary files a/tests/num/self/ref/11.png and /dev/null differ diff --git a/tests/num/self/ref/12.png b/tests/num/self/ref/12.png deleted file mode 100644 index 16ce947..0000000 Binary files a/tests/num/self/ref/12.png and /dev/null differ diff --git a/tests/num/self/ref/13.png b/tests/num/self/ref/13.png deleted file mode 100644 index 4538146..0000000 Binary files a/tests/num/self/ref/13.png and /dev/null differ diff --git a/tests/num/self/ref/14.png b/tests/num/self/ref/14.png deleted file mode 100644 index b2db99f..0000000 Binary files a/tests/num/self/ref/14.png and /dev/null differ diff --git a/tests/num/self/ref/15.png b/tests/num/self/ref/15.png deleted file mode 100644 index ac69a90..0000000 Binary files a/tests/num/self/ref/15.png and /dev/null differ diff --git a/tests/num/self/ref/16.png b/tests/num/self/ref/16.png deleted file mode 100644 index fcd98c2..0000000 Binary files a/tests/num/self/ref/16.png and /dev/null differ diff --git a/tests/num/self/ref/17.png b/tests/num/self/ref/17.png deleted file mode 100644 index 026bbee..0000000 Binary files a/tests/num/self/ref/17.png and /dev/null differ diff --git a/tests/num/self/ref/18.png b/tests/num/self/ref/18.png deleted file mode 100644 index c03b002..0000000 Binary files a/tests/num/self/ref/18.png and /dev/null differ diff --git a/tests/num/self/ref/19.png b/tests/num/self/ref/19.png deleted file mode 100644 index ce24c6a..0000000 Binary files a/tests/num/self/ref/19.png and /dev/null differ diff --git a/tests/num/self/ref/2.png b/tests/num/self/ref/2.png deleted file mode 100644 index 4758295..0000000 Binary files a/tests/num/self/ref/2.png and /dev/null differ diff --git a/tests/num/self/ref/20.png b/tests/num/self/ref/20.png deleted file mode 100644 index 1428467..0000000 Binary files a/tests/num/self/ref/20.png and /dev/null differ diff --git a/tests/num/self/ref/21.png b/tests/num/self/ref/21.png deleted file mode 100644 index 1428467..0000000 Binary files a/tests/num/self/ref/21.png and /dev/null differ diff --git a/tests/num/self/ref/22.png b/tests/num/self/ref/22.png deleted file mode 100644 index 516608b..0000000 Binary files a/tests/num/self/ref/22.png and /dev/null differ diff --git a/tests/num/self/ref/3.png b/tests/num/self/ref/3.png deleted file mode 100644 index 3a1010c..0000000 Binary files a/tests/num/self/ref/3.png and /dev/null differ diff --git a/tests/num/self/ref/4.png b/tests/num/self/ref/4.png deleted file mode 100644 index dc85780..0000000 Binary files a/tests/num/self/ref/4.png and /dev/null differ diff --git a/tests/num/self/ref/5.png b/tests/num/self/ref/5.png deleted file mode 100644 index 776f862..0000000 Binary files a/tests/num/self/ref/5.png and /dev/null differ diff --git a/tests/num/self/ref/6.png b/tests/num/self/ref/6.png deleted file mode 100644 index df6d63b..0000000 Binary files a/tests/num/self/ref/6.png and /dev/null differ diff --git a/tests/num/self/ref/7.png b/tests/num/self/ref/7.png deleted file mode 100644 index 24aed39..0000000 Binary files a/tests/num/self/ref/7.png and /dev/null differ diff --git a/tests/num/self/ref/8.png b/tests/num/self/ref/8.png deleted file mode 100644 index 181f8d2..0000000 Binary files a/tests/num/self/ref/8.png and /dev/null differ diff --git a/tests/num/self/ref/9.png b/tests/num/self/ref/9.png deleted file mode 100644 index 70b2f5c..0000000 Binary files a/tests/num/self/ref/9.png and /dev/null differ diff --git a/tests/num/self/test.typ b/tests/num/self/test.typ deleted file mode 100644 index 6ea50c8..0000000 --- a/tests/num/self/test.typ +++ /dev/null @@ -1,327 +0,0 @@ -#import "/src/zero.typ": * -#set page(width: auto, height: auto, margin: .5em) - -#table( - columns: 6, - [`num`], num[12.0], num[-2e3], num[0,222], num("2.2+-0.2"), num("2.2+-0.2e1"), - [Ref], - $12.0$, - $-2 times 10^3$, - $0.222$, - $2.2 plus.minus 0.2$, - $(2.2 plus.minus 0.2) times 10^1$, -) - - -#pagebreak() - -// input formats - -#num[-2.23] \ -#num(-2.23) \ -#num("-2.23") \ - - - -#pagebreak() - -// querbeet - -#num("0") \ -#num("-0") \ -#num("45") \ -#num(".23") \ -#num("1.0") \ -#num(".00002") \ -#num("2e4") \ -#num("-3.1e-1") \ -#num("-3.1+-1.1") \ -#num("2+-1e1") \ - - -#pagebreak() - -// tight - -#let tnum = num.with(tight: true) -#let examples = ("12.2", "2+-3", "4e2", "-2+-1e1") -#table( - columns: 2, - stroke: none, - [`tight: false`], [`tight: true`], - ..array.zip(examples.map(num), examples.map(tnum)).flatten(), -) - - - -#pagebreak() - -// decimal separator (in- and output) - -#num("1.2+-,1") #num("1,2+-.9") \ -#num("2e1.2") #num("2e1,2") - -#set-num(decimal-separator: ",") -#num("1.2+-,1") #num("1,2+-.9") \ -#num("2e1.2") #num("2e1,2") -#set-num(decimal-separator: ".") - -#num("1.234", decimal-separator: ",") \ -#num("1.234", decimal-separator: "__") \ - - - -#pagebreak() - -// multiplication symbol - -#num("2e9") \ -#num("2e9", product: math.dot) \ -#set-num(product: math.dot) -#num("2e9") \ -#set-num(product: math.times) -#num("2e9") \ - - - -#pagebreak() - -// unit mantissa - -#num("1e9", omit-unity-mantissa: false) \ -#num("1e9", omit-unity-mantissa: true) \ -#num("2e9", omit-unity-mantissa: true) \ -#num("1+-1e9", omit-unity-mantissa: true) \ -#num("1", omit-unity-mantissa: true) \ -#set-num(omit-unity-mantissa: true) -#num("1e3") \ -#set-num(omit-unity-mantissa: false) -#num("1e3") \ - - - -#pagebreak() - -// implicit plus - -#num("1", positive-sign: false) -#num("1", positive-sign: true) -#num("-1", positive-sign: false) -#num("-1", positive-sign: true) \ -#set-num(positive-sign: true) -#num("9") -#set-num(positive-sign: false) -#num("9") - - - -#pagebreak() - -// implicit plus exponent - -#num("1e3", positive-sign-exponent: false) -#num("1e3", positive-sign-exponent: true) -#num("1e-1", positive-sign-exponent: false) -#num("1e-1", positive-sign-exponent: true) \ -#set-num(positive-sign-exponent: true) -#num("1e9") -#set-num(positive-sign-exponent: false) -#num("1e9") - - - -#pagebreak() - -// power base - -#num("1e2", base: 2) \ -#num("1e2", base: $e$) \ -#num("1e2", base: $π$) -#set-num(base: "4") -#num("1e2") \ -#set-num(base: 10) -#num("1e2") - - - -#pagebreak() - -// uncertainty mode - -#let examples = ( - "1.7+-.2", - "1.7+-.02", - "1.7+-.28", - "1.7+-2.8", - "1.7(2)", - "1.7(.2)", - "1.7(28)", - "2.2+.2-.5", - "2.2+2-5", - "2.2+2-.5", - "9.99+2-.5", -) - -#table( - columns: 3, - align: center, - stroke: none, - [`separate`], [`compact`], [`compact-separator`], - ..array - .zip( - examples.map(num.with(uncertainty-mode: "separate")), - examples.map(num.with(uncertainty-mode: "compact")), - examples.map(num.with(uncertainty-mode: "compact-separator")), - ) - .flatten(), -) - - - -#pagebreak() - -// digit grouping - -#num("10.10") \ -#num("123.321") \ -#num("1234.4321") \ -#num("12345.54321") \ -#num("1234567") \ -#set-group(threshold: calc.inf) -#num("1234567") \ -#set-group(threshold: 3) -#num("1234.4321") \ -#set-group(separator: "'", size: 2) -#num("12345.54321") \ -#set-group(separator: sym.space.thin, size: 3, threshold: 5) - - - -#pagebreak() - -// rounding - -#num("1.234") \ -#set-round(mode: "places", precision: 2) -#num("1.234") \ -#num("1.236") \ -#set-round(pad: false) -#num("1.1") \ -#set-round(pad: true) -#num("1.1") \ -#set-round(direction: "towards-negative-infinity") -#num("1.199") \ -#set-round(direction: "towards-infinity") -#num("1.192") \ -#num("1.190") \ -#set-round(direction: "nearest") - -#set-round(mode: "figures", precision: 2) -#num("1.27") \ -#num("0.00001227") \ -#num("9876") \ -#num("9976") \ - -#set-round(mode: "uncertainty", precision: 1) -#num("1.234(34)") \ -#num("8.8+-2") \ - -#set-round(mode: "places") -#num(round: (precision: none), "1.234") -#set-round(precision: none) - -#num(round: (precision: 0, ties: "to-odd"))[.5] - - - -#pagebreak() - -// digits - -#num("1.234", digits: 2) \ -#num("1.2", digits: 2) - - - -#pagebreak() - -// fixed exponent - -#num("1.234", exponent: (fixed: -2)) \ -#num("1.234", exponent: (fixed: 1)) \ -#num("1e4", exponent: (fixed: 1)) \ -#num("1e-4", exponent: (fixed: -1)) \ -#num("2+-1", exponent: (fixed: 1)) \ -#num("2+-1e1", exponent: (fixed: 2)) \ - - - -#pagebreak() - -// combine positive-sign and omit-unity-mantissa -#num("1e3", positive-sign: true, omit-unity-mantissa: true) \ -#num("-1e3", positive-sign: true, omit-unity-mantissa: true) \ - -// combine "compact" and exponential -#num("2.1+-.2e1", uncertainty-mode: "compact") \ -#num("2.1+.2-.2e1", uncertainty-mode: "separate") - - -#pagebreak() - -// content input - -#num[.1] -#num[,1] -#num[2e-1,2] - -#pagebreak() - -// Mode math: false - -#[ - #show math.equation: set text(2pt) - #num(math: false)[2,3+-23e2]\ - #num(math: false, product: sym.dot)[2,3+.3-.4e2] -] - -#pagebreak() - -// num with manual state - -#[ - #let state = impl.default-state - #{ state.decimal-separator = "," } - #let num = num.with(state: state) - #num[2.34] -] - -#pagebreak() - -// num with array input - -#context { - num(("1", "2")).join(" ") -} - -#pagebreak() - -// num with state input - -#context { - let state = impl.num-state.get() - num("1", state: state) - [ ] - num("2", state: state) -} - -#pagebreak() - -#num( - group: (threshold: (fractional: 3, integer: calc.inf)), - [23232.2323], -) \ -#num( - group: (threshold: (integer: 3, fractional: calc.inf)), - [23232.2323], -) diff --git a/tests/num/uncertainty/.gitignore b/tests/num/uncertainty/.gitignore new file mode 100644 index 0000000..2e4c5d8 --- /dev/null +++ b/tests/num/uncertainty/.gitignore @@ -0,0 +1,5 @@ +# generated by tytanic, do not edit + +/diff/ +/out/ +/ref/ diff --git a/tests/num/uncertainty/ref.typ b/tests/num/uncertainty/ref.typ new file mode 100644 index 0000000..32d5591 --- /dev/null +++ b/tests/num/uncertainty/ref.typ @@ -0,0 +1,65 @@ +#set page(width: auto, height: auto, margin: 2pt) +#import "/src/formatting.typ": non-math-attach + + + +#table( + columns: 3, + align: center, + stroke: none, + [`separate`], [`compact`], [`compact-separator`], + $1.7±0.2$, $1.7(2)$, $1.7(2)$, + $1.70±0.02$, $1.70(2)$, $1.70(2)$, + $1.70±0.28$, $1.70(28)$, $1.70(28)$, + $1.7±2.8$, $1.7(28)$, $1.7(2.8)$, + + $1.7±0.2$, $1.7(2)$, $1.7(2)$, + $1.70±0.02$, $1.70(2)$, $1.70(2)$, + $1.7±2.8$, $1.7(28)$, $1.7(2.8)$, + + $2.2^(+0.2)_(-0.5)$, $2.2^(+2)_(-5)$, $2.2^(+2)_(-5)$, + $2.2^(+2.0)_(-5.0)$, $2.2^(+20)_(-50)$, $2.2^(+2.0)_(-5.0)$, + $2.2^(+2.0)_(-0.5)$, $2.2^(+20)_(-5)$, $2.2^(+2.0)_(-0.5)$, + $9.99^(+2.00)_(-0.50)$, $9.99^(+200)_(-50)$, $9.99^(+2.00)_(-0.50)$, +) + + +#pagebreak() + + + +#let th = sym.space.thin + +#context table( + columns: 3, + align: center, + stroke: none, + [`separate`], [`compact`], [`compact-separator`], + [1.7#th;±#th;0.2], [1.7(2)], [1.7(2)], + [1.70#th;±#th;0.02], [1.70(2)], [1.70(2)], + [1.70#th;±#th;0.28], [1.70(28)], [1.70(28)], + [1.7#th;±#th;2.8], [1.7(28)], [1.7(2.8)], + + [1.7#th;±#th;0.2], [1.7(2)], [1.7(2)], + [1.70#th;±#th;0.02], [1.70(2)], [1.70(2)], + [1.7#th;±#th;2.8], [1.7(28)], [1.7(2.8)], + + non-math-attach([2.2], t: [+0.2], b: [-0.5]), + non-math-attach([2.2], t: [+2], b: [-5]), + non-math-attach([2.2], t: [+2], b: [-5]), + non-math-attach([2.2], t: [+2.0], b: [-5.0]), + non-math-attach([2.2], t: [+20], b: [-50]), + non-math-attach([2.2], t: [+2.0], b: [-5.0]), + non-math-attach([2.2], t: [+2.0], b: [-0.5]), + non-math-attach([2.2], t: [+20], b: [-5]), + non-math-attach([2.2], t: [+2.0], b: [-0.5]), + non-math-attach([9.99], t: [+2.00], b: [-0.50]), + non-math-attach([9.99], t: [+200], b: [-50]), + non-math-attach([9.99], t: [+2.00], b: [-0.50]), +) + +#pagebreak() + +$(2.1plus.minus 0.2)×10^1$ \ +$2.1(2)×10^1$ \ +$\(2.1^(+0.2)_(-0.2)\)×10^1$ \ diff --git a/tests/num/uncertainty/test.typ b/tests/num/uncertainty/test.typ new file mode 100644 index 0000000..aafe232 --- /dev/null +++ b/tests/num/uncertainty/test.typ @@ -0,0 +1,67 @@ +#import "/src/zero.typ": * +#set page(width: auto, height: auto, margin: 2pt) + + + + +// uncertainty mode + +#let examples = ( + "1.7+-.2", + "1.7+-.02", + "1.7+-.28", + "1.7+-2.8", + "1.7(2)", + "1.7(.2)", + "1.7(28)", + "2.2+.2-.5", + "2.2+2-5", + "2.2+2-.5", + "9.99+2-.5", +) + +#table( + columns: 3, + align: center, + stroke: none, + [`separate`], [`compact`], [`compact-separator`], + ..array + .zip( + examples.map(num.with(uncertainty-mode: "separate")), + examples.map(num.with(uncertainty-mode: "compact")), + examples.map(num.with(uncertainty-mode: "compact-separator")), + ) + .flatten(), +) + + +#pagebreak() + + +#set-num(math: false) + + +#table( + columns: 3, + align: center, + stroke: none, + [`separate`], [`compact`], [`compact-separator`], + ..array + .zip( + examples.map(num.with(uncertainty-mode: "separate")), + examples.map(num.with(uncertainty-mode: "compact")), + examples.map(num.with(uncertainty-mode: "compact-separator")), + ) + .flatten(), +) + + +#pagebreak() + + +#set-num(math: true) + +// combine "compact" and exponential +#num("2.1+-.2e1", uncertainty-mode: "separate") \ +#num("2.1+-.2e1", uncertainty-mode: "compact") \ +#num("2.1+.2-.2e1", uncertainty-mode: "separate") diff --git a/tests/rounding/ref.typ b/tests/rounding/ref.typ deleted file mode 100644 index 17c3051..0000000 --- a/tests/rounding/ref.typ +++ /dev/null @@ -1,14 +0,0 @@ - -#set page(width: auto, height: auto, margin: .5em) - - -$0.000$ \ -$0.000$ \ -$0$ \ -$0.000$ \ - -#pagebreak() - -$423.4×10^2$ \ -$4.2×10^4$ \ -$42×10^3$ \ diff --git a/tests/rtl/.gitignore b/tests/rtl/.gitignore new file mode 100644 index 0000000..2e4c5d8 --- /dev/null +++ b/tests/rtl/.gitignore @@ -0,0 +1,5 @@ +# generated by tytanic, do not edit + +/diff/ +/out/ +/ref/ diff --git a/tests/rtl/ref.typ b/tests/rtl/ref.typ new file mode 100644 index 0000000..005f68a --- /dev/null +++ b/tests/rtl/ref.typ @@ -0,0 +1,7 @@ +#set page(width: auto, height: auto, margin: .5em) + +#set text(dir: rtl) + +#let th = sym.space.thin +$1,#h(0pt)2$ \ +$"N"th"A"^(-2)th 2.1$ \ No newline at end of file diff --git a/tests/rtl/ref/1.png b/tests/rtl/ref/1.png deleted file mode 100644 index ebdc61b..0000000 Binary files a/tests/rtl/ref/1.png and /dev/null differ diff --git a/tests/rtl/test.typ b/tests/rtl/test.typ index ee72054..e48678c 100644 --- a/tests/rtl/test.typ +++ b/tests/rtl/test.typ @@ -4,4 +4,5 @@ #set text(dir: rtl) -#num(decimal-separator: ",")[1,2] +#num(decimal-separator: ",")[1,2] \ +#zi.N-A2[2.1] diff --git a/tests/table/ref/1.png b/tests/table/format/ref/1.png similarity index 100% rename from tests/table/ref/1.png rename to tests/table/format/ref/1.png diff --git a/tests/table/ref/2.png b/tests/table/format/ref/2.png similarity index 100% rename from tests/table/ref/2.png rename to tests/table/format/ref/2.png diff --git a/tests/table/ref/3.png b/tests/table/format/ref/3.png similarity index 100% rename from tests/table/ref/3.png rename to tests/table/format/ref/3.png diff --git a/tests/table/ref/4.png b/tests/table/format/ref/4.png similarity index 100% rename from tests/table/ref/4.png rename to tests/table/format/ref/4.png diff --git a/tests/table/ref/5.png b/tests/table/format/ref/5.png similarity index 100% rename from tests/table/ref/5.png rename to tests/table/format/ref/5.png diff --git a/tests/table/ref/6.png b/tests/table/format/ref/6.png similarity index 100% rename from tests/table/ref/6.png rename to tests/table/format/ref/6.png diff --git a/tests/table/ref/7.png b/tests/table/format/ref/7.png similarity index 100% rename from tests/table/ref/7.png rename to tests/table/format/ref/7.png diff --git a/tests/table/ref/8.png b/tests/table/format/ref/8.png similarity index 100% rename from tests/table/ref/8.png rename to tests/table/format/ref/8.png diff --git a/tests/table/test.typ b/tests/table/format/test.typ similarity index 100% rename from tests/table/test.typ rename to tests/table/format/test.typ diff --git a/tests/nonum/ref/1.png b/tests/table/nonum/ref/1.png similarity index 100% rename from tests/nonum/ref/1.png rename to tests/table/nonum/ref/1.png diff --git a/tests/nonum/test.typ b/tests/table/nonum/test.typ similarity index 100% rename from tests/nonum/test.typ rename to tests/table/nonum/test.typ diff --git a/tests/zi/basic/ref.typ b/tests/zi/basic/ref.typ new file mode 100644 index 0000000..daf0c09 --- /dev/null +++ b/tests/zi/basic/ref.typ @@ -0,0 +1,85 @@ +#set page(width: auto, height: auto, margin: .5em) +#set table(stroke: none) + + + +#let th = sym.space.thin + +$12th"N"$ \ +$12th"m"th"s"^(-1)$ \ +$12th"kg"$ \ +$23th"cd"$ \ +$23#sym.prime$ \ +$23#sym.prime.double$ \ +$23th"kN"$ \ +$45°$ \ +$2th"s"^(-1)$ \ +$"kN"$ \ +$1/"s"$ \ +$1\/"s"$ \ +$12th"µm"$ \ + +#pagebreak() + +$"kg"th"m"$ \ +$2th"kg"th"m"$ \ + +#pagebreak() + + +#table( + columns: 2, + $"V""·""m""·""s"^(-1)$, + $1.2th"V""·""m""·""s"^(-1)$, + $("V"th"m")/"s"$, + $1.2th ("V"th"m")/"s"$, + $"V"th"m"\/"s"$, + $1.2th"V"th"m"\/"s"$, + $"V""·""m"\/"s"$, + $1.2th"V""·""m"\/"s"$, + $("V""·""m")/"s"$, + $1.2th ("V""·""m")/"s"$, +) + + +#pagebreak() + + +#table( + columns: 2, + $"kg""·""m"$, + $2th"kg""·""m"$, + $"kg""·""m"$, + $2th"kg""·""m"$, + $"kg""·""m"$, + $2th"kg""·""m"$, +) + +#pagebreak() + +$(2plus.minus 2)th"m"th"s"^(-1)$ \ +$(2plus.minus 2)×10^3th"m"th"s"^(-1)$ \ +$2(1)th"m"th"s"^(-1)$ \ +$2(1)th"m"th"s"^(-1)$ \ +$(0.20plus.minus 0.11)×10^1th"m"th"s"^(-1)$ \ + +#pagebreak() + +#set super(typographic: false) +2#th;m \ +2#th;m#th;s#super[-1] \ +2#th;m/s \ +2#th;m#th;s#super[-1]#th;V#super[-2] \ +2#th;m/(s#th;V#super[2]) \ + +#pagebreak() + +$"m"\/"s"$ \ +$"m"^3th√"b"th"c"^(-0.5)$ \ +$("m"^3th√"b")/√"c"$ \ +$"m"^3th√"b"\/√"c"$ \ + +#pagebreak() + +1#th;m \ +m \ diff --git a/tests/zi/basic/ref/1.png b/tests/zi/basic/ref/1.png deleted file mode 100644 index f4785ae..0000000 Binary files a/tests/zi/basic/ref/1.png and /dev/null differ diff --git a/tests/zi/basic/ref/2.png b/tests/zi/basic/ref/2.png deleted file mode 100644 index 822ba44..0000000 Binary files a/tests/zi/basic/ref/2.png and /dev/null differ diff --git a/tests/zi/basic/ref/3.png b/tests/zi/basic/ref/3.png deleted file mode 100644 index 778182e..0000000 Binary files a/tests/zi/basic/ref/3.png and /dev/null differ diff --git a/tests/zi/basic/ref/4.png b/tests/zi/basic/ref/4.png deleted file mode 100644 index 81e8da2..0000000 Binary files a/tests/zi/basic/ref/4.png and /dev/null differ diff --git a/tests/zi/basic/ref/5.png b/tests/zi/basic/ref/5.png deleted file mode 100644 index e8f80dd..0000000 Binary files a/tests/zi/basic/ref/5.png and /dev/null differ diff --git a/tests/zi/basic/ref/6.png b/tests/zi/basic/ref/6.png deleted file mode 100644 index 5d1aaa7..0000000 Binary files a/tests/zi/basic/ref/6.png and /dev/null differ diff --git a/tests/zi/basic/ref/7.png b/tests/zi/basic/ref/7.png deleted file mode 100644 index 82bb8fe..0000000 Binary files a/tests/zi/basic/ref/7.png and /dev/null differ diff --git a/tests/zi/basic/ref/8.png b/tests/zi/basic/ref/8.png deleted file mode 100644 index 5737e04..0000000 Binary files a/tests/zi/basic/ref/8.png and /dev/null differ diff --git a/tests/zi/basic/ref/9.png b/tests/zi/basic/ref/9.png deleted file mode 100644 index 36c4617..0000000 Binary files a/tests/zi/basic/ref/9.png and /dev/null differ diff --git a/tests/zi/basic/test.typ b/tests/zi/basic/test.typ index a8c8854..828450b 100644 --- a/tests/zi/basic/test.typ +++ b/tests/zi/basic/test.typ @@ -14,25 +14,20 @@ #zi.degree[45] \ // #zi.liter-l[1] \ #zi.declare("1/s")([2]) \ - -#zi.kN() // later make them types maybe? Then we can just call #zi.kN, that looks much better - -#zi.declare("1/s")(fraction: "fraction") -#zi.declare("1/s")(fraction: "inline") - +#zi.kN() \ // later make them types maybe? Then we can just call #zi.kN, that looks much better +#zi.declare("1/s")(fraction: "fraction") \ +#zi.declare("1/s")(fraction: "inline") \ #let um = zi.declare("mum") #um[12] #pagebreak() -// #set page(width: 4cm) // Unit declaration #let kgm-s2 = zi.declare("kg m/s^2") #let kgm-s2 = zi.declare("kg m") #kgm-s2() \ -$"kg" thin "m"$ \ #kgm-s2[2] @@ -69,25 +64,15 @@ $"kg" thin "m"$ \ -#set page(width: 2cm) -Hello #zi.m-s[2.2] - -Hello #zi.m-s(breakable: true)[2.2] - -A #kgm-s2() -A #kgm-s2(breakable: true) - #pagebreak() #set page(width: auto) -#table( - zi.m-s("2+-2"), - zi.m-s("2+-2e3"), - zi.m-s(uncertainty-mode: "compact", "2+-1"), - zi.m-s(uncertainty-mode: "compact-separator", "2+-1"), - zi.m-s(exponent: (fixed: 1), "2+-1.1"), -) +#zi.m-s("2+-2") \ +#zi.m-s("2+-2e3") \ +#zi.m-s(uncertainty-mode: "compact", "2+-1") \ +#zi.m-s(uncertainty-mode: "compact-separator", "2+-1") \ +#zi.m-s(exponent: (fixed: 1), "2+-1.1") \ #pagebreak() @@ -95,23 +80,20 @@ A #kgm-s2(breakable: true) #let m-s-V = zi.declare("m/s/V^2") -#table( - zi.m(fraction: "power", math: false)[2], - zi.m-s(fraction: "power", math: false)[2], - zi.m-s(fraction: "inline", math: false)[2], - m-s-V(fraction: "power", math: false)[2], - m-s-V(fraction: "inline", math: false)[2], -) + +#zi.m(fraction: "power", math: false)[2] \ +#zi.m-s(fraction: "power", math: false)[2] \ +#zi.m-s(fraction: "inline", math: false)[2] \ +#m-s-V(fraction: "power", math: false)[2] \ +#m-s-V(fraction: "inline", math: false)[2] \ #pagebreak() #set-unit(use-sqrt: true, fraction: "inline") -#zi.m-s() -#table( - zi.declare("m^3 b^0.5/c^0.5")(fraction: "power"), - zi.declare("m^3 b^0.5/c^0.5")(fraction: "fraction"), - zi.declare("m^3 b^0.5/c^0.5")(fraction: "inline"), -) +#zi.m-s() \ +#zi.declare("m^3 b^0.5/c^0.5")(fraction: "power") \ +#zi.declare("m^3 b^0.5/c^0.5")(fraction: "fraction") \ +#zi.declare("m^3 b^0.5/c^0.5")(fraction: "inline") \ #pagebreak()