depot/third_party/nixpkgs/pkgs/by-name/in/inko/test.nix
Default email 159e378cbb Project import generated by Copybara.
GitOrigin-RevId: c04d5652cfa9742b1d519688f65d1bbccea9eb7e
2024-09-19 17:19:46 +03:00

39 lines
733 B
Nix

{ inko
, writeText
, runCommand
, ...
}:
let
source = writeText "hello.inko" /* inko */ ''
import std.process (sleep)
import std.stdio (STDOUT)
import std.time (Duration)
class async Printer {
fn async print(message: String, channel: Channel[Nil]) {
let _ = STDOUT.new.print(message)
channel.send(nil)
}
}
class async Main {
fn async main {
let channel = Channel.new(size: 2)
Printer().print('Hello', channel)
Printer().print('world', channel)
channel.receive
channel.receive
}
}
'';
in
runCommand "inko-test" { } ''
${inko}/bin/inko run ${source} > $out
cat $out | grep -q Hello
cat $out | grep -q world
''