Skip to content

Commit 0d2fcdf

Browse files
add tests for slicing assignment and bin/oct/hex
1 parent 349f0e2 commit 0d2fcdf

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

bas/test.bas

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
20 DEFINT X,Y
1111
25 PRINT "printing var list"
1212
30 VARLIST
13-
34 REM
14-
35 REM simple loop
15-
36 REM
13+
44 REM
14+
45 REM simple loop
15+
46 REM
1616
50 FOR I=1 TO 3
1717
60 PRINT "loop with NEXT I"I
1818
70 NEXT I
@@ -88,6 +88,12 @@
8888
1740 PRINT A$, "len="len(A$)
8989
1750 PRINT "(1:5), should produce HELLO: "A$(1:5)
9090
1760 PRINT "(4:5), should produce LO: "A$(4:5)
91+
1770 REM
92+
1771 REM assign string into a slice
93+
1772 REM
94+
1780 A$="HELLO WORLD"
95+
1790 A$(1:4)="GOOD"
96+
1791 PRINT "assigned into a slice, should produce GOODO WORLD: "A$
9197
1800 REM
9298
1801 REM concats
9399
1802 REM
@@ -117,6 +123,15 @@
117123
1910 PRINT "using SPACE$, should print three spaces and HELLO: ";SPACE$(3);"HELLO"
118124
1920 PRINT "using STRING$, should print HELLO three times: ";STRING$("HELLO",3)
119125
1930 PRINT "using STRING$ with ASCII value, should print three X's: ";STRING$(88,3)
126+
2000 REM
127+
2001 REM bin/oct/hex conversions
128+
2002 REM
129+
2010 PRINT "Convert hex FFFE to number, should print 65534: ";HEX("FFFE")
130+
2020 PRINT "Convert oct 7654 to number, should print 4012: ";OCT("7654")
131+
2030 PRINT "Convert bin 101010 to number, should print 42: ";BIN("101010")
132+
2040 PRINT "Convert 5432 to hex, should print 1538: ";HEX$(5432)
133+
2050 PRINT "Convert 4321 to oct, should print 10341: ";OCT$(4321)
134+
2060 PRINT "Convert 55 to bin, should print 110111: ";BIN$(55)
120135
2294 REM
121136
2295 REM make sure B and B() are different
122137
2296 REM

0 commit comments

Comments
 (0)