This repository has been archived on 2024-06-20. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
coffee.pygments/tests/examplefiles/savi/example.savi
Joe Eli McIlvain d7fda4e60b Add string interpolation to the Savi lexer.
Now the Savi lexer can tokenize string interpolation inside strings,
which is a new feature added to Savi since the last time this
lexer was updated.
2022-04-04 12:53:27 +02:00

29 lines
828 B
Text

:actor Main
:new (env)
Spec.Process.run(env, [
Spec.Run(AdditionSpec).new(env)
])
:class AdditionSpec
:is Spec
:const describes: "Addition"
:: Return the number 2 (written in hex, just for fun).
:const _two U64'val: 0x02
:it "adds two twos"
assert: @_two + '\x02' == 4
:: Raise an error if the argument is positive.
:fun non add_overflow!(a U64'val, b U64'val): a +! b
:it "can error on overflow"
integers Array(U64)'val = [99, 100, 101]
// Check addition overflow for various pairs of addends.
assert error: add_overflow!(U64.max_value, 1)
assert no_error: add_overflow!(U64.max_value, 0)
assert no_error: add_overflow!(integers[0]!, 1)
// Print a bit of extra information using string interpolation.
@env.out.print("The first integer is \(integers[0]!)")