From 7f30097d45c94ad77866bf84072b194964d8523e Mon Sep 17 00:00:00 2001 From: Jeff Date: Mon, 29 Jan 2024 23:57:13 -0500 Subject: [PATCH] Improve tests; Clean up --- examples/async_download.ds | 21 +++++++++++++++------ examples/threads.ds | 3 --- tests/value.rs | 22 ++++++++++++++++++++-- 3 files changed, 35 insertions(+), 11 deletions(-) delete mode 100644 examples/threads.ds diff --git a/examples/async_download.ds b/examples/async_download.ds index 7f8d8bb..5c17f4f 100644 --- a/examples/async_download.ds +++ b/examples/async_download.ds @@ -1,11 +1,20 @@ -cast = download("https://api.sampleapis.com/futurama/cast") -characters = download("https://api.sampleapis.com/futurama/characters") -episodes = download("https://api.sampleapis.com/futurama/episodes") +cast_len = 0 +characters_len = 0 +episodes_len = 0 async { - cast_len = length(from_json(cast)) - characters_len = length(from_json(characters)) - episodes_len = length(from_json(episodes)) + { + cast = download("https://api.sampleapis.com/futurama/cast") + cast_len = length(from_json(cast)) + } + { + characters = download("https://api.sampleapis.com/futurama/characters") + characters_len = length(from_json(characters)) + } + { + episodes = download("https://api.sampleapis.com/futurama/episodes") + episodes_len = length(from_json(episodes)) + } } output ([cast_len, characters_len, episodes_len]) diff --git a/examples/threads.ds b/examples/threads.ds deleted file mode 100644 index 1a49f6d..0000000 --- a/examples/threads.ds +++ /dev/null @@ -1,3 +0,0 @@ -handle = thread:spawn("my_thread", { - -}) diff --git a/tests/value.rs b/tests/value.rs index 446f535..9bd78b2 100644 --- a/tests/value.rs +++ b/tests/value.rs @@ -13,11 +13,29 @@ fn integer() { assert_eq!(interpret("-666"), Ok(Value::Integer(-666))); } +#[test] +fn integer_overflow() { + assert_eq!( + interpret("9223372036854775807 + 1"), + Ok(Value::Integer(i64::MIN)) + ); + assert_eq!( + interpret("-9223372036854775808 - 1"), + Ok(Value::Integer(i64::MAX)) + ); +} + #[test] fn float() { assert_eq!(interpret("0.1"), Ok(Value::Float(0.1))); - assert_eq!(interpret("12.3"), Ok(Value::Float(12.3))); - assert_eq!(interpret("-6.66"), Ok(Value::Float(-6.66))); + assert_eq!( + interpret("1.7976931348623157e308f64"), + Ok(Value::Float(f64::MAX)) + ); + assert_eq!( + interpret("-1.7976931348623157e308f64"), + Ok(Value::Float(f64::MIN)) + ); } #[test]