Skip to content

Commit

Permalink
Merge pull request #245 from johannes-wolf/scripts-nested-dir
Browse files Browse the repository at this point in the history
tests: Allow nested tests
  • Loading branch information
johannes-wolf authored Oct 9, 2023
2 parents c2c4fc9 + 775913a commit 282e400
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 18 deletions.
6 changes: 3 additions & 3 deletions scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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} ..."

Expand Down Expand Up @@ -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 {}'
Expand Down
Binary file added tests/plot/parametric/ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions tests/plot/parametric/test.typ
Original file line number Diff line number Diff line change
@@ -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)
})
}))
Binary file modified tests/plot/ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 0 additions & 15 deletions tests/plot/test.typ
Original file line number Diff line number Diff line change
Expand Up @@ -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: *
Expand Down

0 comments on commit 282e400

Please sign in to comment.