diff --git a/scripts/test b/scripts/test index 923ee54d..cec1d5ab 100755 --- a/scripts/test +++ b/scripts/test @@ -18,7 +18,7 @@ while :; do done -TYPST_VERSION="v0.6.0" +TYPST_VERSION="v0.8.0" TYPST_BASE_URL="https://github.com/typst/typst/releases/download" TYPST_ARCHIVE="typst-x86_64-unknown-linux-musl.tar.xz" @@ -117,7 +117,7 @@ function run_test() if ( cd "$1" local NAME - NAME="$(basename "$1")" + NAME="$(realpath "$1" --relative-to "$TEST_ROOT")" echo "[TEST] ${NAME} ..." @@ -152,7 +152,7 @@ if ! hash parallel 2>/dev/null; then fi function tests() { - find "$TEST_ROOT" -type d + find "$TEST_ROOT" -type f -name "test.typ" -exec dirname {} \; } if [[ "$MODE" == "test" ]]; then tests | parallel 'run_test {}' diff --git a/tests/plot/parametric/ref.png b/tests/plot/parametric/ref.png new file mode 100644 index 00000000..1716661e Binary files /dev/null and b/tests/plot/parametric/ref.png differ diff --git a/tests/plot/parametric/test.typ b/tests/plot/parametric/test.typ new file mode 100644 index 00000000..e1b48325 --- /dev/null +++ b/tests/plot/parametric/test.typ @@ -0,0 +1,50 @@ +#set page(width: auto, height: auto) +#import "/src/lib.typ": * + +/* Simple plot */ +#box(stroke: 2pt + red, canvas({ + import draw: * + + plot.plot(size: (4, 4), + x-tick-step: 1, + y-tick-step: 1, + { + plot.add((t) => (calc.cos(t * 1rad), calc.sin(t * 1rad)), + domain: (0, 2 * calc.pi)) + }) +})) + +/* Test clipping */ +#box(stroke: 2pt + red, canvas({ + import draw: * + + plot.plot(size: (4, 4), + x-min: -1, x-max: 1, + y-min: -1, y-max: 1, + x-tick-step: 1, + y-tick-step: 1, + { + plot.add((t) => (calc.cos(t * 1rad) + .5, calc.sin(t * 1rad)), + domain: (0, 2 * calc.pi)) + plot.add((t) => (calc.cos(t * 1rad) - .5, calc.sin(t * 1rad)), + domain: (0, 2 * calc.pi)) + plot.add((t) => (calc.cos(t * 1rad), calc.sin(t * 1rad) + .5), + domain: (0, 2 * calc.pi)) + plot.add((t) => (calc.cos(t * 1rad), calc.sin(t * 1rad) - .5), + domain: (0, 2 * calc.pi)) + }) +})) + +/* Test filling */ +#box(stroke: 2pt + red, canvas({ + import draw: * + + plot.plot(size: (4, 4), + x-tick-step: 1, + y-tick-step: 1, + { + plot.add((t) => (calc.cos(t * 1rad), calc.sin(t * 1rad)), + domain: (0, 2 * calc.pi), + fill: true) + }) +})) diff --git a/tests/plot/ref.png b/tests/plot/ref.png index c7088686..4cea1b22 100644 Binary files a/tests/plot/ref.png and b/tests/plot/ref.png differ diff --git a/tests/plot/test.typ b/tests/plot/test.typ index dfe3c56e..b2d02c71 100644 --- a/tests/plot/test.typ +++ b/tests/plot/test.typ @@ -245,21 +245,6 @@ mark: (start: ">", end: ">"), name: "amplitude") })) -/* Something cool */ -#box(stroke: 2pt + red, canvas({ - import draw: * - - plot.plot(size: (10, 4), - x-min: -.8, - x-grid: "major", - y-grid: "major", - { - plot.add(samples: 100, domain: (-2 * calc.pi, 2 * calc.pi), t => - (calc.cos(t) / (calc.pow(calc.sin(t), 2) + 1), - calc.cos(t) * calc.sin(t) / (calc.pow(calc.sin(t), 2) + 1))) - }) -})) - /* Custom sample points */ #box(stroke: 2pt + red, canvas({ import draw: *