This directory contains conformance tests for the aggregate-library (aLib) specification.
These tests verify that AffineScript's standard library operations conform to the language-agnostic specifications defined in the aggregate-library project.
aggregate-library (aLib) is a methodology repository that provides:
- Language-agnostic operation specifications
- Behavioral semantics and properties
- Executable test vectors in YAML format
aLib is NOT a code library - it's a way to specify minimal overlap between diverse programming ecosystems.
tests/conformance/
├── arithmetic/ # Arithmetic operation tests
│ └── add.affine
├── collection/ # Collection operation tests
│ ├── map.affine
│ ├── filter.affine
│ ├── fold.affine
│ └── contains.affine
├── run_all.affine # Master test runner
└── README.md # This file
affinescript tests/conformance/run_all.affineaffinescript tests/conformance/collection/map.affine================================================================================
aLib Conformance Report
================================================================================
✓ PASS collection/map: 5/5 tests
✓ PASS collection/filter: 5/5 tests
✓ PASS collection/fold: 6/6 tests
✓ PASS collection/contains: 6/6 tests
✓ PASS arithmetic/add: 5/5 tests
================================================================================
Summary
================================================================================
Total operations tested: 5
Conformant operations: 5/5
Total test cases: 27
Tests passed: 27
Tests failed: 0
Conformance rate: 100%
✓ Excellent aLib conformance (≥95%)
================================================================================
Each test file includes a reference to its source aLib spec:
// Source: aggregate-library/specs/collection/map.md
- 100% conformance: All test vectors pass
- ≥95% conformance: Excellent (production-ready)
- ≥80% conformance: Good (acceptable with documented gaps)
- <80% conformance: Needs improvement
AffineScript's conformance tests respect affine type constraints:
- Source collection moved (not copied)
- Elements consumed exactly once
- Result owned by caller
- Predicate borrows (
&T -> Bool) - Source collection moved
- Filtered elements automatically dropped
- Accumulator ownership tracked
- Source collection moved
- Left-associative evaluation
- Requires
Eqtrait on element type - Short-circuit on first match
- Source collection borrowed (not moved)
- Read the aLib spec from
aggregate-library/specs/ - Extract test vectors from YAML section
- Create
tests/conformance/<category>/<operation>.affine - Translate aLib function expressions to AffineScript syntax
- Add test to
run_all.affine
Example:
// SPDX-License-Identifier: CC-BY-SA-4.0
// Source: aggregate-library/specs/collection/map.md
fn test_map_double() -> TestResult {
let input = [1, 2, 3];
let result = map(input, fn(x) => x * 2);
assert_eq(result, [2, 4, 6], "Double each number");
Pass
}
See docs/ALIB-INTEGRATION.md for the complete aLib integration roadmap.
Phase 1: Conformance ✅ COMPLETE
- Collection conformance tests (4/4 specs) ✓
- Arithmetic conformance tests (5/5 specs) ✓
- Comparison conformance tests (6/6 specs) ✓
- Logical conformance tests (3/3 specs) ✓
- String conformance tests (3/3 specs) ✓
- Conditional conformance tests (1/1 specs) ✓
🏆 Total Progress: 22/22 specs (100% - PERFECT CONFORMANCE)
AffineScript now validates against all core aLib operations. Phase 1 complete!
When contributing affine-specific notes to aLib upstream:
- Document ownership semantics
- Explain move vs borrow decisions
- Show safety guarantees
- Provide affine-specific test vectors
MPL-2.0 (following AffineScript project license)