Changeset - b789f53dc8f7
[Not reviewed]
mh - 3 years ago 2022-04-13 14:56:00
contact@maxhenger.nl
Actually fix string concatenation tests
2 files changed with 1 insertions and 19 deletions:
0 comments (0 inline, 0 general)
src/protocol/tests/eval_operators.rs
Show inline comments
 
@@ -185,59 +185,57 @@ fn test_tuple_select_operator() {
 
        auto tuple = (0, 1, 0, 1);
 
        tuple.0 = cast<u8>(1);
 
        tuple.1 = cast<u16>(2);
 
        tuple.2 = cast<u32>(3);
 
        tuple.3 = cast<u64>(4);
 
        return cast(tuple.0) + cast(tuple.1) + tuple.2 + cast(tuple.3) == 10;
 
    }
 
    ").for_function("test", |f| { f
 
        .for_variable("tuple", |v| { v.assert_concrete_type("(u8,u16,u32,u64)"); })
 
        .call_ok(Some(Value::Bool(true)));
 
    });
 

	
 
    Tester::new_single_source_expect_ok("tuple polymorph member access", "
 
    func sum_variant_a<A,B,C,D>((A,B,C,D) v) -> C {
 
        return cast(v.0) + cast(v.1) + v.2 + cast(v.3);
 
    }
 
    func sum_variant_b<A,B,C,D>((A,B,C,D) i) -> B {
 
        (A,B,C,D) c = (0,0,0,0);
 
        c.0 = i.0; c.1 = i.1; c.2 = i.2; c.3 = i.3;
 
        return cast(c.0) + c.1 + cast(c.2) + cast(c.3);
 
    }
 
    func test() -> bool {
 
        (u8,u16,u32,u64) tuple = (1, 2, 3, 4);
 
        return sum_variant_a(tuple) == 10 && sum_variant_b(tuple) == 10;
 
    }
 
    ").for_function("test", |f| { f
 
        .call_ok(Some(Value::Bool(true)));
 
    });
 
}
 

	
 
#[test]
 
fn test_string_operators() {
 
    Tester::new_single_source_expect_ok("string concatenation", "
 
func create_concatenated(string left, string right) -> string {
 
    return left @ \", but also \" @ right;
 
}
 
func perform_concatenate(string left, string right) -> string {
 
    left @= \", but also \";
 
    left @= right;
 
    return left;
 
}
 
func foo() -> bool {
 
    auto left = \"Darth Vader\";
 
    auto right = \"Anakin Skywalker\";
 
    auto res1 = create_concatenated(left, right);
 
    auto res2 = perform_concatenate(left, right);
 
    auto expected = \"Darth Vader, but also Anakin Skywalker\";
 

	
 
    print(res1);
 
    print(expected);
 
    return
 
        res1 == expected; // &&
 
        res1 == expected &&
 
        res2 == \"Darth Vader, but also Anakin Skywalker\" &&
 
        res1 != \"This kind of thing\" && res2 != \"Another likewise kind of thing\";
 
}
 
    ").for_function("foo", |f| { f
 
        .call_ok(Some(Value::Bool(true)));
 
    });
 
}
 
\ No newline at end of file
std/std.internet.pdl
Show inline comments
 
#module std.internet
 

	
 
union Cmd {
 
    Send(u8[]),
 
    Receive,
 
    Finish,
 
    Shutdown,
 
}
 

	
 
primitive tcp_client(u8[] ip, u16 port, in<Cmd> cmds, out<u8[]> rx) {
 
    #builtin
 
}
 

	
 
- Cleaned up stdlib
 
- Add option to bin compiler
 
- Allow for builtin procedures
 
- Move global functions to their own stdlib file
 
- Add bytestring (and tests for those bytestrings)
 
- Implement type inspector for rust-based components
 
- Modify scheme to facilitate position-independent symbol referencing (from token ranges to token markers)
 
- Fix (byte)string character escaping bug
 
- Fix (release-mode only) type inferencing bug
 
- Implement token-writer for debugging purposes
 
- Introduce `component` trait to facilitate builtin components
 
- Refactor common component code into various `component::default_handle_xxx` functions.
 
- Create TCP client component
 
- Add "epoll" polling thread to retrieve file descriptor events from unix OS.
 
- Implement type for runtime errors
 
\ No newline at end of file
0 comments (0 inline, 0 general)