Tya v0.4 Specification

This document is the specification for Tya v0.4 after v0.3 standard attached libraries.

Theme

Tya v0.4 is about testing and script confidence.

v0.3 makes shared .tya modules easier to ship and import. v0.4 makes those modules, and user scripts built on them, easier to verify.

Goals

Included in v0.4

v0.4 adds:

Not Included in v0.4

v0.4 does not include:

Test Command

tya test runs Tya test files.

tya test
tya test tests
tya test tests/string_test.tya

Discovery rules:

  1. With no argument, search the current directory recursively for *_test.tya.
  2. With a directory argument, search that directory recursively for

*_test.tya.

  1. With a file argument, run that file only.

Each test file is a normal Tya program. If any test file fails, tya test exits with a non-zero status.

Assertions

assert value fails when value is falsey.

assert true
assert 1 + 1 == 2

assert_equal expected, actual compares with deep equality.

assert_equal 4, add(2, 2)
assert_equal ["a", "b"], names

Failure output should be source-oriented and concise.

tests/math_test.tya:3:1: assertion failed

For assert_equal, include expected and actual values.

tests/math_test.tya:4:1: assert_equal failed
expected: 4
actual: 5

Stdlib Tests

The v0.3 standard attached library is tested through the same runner that user projects use.

Preferred layout:

tests/
  stdlib_string_test.tya
  stdlib_array_test.tya

Example:

import string

assert string.blank(" ")
assert_equal false, string.blank("tya")