Skip to content

main.aug ​

A small tested application · Source and specification

Files in this project

Code ​

aug
// aug-spec: "main.aug.md" explains this file. Read it before changes; refresh with aug spec.
import Console and SystemConsole from august.io
implement Console with SystemConsole
import Logger and ConsoleLogger from logging
import Arithmetic and Calculator and load from calculator
implement Logger with ConsoleLogger
try:
    List<int> numbers = [1, 2]
    Tuple<int,string> pair = (1, "apple")
    Set<int> unique = {1, 2, 1}
    Map<int,string> fruit = {1: "apples", 2: "pears"}
    calculator = Calculator()
    print(
        value=calculator.add(right=numbers.get(index=1), left=numbers.get(index=0))
    )
    print(value=pair.get(index=1))
    print(value=unique.length())
    print(value=fruit.get(key=2))
    try:
        print(value=load(fail=true))
    catch FileError error:
        print(value="load failed as expected")
catch IndexError error:
    print(value="unexpected index failure")
aug
// aug-spec: "main.aug.md" explains this file. Read it before changes; refresh with aug spec.
import Console and SystemConsole from august.io
implement Console with SystemConsole
import Logger and ConsoleLogger from logging
import Arithmetic and Calculator and load from calculator
implement Logger with ConsoleLogger
try {
    List<int> numbers = [1, 2]
    Tuple<int,string> pair = (1, "apple")
    Set<int> unique = {1, 2, 1}
    Map<int,string> fruit = {1: "apples", 2: "pears"}
    calculator = Calculator()
    print(
        value=calculator.add(right=numbers.get(index=1), left=numbers.get(index=0))
    )
    print(value=pair.get(index=1))
    print(value=unique.length())
    print(value=fruit.get(key=2))
    try {
        print(value=load(fail=true))
    }
    catch FileError error {
        print(value="load failed as expected")
    }
}
catch IndexError error {
    print(value="unexpected index failure")
}

Compiled specification ​

Interactions and sequences

Providers ​

Console is provided by SystemConsole. The same instance is shared. Logger is provided by ConsoleLogger. The same instance is shared.

Startup ​

It sets numbers of type List<int> to a list containing 1, 2. It sets pair of type Tuple<int,string> to a tuple containing 1, "apple". It sets unique of type Set<int> to a set containing 1, 2, 1. It sets fruit of type Map<int,string> to a map with 1 mapped to "apples"; 2 mapped to "pears". source

It sets calculator to a Calculator using injected Logger for _logger. It prints calculator.add with right from the item at index 1 in numbers and left from the item at index 0 in numbers using injected Console for console. It prints pair.get with index 1. It prints the number of elements in unique. source

It prints the value under 2 in fruit. It prints load with fail true. If this work raises FileError, it prints "load failed as expected". If this work raises IndexError, it prints "unexpected index failure". source

Dependencies ​

It uses SystemConsole from august.io. It uses Calculator (add) and load from calculator. It uses ConsoleLogger from logging.

Built-in operations follow the language reference.

Last updated:

The world runs on language