Add Map<String, V> as a first-class built-in type for key-value storage, needed for self-hosting the compiler (parser/typechecker/interpreter all rely heavily on hashmaps). - types.rs: Type::Map(K,V) variant, all match arms (unify, apply, etc.) - interpreter.rs: Value::Map, 12 BuiltinFn variants (new/set/get/contains/ remove/keys/values/size/isEmpty/fromList/toList/merge), immutable semantics - typechecker.rs: Map<K,V> resolution in resolve_type - js_backend.rs: Map as JS Map with emit_map_operation() - c_backend.rs: LuxMap struct (linear-scan), runtime fns, emit_map_operation() - main.rs: 12 tests covering all Map operations - validate.sh: now checks all projects/ directories too Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
94 lines
3.0 KiB
Bash
Executable File
94 lines
3.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Lux Full Validation Script
|
|
# Runs all checks: Rust tests, package tests, type checking, formatting, linting.
|
|
# Run after every committable change to ensure no regressions.
|
|
|
|
# cd to repo root (directory containing this script's parent)
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
cd "$SCRIPT_DIR/.."
|
|
|
|
LUX="$(pwd)/target/release/lux"
|
|
PACKAGES_DIR="$(pwd)/../packages"
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
CYAN='\033[0;36m'
|
|
BOLD='\033[1m'
|
|
NC='\033[0m'
|
|
|
|
FAILED=0
|
|
TOTAL=0
|
|
|
|
step() {
|
|
TOTAL=$((TOTAL + 1))
|
|
printf "${CYAN}[%d]${NC} %s... " "$TOTAL" "$1"
|
|
}
|
|
|
|
ok() { printf "${GREEN}ok${NC} %s\n" "${1:-}"; }
|
|
fail() { printf "${RED}FAIL${NC} %s\n" "${1:-}"; FAILED=$((FAILED + 1)); }
|
|
|
|
# --- Rust checks ---
|
|
step "cargo check"
|
|
if nix develop --command cargo check 2>&1 | grep -q "Finished"; then ok; else fail; fi
|
|
|
|
step "cargo test"
|
|
OUTPUT=$(nix develop --command cargo test 2>&1 || true)
|
|
RESULT=$(echo "$OUTPUT" | grep "test result:" || echo "no result")
|
|
if echo "$RESULT" | grep -q "0 failed"; then ok "$RESULT"; else fail "$RESULT"; fi
|
|
|
|
# --- Build release binary ---
|
|
step "cargo build --release"
|
|
if nix develop --command cargo build --release 2>&1 | grep -q "Finished"; then ok; else fail; fi
|
|
|
|
# --- Package tests ---
|
|
for pkg in path frontmatter xml rss markdown; do
|
|
PKG_DIR="$PACKAGES_DIR/$pkg"
|
|
if [ -d "$PKG_DIR" ]; then
|
|
step "lux test ($pkg)"
|
|
OUTPUT=$(cd "$PKG_DIR" && "$LUX" test 2>&1 || true)
|
|
RESULT=$(echo "$OUTPUT" | grep "passed" | tail -1 || echo "no result")
|
|
if echo "$RESULT" | grep -q "passed"; then ok "$RESULT"; else fail "$RESULT"; fi
|
|
fi
|
|
done
|
|
|
|
# --- Lux check on packages ---
|
|
for pkg in path frontmatter xml rss markdown; do
|
|
PKG_DIR="$PACKAGES_DIR/$pkg"
|
|
if [ -d "$PKG_DIR" ]; then
|
|
step "lux check ($pkg)"
|
|
OUTPUT=$(cd "$PKG_DIR" && "$LUX" check 2>&1 || true)
|
|
RESULT=$(echo "$OUTPUT" | grep "passed" | tail -1 || echo "no result")
|
|
if echo "$RESULT" | grep -q "passed"; then ok; else fail "$RESULT"; fi
|
|
fi
|
|
done
|
|
|
|
# --- Project checks ---
|
|
PROJECTS_DIR="$(pwd)/projects"
|
|
for proj_dir in "$PROJECTS_DIR"/*/; do
|
|
proj=$(basename "$proj_dir")
|
|
if [ -f "$proj_dir/main.lux" ]; then
|
|
step "lux check (project: $proj)"
|
|
OUTPUT=$("$LUX" check "$proj_dir/main.lux" 2>&1 || true)
|
|
if echo "$OUTPUT" | grep -qi "error"; then fail; else ok; fi
|
|
fi
|
|
# Check any standalone .lux files in the project
|
|
for lux_file in "$proj_dir"/*.lux; do
|
|
[ -f "$lux_file" ] || continue
|
|
fname=$(basename "$lux_file")
|
|
[ "$fname" = "main.lux" ] && continue
|
|
step "lux check (project: $proj/$fname)"
|
|
OUTPUT=$("$LUX" check "$lux_file" 2>&1 || true)
|
|
if echo "$OUTPUT" | grep -qi "error"; then fail; else ok; fi
|
|
done
|
|
done
|
|
|
|
# --- Summary ---
|
|
printf "\n${BOLD}═══ Validation Summary ═══${NC}\n"
|
|
if [ $FAILED -eq 0 ]; then
|
|
printf "${GREEN}All %d checks passed.${NC}\n" "$TOTAL"
|
|
else
|
|
printf "${RED}%d/%d checks failed.${NC}\n" "$FAILED" "$TOTAL"
|
|
exit 1
|
|
fi
|