aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-09-15 15:33:47 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-09-15 15:33:47 -0400
commite422079fcced744e3a6247aeb12a09a658989072 (patch)
tree393d5e52ba67dcc822ccfa9a812198edda5e735d /test
parent259c7efcf8c3808d8151d8e15f1167ad2b6f2ca7 (diff)
Add a Byte datatype
Diffstat (limited to 'test')
-rw-r--r--test/bytes.tm8
-rw-r--r--test/integers.tm16
-rw-r--r--test/lang.tm2
-rw-r--r--test/optionals.tm6
-rw-r--r--test/paths.tm2
-rw-r--r--test/text.tm16
6 files changed, 31 insertions, 19 deletions
diff --git a/test/bytes.tm b/test/bytes.tm
new file mode 100644
index 00000000..4db94930
--- /dev/null
+++ b/test/bytes.tm
@@ -0,0 +1,8 @@
+
+func main():
+ !! Test bytes:
+ >> 100[B]
+ = 100[B]
+
+ >> 0xFF[B]
+ = 255[B]
diff --git a/test/integers.tm b/test/integers.tm
index e15b9473..363fdfdd 100644
--- a/test/integers.tm
+++ b/test/integers.tm
@@ -11,8 +11,8 @@ func main():
>> 2 * 3 + 4
= 10
- >> 1i8 + 2i16
- = 3_i16
+ >> 1[8] + 2[16]
+ = 3[16]
>> 1 << 10
= 1024
@@ -32,7 +32,7 @@ func main():
>> nums
= "1,2,3,4,5,"
- >> x := 123i64
+ >> x := 123[64]
>> x:format(digits=5)
= "00123"
>> x:hex()
@@ -42,16 +42,16 @@ func main():
>> Int.random(1, 100)
>> Int64.min
- = -9223372036854775808_i64
+ = -9223372036854775808[64]
>> Int64.max
- = 9223372036854775807_i64
+ = 9223372036854775807[64]
- >> 123_i32:hex()
+ >> 123[32]:hex()
= "0x7B"
- >> 123_i16:hex()
+ >> 123[16]:hex()
= "0x7B"
- >> 123_i8:hex()
+ >> 123[8]:hex()
= "0x7B"
>> Int(2.1)
diff --git a/test/lang.tm b/test/lang.tm
index a637b442..e19c1e2a 100644
--- a/test/lang.tm
+++ b/test/lang.tm
@@ -33,7 +33,7 @@ func main():
>> $HTML"$(1 + 2)"
= $HTML"3"
- >> $HTML"$(3_i8)"
+ >> $HTML"$(3[8])"
= $HTML"3"
>> html:paragraph()
diff --git a/test/optionals.tm b/test/optionals.tm
index 928587f7..6d7db835 100644
--- a/test/optionals.tm
+++ b/test/optionals.tm
@@ -21,7 +21,7 @@ func maybe_int(should_i:Bool)->Int?:
func maybe_int64(should_i:Bool)->Int64?:
if should_i:
- return 123_i64
+ return 123[64]
else:
return !Int64
@@ -110,12 +110,12 @@ func main():
!! ...
!! Int64s:
>> yep := maybe_int64(yes)
- = 123_i64?
+ = 123[64]?
>> nope := maybe_int64(no)
= !Int64
>> if yep:
>> yep
- = 123_i64
+ = 123[64]
else: fail("Falsey: $yep")
>> if nope:
fail("Truthy: $nope")
diff --git a/test/paths.tm b/test/paths.tm
index 8d5a92f2..996b6dde 100644
--- a/test/paths.tm
+++ b/test/paths.tm
@@ -24,6 +24,8 @@ func main():
>> tmpfile:append("!")
>> tmpfile:read()
= "Hello world!"
+ >> tmpfile:read_bytes()
+ = [72[B], 101[B], 108[B], 108[B], 111[B], 32[B], 119[B], 111[B], 114[B], 108[B], 100[B], 33[B]]
>> tmpdir:files():has(tmpfile)
= yes
diff --git a/test/text.tm b/test/text.tm
index 5de66a60..f27eaf37 100644
--- a/test/text.tm
+++ b/test/text.tm
@@ -29,17 +29,19 @@ func main():
>> amelie:split()
= ["A", "m", "é", "l", "i", "e"] : [Text]
>> amelie:utf32_codepoints()
- = [65_i32, 109_i32, 233_i32, 108_i32, 105_i32, 101_i32] : [Int32]
+ = [65[32], 109[32], 233[32], 108[32], 105[32], 101[32]] : [Int32]
>> amelie:utf8_bytes()
- = [65_i8, 109_i8, -61_i8, -87_i8, 108_i8, 105_i8, 101_i8] : [Int8]
+ = [65[B], 109[B], 195[B], 169[B], 108[B], 105[B], 101[B]] : [Byte]
+ >> Text.from_bytes([65[B], 109[B], 195[B], 169[B], 108[B], 105[B], 101[B]])
+ = "Amélie"
>> amelie2 := "Am$(\U65\U301)lie"
>> amelie2:split()
= ["A", "m", "é", "l", "i", "e"] : [Text]
>> amelie2:utf32_codepoints()
- = [65_i32, 109_i32, 233_i32, 108_i32, 105_i32, 101_i32] : [Int32]
+ = [65[32], 109[32], 233[32], 108[32], 105[32], 101[32]] : [Int32]
>> amelie2:utf8_bytes()
- = [65_i8, 109_i8, -61_i8, -87_i8, 108_i8, 105_i8, 101_i8] : [Int8]
+ = [65[B], 109[B], 195[B], 169[B], 108[B], 105[B], 101[B]] : [Byte]
>> amelie:codepoint_names()
= ["LATIN CAPITAL LETTER A", "LATIN SMALL LETTER M", "LATIN SMALL LETTER E WITH ACUTE", "LATIN SMALL LETTER L", "LATIN SMALL LETTER I", "LATIN SMALL LETTER E"]
@@ -193,11 +195,11 @@ func main():
>> " one two three ":find($/{id}/, start=5)
= 8
- >> len := 0_i64
+ >> len := 0[64]
>> " one ":find($/{id}/, length=&len)
= 4
>> len
- = 3_i64
+ = 3[64]
!! Test text slicing:
>> "abcdef":slice()
@@ -218,7 +220,7 @@ func main():
>> house:codepoint_names()
= ["CJK Unified Ideographs-5BB6"]
>> house:utf32_codepoints()
- = [23478_i32]
+ = [23478[32]]
>> "🐧":codepoint_names()
= ["PENGUIN"]