tobogganSe connecter

louise

The Louise language: compiler, runtime, std, tooling

Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.

40 lignes · 1023 octetsBrut · Historique
1// `@test import` brings a module in for tests only (ADR 0064): a `@test`
2// function may use it, any other item is E0126, and a program build drops
3// it with the tests. No other attribute applies to an import (E0114), nor
4// does `@test native`: an import has nothing to run.
5
6@test import std/list
7@test import std/option.{unwrap_or}
8
9@should_panic "no" //~ ERROR E0114 `@should_panic` does not apply to an import
10import std/result
11
12@test native import std/string //~ ERROR E0114 `@test native` does not apply to an import
13
14@test
15fn a_test_may_use_both ::
16{
17 let _ = list.length [1, 2]
18 let _ = unwrap_or None 1
19 let _ = result.is_ok (Ok(1))
20 let _ = string.length "ok"
21 ()
22}
23
24fn qualified :: -> Int
25//~^ ERROR E0126 `qualified` is not a test but uses `std/list`
26{
27 list.length [1, 2]
28}
29
30fn by_name :: -> Int
31//~^ ERROR E0126 `by_name` is not a test but uses `std/option`
32{
33 unwrap_or None 1
34}
35
36fn twice :: -> Int
37//~^ ERROR E0126 `twice` is not a test but uses `std/list`
38{
39 list.length [1] + list.length [2]
40}