Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Allow nested tests #245

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading