prog8/compiler/test/arithmetic/aggregates.p8

74 lines
2.1 KiB
Plaintext
Raw Normal View History

%import floats
%import textio
%import string
2020-08-27 16:10:22 +00:00
%zeropage basicsafe
main {
sub start() {
ubyte[] ubarr = [100, 0, 99, 199, 22]
byte[] barr = [-100, 0, 99, -122, 22]
uword[] uwarr = [1000, 0, 222, 4444, 999]
word[] warr = [-1000, 0, 999, -4444, 222]
float[] farr = [-1000.1, 0, 999.9, -4444.4, 222.2]
str name = "irmen"
ubyte ub
byte bb
word ww
uword uw
float ff
; LEN/STRLEN
ubyte length = len(name)
2020-08-27 16:10:22 +00:00
if length!=5 txt.print("error len1\n")
length = len(uwarr)
2020-08-27 16:10:22 +00:00
if length!=5 txt.print("error len2\n")
length=string.length(name)
2020-08-27 16:10:22 +00:00
if length!=5 txt.print("error strlen1\n")
name[3] = 0
length=string.length(name)
2020-08-27 16:10:22 +00:00
if length!=3 txt.print("error strlen2\n")
; ANY
2024-02-21 16:04:39 +00:00
ub = any(ubarr) as ubyte
2020-08-27 16:10:22 +00:00
if ub==0 txt.print("error any1\n")
2024-02-21 16:04:39 +00:00
ub = any(barr) as ubyte
2020-08-27 16:10:22 +00:00
if ub==0 txt.print("error any2\n")
2024-02-21 16:04:39 +00:00
ub = any(uwarr) as ubyte
2020-08-27 16:10:22 +00:00
if ub==0 txt.print("error any3\n")
2024-02-21 16:04:39 +00:00
ub = any(warr) as ubyte
2020-08-27 16:10:22 +00:00
if ub==0 txt.print("error any4\n")
2024-02-21 16:04:39 +00:00
ub = any(farr) as ubyte
2020-08-27 16:10:22 +00:00
if ub==0 txt.print("error any5\n")
; ALL
2024-02-21 16:04:39 +00:00
ub = all(ubarr) as ubyte
2020-08-27 16:10:22 +00:00
if ub==1 txt.print("error all1\n")
2024-02-21 16:04:39 +00:00
ub = all(barr) as ubyte
2020-08-27 16:10:22 +00:00
if ub==1 txt.print("error all2\n")
2024-02-21 16:04:39 +00:00
ub = all(uwarr) as ubyte
2020-08-27 16:10:22 +00:00
if ub==1 txt.print("error all3\n")
2024-02-21 16:04:39 +00:00
ub = all(warr) as ubyte
2020-08-27 16:10:22 +00:00
if ub==1 txt.print("error all4\n")
2024-02-21 16:04:39 +00:00
ub = all(farr) as ubyte
2020-08-27 16:10:22 +00:00
if ub==1 txt.print("error all5\n")
ubarr[1]=$40
barr[1]=$40
uwarr[1]=$4000
warr[1]=$4000
farr[1]=1.1
2024-02-21 16:04:39 +00:00
ub = all(ubarr) as ubyte
2020-08-27 16:10:22 +00:00
if ub==0 txt.print("error all6\n")
2024-02-21 16:04:39 +00:00
ub = all(barr) as ubyte
2020-08-27 16:10:22 +00:00
if ub==0 txt.print("error all7\n")
2024-02-21 16:04:39 +00:00
ub = all(uwarr) as ubyte
2020-08-27 16:10:22 +00:00
if ub==0 txt.print("error all8\n")
2024-02-21 16:04:39 +00:00
ub = all(warr) as ubyte
2020-08-27 16:10:22 +00:00
if ub==0 txt.print("error all9\n")
2024-02-21 16:04:39 +00:00
ub = all(farr) as ubyte
2020-08-27 16:10:22 +00:00
if ub==0 txt.print("error all10\n")
2020-08-27 16:10:22 +00:00
txt.print("\nyou should see no errors printed above (only at first run).")
}
}