From bcea8e0d169974ba57a54ca098f480d6294a7fb1 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 2 Mar 2021 13:10:49 +0200 Subject: test(tazjin/rlox): Add simple string assertions Change-Id: I6c60934d57170157d877e71cc87a97ab773342b5 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2581 Reviewed-by: tazjin Tested-by: BuildkiteCI --- users/tazjin/rlox/src/bytecode/tests.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'users/tazjin/rlox/src') diff --git a/users/tazjin/rlox/src/bytecode/tests.rs b/users/tazjin/rlox/src/bytecode/tests.rs index 9b31d5469be1..b29769f460a1 100644 --- a/users/tazjin/rlox/src/bytecode/tests.rs +++ b/users/tazjin/rlox/src/bytecode/tests.rs @@ -18,6 +18,10 @@ fn expect_bool(code: &str, value: bool) { expect(code, Value::Bool(value)) } +fn expect_str(code: &str, value: &str) { + expect(code, Value::String(value.to_string().into())) +} + #[test] fn numbers() { expect_num("1", 1.0); @@ -98,3 +102,9 @@ fn comparisons() { expect_bool("42 >= 42", true); expect_bool("42 >= 23", true); } + +#[test] +fn strings() { + expect_str("\"hello\"", "hello"); + expect_str("\"hello\" + \" world\"", "hello world"); +} -- cgit 1.4.1