Add testing guide and update README with testing section

This commit is contained in:
2026-04-05 09:35:17 +03:00
parent a1618f39bb
commit f1998acfe3
2 changed files with 101 additions and 0 deletions
+4
View File
@@ -58,6 +58,10 @@ See [`docs/cheatsheet.md`](docs/cheatsheet.md) for a map of Finnish grammatical
| `examples/async/` | DOM click handlers, mutable state | | `examples/async/` | DOM click handlers, mutable state |
| `examples/program/` | Capstone combining recursion and list iteration | | `examples/program/` | Capstone combining recursion and list iteration |
## Testing
See [`docs/testing.md`](docs/testing.md) for a step-by-step guide to verifying each example.
## Local Setup (without Docker) ## Local Setup (without Docker)
See [`docs/install.md`](docs/install.md) for instructions on installing `libvoikko` and `tampio` natively. See [`docs/install.md`](docs/install.md) for instructions on installing `libvoikko` and `tampio` natively.
+97
View File
@@ -0,0 +1,97 @@
# Testing the Examples
## Build and serve
```sh
make
python3 -m http.server 9994 --directory examples
```
Open `http://localhost:9994/basics/index.html` for the full index, or test each example directly below.
---
## basics/hello.html
`http://localhost:9994/basics/hello.html`
- Page loads → browser alert says **Hei maailma!**
---
## basics/factorial.html
`http://localhost:9994/basics/factorial.html`
- Page loads → prompt appears
- Enter `5` → alert shows **120**
- Enter `0` → alert shows **1**
---
## basics/fibonacci.html
`http://localhost:9994/basics/fibonacci.html`
- Page loads → prompt appears
- Enter `10` → alert shows **55**
- Enter `1` → alert shows **1**
---
## data-structures/lista.html
`http://localhost:9994/data-structures/lista.html`
- Right panel shows the list `[3, 1, 4, 1, 5]`
- Size: **5**, first element: **3**
- Ascending sort: **1 1 3 4 5**
- Descending sort: **5 4 3 1 1**
---
## data-structures/vektori.html
`http://localhost:9994/data-structures/vektori.html`
- Dimension: **2**
- Sum: **7**
- Length (3-4-5 triangle): **5**
---
## strings/merkkijono.html
`http://localhost:9994/strings/merkkijono.html`
- Merkkijono: **Hei, Tampio!**
- Pituus: **12**
- Yhdistetty: **Hei, Tampio! Vuosi 2026.**
- Siistitty: **'välilyönnit poistuvat'**
- Hedelmät: **omena banaani kiivi**
---
## async/nappi.html
`http://localhost:9994/async/nappi.html`
- Two buttons visible: **+1** and **+10**
- Click **+1** → one `▪` dot appears
- Click **+10** → ten `▪` dots appear
- Dots accumulate across clicks
---
## program/kasvutaulukko.html
`http://localhost:9994/program/kasvutaulukko.html`
- **Kertoma (n!)** section shows: `1 1 2 6 24 120 720`
- **Fibonacci-kani (fib(n))** section shows: `1 1 2 3 5 8 13`
---
## Checking for errors
Open browser DevTools (`F12` → Console) on any page and verify no red errors appear. The only expected output is from the examples themselves.