Added ./scripts/play.fun to interactive run thrue all examples in ./examples/. (0.40.6)
This commit is contained in:
parent
587bb76108
commit
5eb5cd7348
10 changed files with 275 additions and 141 deletions
|
|
@ -4,7 +4,7 @@ published: true
|
|||
noToc: false
|
||||
noComments: false
|
||||
noDate: false
|
||||
title: Fun - Running the Examples
|
||||
title: Running the Examples
|
||||
subtitle: How to run the examples and the interactive showcase script, with environment tips.
|
||||
description: How to run the examples and the interactive showcase script, with environment tips.
|
||||
permalink: /documentation/examples/
|
||||
|
|
@ -21,7 +21,6 @@ tags:
|
|||
- tips
|
||||
---
|
||||
|
||||
|
||||
This page shows how to run the example programs included with the repository and how to use the interactive showcase script.
|
||||
|
||||
All commands assume you are in the repository root.
|
||||
|
|
@ -33,33 +32,33 @@ All commands assume you are in the repository root.
|
|||
|
||||
Example (Linux/macOS/BSD):
|
||||
|
||||
<pre>FUN_LIB_DIR="$(pwd)/lib" ./build/fun examples/include_lib.fun
|
||||
</pre>
|
||||
<pre>FUN_LIB_DIR="$(pwd)/lib" ./build/fun examples/include_lib.fun</pre>
|
||||
|
||||
Windows (PowerShell):
|
||||
|
||||
<pre>$env:FUN_LIB_DIR = "$PWD/lib"
|
||||
./build/fun.exe .\examples\include_lib.fun
|
||||
</pre>
|
||||
./build/fun.exe .\examples\include_lib.fun</pre>
|
||||
|
||||
## Interactive showcase: play.fun
|
||||
|
||||
The script `./play.fun` discovers all `.fun` files under `./examples` and offers to run them one by one:
|
||||
The script `./scripts/play.fun` discovers all `.fun` files under `./examples` and offers to run them one by one:
|
||||
|
||||
<pre>./scripts/play.fun</pre>
|
||||
|
||||
<pre>./play.fun
|
||||
</pre>
|
||||
Notes:
|
||||
|
||||
- The script auto-picks your interpreter (FUN_BIN env or `fun` in PATH) and ensures `FUN_LIB_DIR=./lib` so examples resolve includes correctly.
|
||||
- It shows the exit code for each run and summarizes failures at the end.
|
||||
|
||||
Tip: you can run specific examples directly too:
|
||||
|
||||
<pre>FUN_LIB_DIR="$(pwd)/lib" fun examples/crypto/openssl_md5.fun
|
||||
</pre>
|
||||
<pre>FUN_LIB_DIR="$(pwd)/lib" fun examples/crypto/openssl_md5.fun</pre>
|
||||
|
||||
## Example categories
|
||||
|
||||
Browse the `examples/` tree for areas of interest:
|
||||
|
||||
- crypto — crypto demonstrations (e.g., OpenSSL MD5/SHA-256/SHA-512 helpers; requires build with `-DFUN_WITH_OPENSSL=ON`)
|
||||
- crypto — crypto demonstrations (e.g., OpenSSL MD5/SHA-256/SHA-512/RIPEMD‑160 helpers; requires build with `-DFUN_WITH_OPENSSL=ON`)
|
||||
- blocking / interactive — I/O or user-interactive patterns
|
||||
- error / broken — negative tests and error showcases
|
||||
- math — numeric operations
|
||||
|
|
@ -70,6 +69,6 @@ Browse the `examples/` tree for areas of interest:
|
|||
Place your `.fun` files anywhere under `examples/` to have them picked up by `play.fun`. Use quoted includes for project-local helpers and angle brackets for stdlib modules:
|
||||
|
||||
<pre>#include "examples/my_lib/common.fun"
|
||||
#include <io/console.fun>
|
||||
</pre>
|
||||
#include <io/console.fun></pre>
|
||||
|
||||
If you add an example showcasing a new feature, also consider adding a brief note to the relevant doc (types.md, includes.md, opcodes.md, etc.).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue