2021-03-15 22:32:16 +01:00
|
|
|
{ depot, lib, pkgs, ... }:
|
2021-01-02 00:15:32 +01:00
|
|
|
|
|
|
|
let
|
2021-01-23 16:17:01 +01:00
|
|
|
|
|
|
|
python-netstring-test = depot.users.Profpatsch.writers.python3 {
|
|
|
|
name = "python-netstring-test";
|
2021-01-02 00:15:32 +01:00
|
|
|
libraries = p: [
|
2021-04-23 22:04:42 +02:00
|
|
|
depot.users.Profpatsch.netstring.python-netstring
|
2021-01-02 00:15:32 +01:00
|
|
|
];
|
|
|
|
} ''
|
|
|
|
import netstring
|
|
|
|
|
|
|
|
def assEq(left, right):
|
|
|
|
assert left == right, "{} /= {}".format(str(left), str(right))
|
|
|
|
|
|
|
|
assEq(
|
2021-04-23 19:05:59 +02:00
|
|
|
netstring.read_netstring(b"""${depot.nix.netstring.fromString "hi!"}"""),
|
2021-01-02 00:15:32 +01:00
|
|
|
(b"hi!", b"")
|
|
|
|
)
|
|
|
|
|
|
|
|
assEq(
|
|
|
|
netstring.read_netstring_key_val(
|
2021-04-23 19:05:59 +02:00
|
|
|
b"""${depot.nix.netstring.attrsToKeyValList { foo = "42"; }}"""
|
2021-01-02 00:15:32 +01:00
|
|
|
),
|
|
|
|
(b'foo', b'42', b"")
|
|
|
|
)
|
|
|
|
|
|
|
|
assEq(
|
|
|
|
netstring.read_netstring_key_val_list(
|
2021-04-23 19:05:59 +02:00
|
|
|
b"""${depot.nix.netstring.attrsToKeyValList { foo = "42"; bar = "hi"; }}"""
|
2021-01-02 00:15:32 +01:00
|
|
|
),
|
|
|
|
{ b'foo': b'42', b'bar': b'hi' }
|
|
|
|
)
|
2021-01-23 16:17:01 +01:00
|
|
|
'';
|
2021-01-02 00:15:32 +01:00
|
|
|
|
2021-04-23 22:04:42 +02:00
|
|
|
rust-netstring-test = depot.nix.writers.rustSimple {
|
2021-01-23 16:17:01 +01:00
|
|
|
name = "rust-netstring-test";
|
|
|
|
dependencies = [
|
2021-04-23 22:04:42 +02:00
|
|
|
depot.users.Profpatsch.netstring.rust-netstring
|
2021-01-23 16:17:01 +01:00
|
|
|
];
|
|
|
|
} ''
|
|
|
|
extern crate netstring;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
assert_eq!(
|
|
|
|
std::str::from_utf8(&netstring::to_netstring(b"hello")).unwrap(),
|
2021-04-23 19:05:59 +02:00
|
|
|
r##"${depot.nix.netstring.fromString "hello"}"##
|
2021-01-23 16:17:01 +01:00
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
std::str::from_utf8(&netstring::to_netstring("こんにちは".as_bytes())).unwrap(),
|
2021-04-23 19:05:59 +02:00
|
|
|
r##"${depot.nix.netstring.fromString "こんにちは"}"##
|
2021-01-23 16:17:01 +01:00
|
|
|
);
|
|
|
|
}
|
2021-01-02 00:15:32 +01:00
|
|
|
'';
|
|
|
|
|
2021-11-23 14:31:17 +01:00
|
|
|
in depot.nix.readTree.drvTargets {
|
2021-01-02 00:15:32 +01:00
|
|
|
inherit
|
|
|
|
python-netstring-test
|
2021-01-23 16:17:01 +01:00
|
|
|
rust-netstring-test
|
2021-01-02 00:15:32 +01:00
|
|
|
;
|
|
|
|
}
|