From b20c2c13f229704f5b4b9a43d8323f24e18977f2 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 7 Nov 2014 15:03:03 -0600 Subject: BAS: Rename examples/bas to examples/bastest. Hook into build and configuration system. Finish ROMFS logic --- apps/examples/Kconfig | 1 + apps/examples/Makefile | 2 +- apps/examples/README.txt | 16 + apps/examples/bas/README.txt | 1576 ------------------------------- apps/examples/bas/tests/test01.bas | 10 - apps/examples/bas/tests/test02.bas | 8 - apps/examples/bas/tests/test03.bas | 16 - apps/examples/bas/tests/test04.bas | 6 - apps/examples/bas/tests/test05.bas | 8 - apps/examples/bas/tests/test06.bas | 12 - apps/examples/bas/tests/test07.bas | 5 - apps/examples/bas/tests/test08.bas | 10 - apps/examples/bas/tests/test09.bas | 9 - apps/examples/bas/tests/test10.bas | 31 - apps/examples/bas/tests/test11.bas | 6 - apps/examples/bas/tests/test12.bas | 10 - apps/examples/bas/tests/test13.bas | 4 - apps/examples/bas/tests/test14.bas | 22 - apps/examples/bas/tests/test15.bas | 18 - apps/examples/bas/tests/test16.bas | 10 - apps/examples/bas/tests/test17.bas | 9 - apps/examples/bas/tests/test18.bas | 13 - apps/examples/bas/tests/test19.bas | 20 - apps/examples/bas/tests/test20.bas | 11 - apps/examples/bas/tests/test21.bas | 16 - apps/examples/bas/tests/test22.bas | 14 - apps/examples/bas/tests/test23.bas | 13 - apps/examples/bas/tests/test24.bas | 8 - apps/examples/bas/tests/test25.bas | 14 - apps/examples/bas/tests/test26.bas | 5 - apps/examples/bas/tests/test27.bas | 8 - apps/examples/bas/tests/test28.bas | 6 - apps/examples/bas/tests/test29.bas | 7 - apps/examples/bas/tests/test30.bas | 2 - apps/examples/bas/tests/test31.bas | 7 - apps/examples/bas/tests/test32.bas | 8 - apps/examples/bas/tests/test33.bas | 17 - apps/examples/bas/tests/test34.bas | 18 - apps/examples/bas/tests/test35.bas | 9 - apps/examples/bas/tests/test36.bas | 8 - apps/examples/bas/tests/test37.bas | 6 - apps/examples/bas/tests/test38.bas | 9 - apps/examples/bas/tests/test39.bas | 12 - apps/examples/bas/tests/test40.bas | 5 - apps/examples/bas/tests/test41.bas | 9 - apps/examples/bas/tests/test42.bas | 9 - apps/examples/bas/tests/test43.bas | 16 - apps/examples/bas/tests/test44.bas | 8 - apps/examples/bas/tests/test45.bas | 9 - apps/examples/bas/tests/test46.bas | 2 - apps/examples/bas/tests/test47.bas | 10 - apps/examples/bas/tests/test48.bas | 8 - apps/examples/bas/tests/test49.bas | 16 - apps/examples/bas/tests/test50.bas | 9 - apps/examples/bas/tests/test51.bas | 2 - apps/examples/bas/tests/test52.bas | 6 - apps/examples/bastest/.gitignore | 11 + apps/examples/bastest/Kconfig | 31 + apps/examples/bastest/Makefile | 153 +++ apps/examples/bastest/README.txt | 1628 ++++++++++++++++++++++++++++++++ apps/examples/bastest/bastest_main.c | 121 +++ apps/examples/bastest/tests/test01.bas | 10 + apps/examples/bastest/tests/test02.bas | 8 + apps/examples/bastest/tests/test03.bas | 16 + apps/examples/bastest/tests/test04.bas | 6 + apps/examples/bastest/tests/test05.bas | 8 + apps/examples/bastest/tests/test06.bas | 12 + apps/examples/bastest/tests/test07.bas | 5 + apps/examples/bastest/tests/test08.bas | 10 + apps/examples/bastest/tests/test09.bas | 9 + apps/examples/bastest/tests/test10.bas | 31 + apps/examples/bastest/tests/test11.bas | 6 + apps/examples/bastest/tests/test12.bas | 10 + apps/examples/bastest/tests/test13.bas | 4 + apps/examples/bastest/tests/test14.bas | 22 + apps/examples/bastest/tests/test15.bas | 18 + apps/examples/bastest/tests/test16.bas | 10 + apps/examples/bastest/tests/test17.bas | 9 + apps/examples/bastest/tests/test18.bas | 13 + apps/examples/bastest/tests/test19.bas | 20 + apps/examples/bastest/tests/test20.bas | 11 + apps/examples/bastest/tests/test21.bas | 16 + apps/examples/bastest/tests/test22.bas | 14 + apps/examples/bastest/tests/test23.bas | 13 + apps/examples/bastest/tests/test24.bas | 8 + apps/examples/bastest/tests/test25.bas | 14 + apps/examples/bastest/tests/test26.bas | 5 + apps/examples/bastest/tests/test27.bas | 8 + apps/examples/bastest/tests/test28.bas | 6 + apps/examples/bastest/tests/test29.bas | 7 + apps/examples/bastest/tests/test30.bas | 2 + apps/examples/bastest/tests/test31.bas | 7 + apps/examples/bastest/tests/test32.bas | 8 + apps/examples/bastest/tests/test33.bas | 17 + apps/examples/bastest/tests/test34.bas | 18 + apps/examples/bastest/tests/test35.bas | 9 + apps/examples/bastest/tests/test36.bas | 8 + apps/examples/bastest/tests/test37.bas | 6 + apps/examples/bastest/tests/test38.bas | 9 + apps/examples/bastest/tests/test39.bas | 12 + apps/examples/bastest/tests/test40.bas | 5 + apps/examples/bastest/tests/test41.bas | 9 + apps/examples/bastest/tests/test42.bas | 9 + apps/examples/bastest/tests/test43.bas | 16 + apps/examples/bastest/tests/test44.bas | 8 + apps/examples/bastest/tests/test45.bas | 9 + apps/examples/bastest/tests/test46.bas | 2 + apps/examples/bastest/tests/test47.bas | 10 + apps/examples/bastest/tests/test48.bas | 8 + apps/examples/bastest/tests/test49.bas | 16 + apps/examples/bastest/tests/test50.bas | 9 + apps/examples/bastest/tests/test51.bas | 2 + apps/examples/bastest/tests/test52.bas | 6 + apps/interpreters/bas/README.txt | 7 +- nuttx/Documentation/README.html | 3 +- nuttx/README.txt | 1 + 116 files changed, 2501 insertions(+), 2117 deletions(-) delete mode 100644 apps/examples/bas/README.txt delete mode 100644 apps/examples/bas/tests/test01.bas delete mode 100644 apps/examples/bas/tests/test02.bas delete mode 100644 apps/examples/bas/tests/test03.bas delete mode 100644 apps/examples/bas/tests/test04.bas delete mode 100644 apps/examples/bas/tests/test05.bas delete mode 100644 apps/examples/bas/tests/test06.bas delete mode 100644 apps/examples/bas/tests/test07.bas delete mode 100644 apps/examples/bas/tests/test08.bas delete mode 100644 apps/examples/bas/tests/test09.bas delete mode 100644 apps/examples/bas/tests/test10.bas delete mode 100644 apps/examples/bas/tests/test11.bas delete mode 100644 apps/examples/bas/tests/test12.bas delete mode 100644 apps/examples/bas/tests/test13.bas delete mode 100644 apps/examples/bas/tests/test14.bas delete mode 100644 apps/examples/bas/tests/test15.bas delete mode 100644 apps/examples/bas/tests/test16.bas delete mode 100644 apps/examples/bas/tests/test17.bas delete mode 100644 apps/examples/bas/tests/test18.bas delete mode 100644 apps/examples/bas/tests/test19.bas delete mode 100644 apps/examples/bas/tests/test20.bas delete mode 100644 apps/examples/bas/tests/test21.bas delete mode 100644 apps/examples/bas/tests/test22.bas delete mode 100644 apps/examples/bas/tests/test23.bas delete mode 100644 apps/examples/bas/tests/test24.bas delete mode 100644 apps/examples/bas/tests/test25.bas delete mode 100644 apps/examples/bas/tests/test26.bas delete mode 100644 apps/examples/bas/tests/test27.bas delete mode 100644 apps/examples/bas/tests/test28.bas delete mode 100644 apps/examples/bas/tests/test29.bas delete mode 100644 apps/examples/bas/tests/test30.bas delete mode 100644 apps/examples/bas/tests/test31.bas delete mode 100644 apps/examples/bas/tests/test32.bas delete mode 100644 apps/examples/bas/tests/test33.bas delete mode 100644 apps/examples/bas/tests/test34.bas delete mode 100644 apps/examples/bas/tests/test35.bas delete mode 100644 apps/examples/bas/tests/test36.bas delete mode 100644 apps/examples/bas/tests/test37.bas delete mode 100644 apps/examples/bas/tests/test38.bas delete mode 100644 apps/examples/bas/tests/test39.bas delete mode 100644 apps/examples/bas/tests/test40.bas delete mode 100644 apps/examples/bas/tests/test41.bas delete mode 100644 apps/examples/bas/tests/test42.bas delete mode 100644 apps/examples/bas/tests/test43.bas delete mode 100644 apps/examples/bas/tests/test44.bas delete mode 100644 apps/examples/bas/tests/test45.bas delete mode 100644 apps/examples/bas/tests/test46.bas delete mode 100644 apps/examples/bas/tests/test47.bas delete mode 100644 apps/examples/bas/tests/test48.bas delete mode 100644 apps/examples/bas/tests/test49.bas delete mode 100644 apps/examples/bas/tests/test50.bas delete mode 100644 apps/examples/bas/tests/test51.bas delete mode 100644 apps/examples/bas/tests/test52.bas create mode 100644 apps/examples/bastest/.gitignore create mode 100644 apps/examples/bastest/Kconfig create mode 100644 apps/examples/bastest/Makefile create mode 100644 apps/examples/bastest/README.txt create mode 100644 apps/examples/bastest/bastest_main.c create mode 100644 apps/examples/bastest/tests/test01.bas create mode 100644 apps/examples/bastest/tests/test02.bas create mode 100644 apps/examples/bastest/tests/test03.bas create mode 100644 apps/examples/bastest/tests/test04.bas create mode 100644 apps/examples/bastest/tests/test05.bas create mode 100644 apps/examples/bastest/tests/test06.bas create mode 100644 apps/examples/bastest/tests/test07.bas create mode 100644 apps/examples/bastest/tests/test08.bas create mode 100644 apps/examples/bastest/tests/test09.bas create mode 100644 apps/examples/bastest/tests/test10.bas create mode 100644 apps/examples/bastest/tests/test11.bas create mode 100644 apps/examples/bastest/tests/test12.bas create mode 100644 apps/examples/bastest/tests/test13.bas create mode 100644 apps/examples/bastest/tests/test14.bas create mode 100644 apps/examples/bastest/tests/test15.bas create mode 100644 apps/examples/bastest/tests/test16.bas create mode 100644 apps/examples/bastest/tests/test17.bas create mode 100644 apps/examples/bastest/tests/test18.bas create mode 100644 apps/examples/bastest/tests/test19.bas create mode 100644 apps/examples/bastest/tests/test20.bas create mode 100644 apps/examples/bastest/tests/test21.bas create mode 100644 apps/examples/bastest/tests/test22.bas create mode 100644 apps/examples/bastest/tests/test23.bas create mode 100644 apps/examples/bastest/tests/test24.bas create mode 100644 apps/examples/bastest/tests/test25.bas create mode 100644 apps/examples/bastest/tests/test26.bas create mode 100644 apps/examples/bastest/tests/test27.bas create mode 100644 apps/examples/bastest/tests/test28.bas create mode 100644 apps/examples/bastest/tests/test29.bas create mode 100644 apps/examples/bastest/tests/test30.bas create mode 100644 apps/examples/bastest/tests/test31.bas create mode 100644 apps/examples/bastest/tests/test32.bas create mode 100644 apps/examples/bastest/tests/test33.bas create mode 100644 apps/examples/bastest/tests/test34.bas create mode 100644 apps/examples/bastest/tests/test35.bas create mode 100644 apps/examples/bastest/tests/test36.bas create mode 100644 apps/examples/bastest/tests/test37.bas create mode 100644 apps/examples/bastest/tests/test38.bas create mode 100644 apps/examples/bastest/tests/test39.bas create mode 100644 apps/examples/bastest/tests/test40.bas create mode 100644 apps/examples/bastest/tests/test41.bas create mode 100644 apps/examples/bastest/tests/test42.bas create mode 100644 apps/examples/bastest/tests/test43.bas create mode 100644 apps/examples/bastest/tests/test44.bas create mode 100644 apps/examples/bastest/tests/test45.bas create mode 100644 apps/examples/bastest/tests/test46.bas create mode 100644 apps/examples/bastest/tests/test47.bas create mode 100644 apps/examples/bastest/tests/test48.bas create mode 100644 apps/examples/bastest/tests/test49.bas create mode 100644 apps/examples/bastest/tests/test50.bas create mode 100644 apps/examples/bastest/tests/test51.bas create mode 100644 apps/examples/bastest/tests/test52.bas diff --git a/apps/examples/Kconfig b/apps/examples/Kconfig index 3c1639923..9b14a5bca 100644 --- a/apps/examples/Kconfig +++ b/apps/examples/Kconfig @@ -4,6 +4,7 @@ # source "$APPSDIR/examples/adc/Kconfig" +source "$APPSDIR/examples/bastest/Kconfig" source "$APPSDIR/examples/buttons/Kconfig" source "$APPSDIR/examples/can/Kconfig" source "$APPSDIR/examples/cc3000/Kconfig" diff --git a/apps/examples/Makefile b/apps/examples/Makefile index 815b410a3..b2e04be81 100644 --- a/apps/examples/Makefile +++ b/apps/examples/Makefile @@ -37,7 +37,7 @@ # Sub-directories -SUBDIRS = adc buttons can cc3000 cpuhog cxxtest dhcpd discover elf +SUBDIRS = adc bastest buttons can cc3000 cpuhog cxxtest dhcpd discover elf SUBDIRS += flash_test ftpc ftpd hello helloxx hidkbd igmp i2schar json SUBDIRS += keypadtest lcdrw mm modbus mount mtdpart mtdrwb netpkt nettest SUBDIRS += nrf24l01_term nsh null nx nxterm nxffs nxflat nxhello nximage diff --git a/apps/examples/README.txt b/apps/examples/README.txt index a1d754ae1..caac77e4a 100644 --- a/apps/examples/README.txt +++ b/apps/examples/README.txt @@ -48,6 +48,22 @@ examples/adc CONFIG_EXAMPLES_ADC_GROUPSIZE - The number of samples to read at once. Default: 4 +examples/bastest +^^^^^^^^^^^^^^^^ + This directory contains a small program that will mount a ROMFS file system + containing the BASIC test files extracted from the BAS 2.4 release. See + examples/bastest/README.txt for licensing and usage information. + + CONFIG_EXAMPLES_BASTEST_DEVMINOR - The minor device number of the ROMFS block + driver. For example, the N in /dev/ramN. Used for registering the RAM + block driver that will hold the ROMFS file system containing the BASIC + files to be tested. Default: 0 + + CONFIG_EXAMPLES_BASTEST_DEVPATH - The path to the ROMFS block driver device. This + must match EXAMPLES_BASTEST_DEVMINOR. Used for registering the RAM block driver + that will hold the ROMFS file system containing the BASIC files to be + tested. Default: "/dev/ram0" + examples/buttons ^^^^^^^^^^^^^^^^ diff --git a/apps/examples/bas/README.txt b/apps/examples/bas/README.txt deleted file mode 100644 index c1a47429d..000000000 --- a/apps/examples/bas/README.txt +++ /dev/null @@ -1,1576 +0,0 @@ -test01.bas -========== -Scalar variable assignment - -Test File ---------- -10 a=1 -20 print a -30 a$="hello" -40 print a$ -50 a=0.0002 -60 print a -70 a=2.e-6 -80 print a -90 a=.2e-6 -100 print a - -Expected Result ---------------- - 1 -hello - 0.0002 - 2e-06 - 2e-07 - -test02.bas -========== -Array variable assignment - -Test File ---------- -10 dim a(1) -20 a(0)=10 -30 a(1)=11 -40 a=12 -50 print a(0) -60 print a(1) -70 print a - -Expected Result ---------------- - 10 - 11 - 12 - -test03.bas -========== -FOR loops - -Test File ---------- - 10 for i=0 to 10 - 20 print i - 30 if i=5 then exit for - 40 next - 50 for i=0 to 0 - 60 print i - 70 next I - 80 for i=1 to 0 step -1 - 90 print i -100 next -110 for i=1 to 0 -120 print i -130 next -140 for i$="" to "aaaaaaaaaa" step "a" -150 print i$ -160 next - -Expected Result ---------------- - 0 - 1 - 2 - 3 - 4 - 5 - 0 - 1 - 0 - -a -aa -aaa -aaaa -aaaaa -aaaaaa -aaaaaaa -aaaaaaaa -aaaaaaaaa -aaaaaaaaaa - -test04.bas -========== -REPEAT UNTIL loop - -Test File ---------- -10 a=1 -20 repeat -30 print a -40 a=a+1 -50 until a=10 - -Expected Result ---------------- - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - -test05.bas -========== -GOSUB RETURN subroutines - -Test File ---------- -10 gosub 100 -20 gosub 100 -30 end -100 gosub 200 -110 gosub 200 -120 return -200 print "hello, world":return - -Expected Result ---------------- -hello, world -hello, world -hello, world -hello, world - -test06.bas -========== -Recursive function without arguments - -Test File ---------- -10 def fnloop -20 if n=0.0 then -30 r=0.0 -40 else -50 print n -60 n=n-1.0 -70 r=fnloop() -80 end if -90 =r -100 n=10 -110 print fnloop - -Expected Result ---------------- - 10 - 9 - 8 - 7 - 6 - 5 - 4 - 3 - 2 - 1 - 0 - -test07.bas -========== -Recursive function with arguments - -Test File ---------- -10 def fna(x) -20 if x=0 then r=1 else r=x*fna(x-1) -30 =r -40 print fna(7) - -Expected Result ---------------- - 5040 - -test08.bas -========== -DATA, READ and RESTORE - -Test File ---------- -10 data "a",b -20 data "c","d -40 read j$ -50 print "j=";j$ -60 restore 20 -70 for i=1 to 3 -80 read j$,k$ -90 print "j=";j$;" k=";k$ -100 next - -Expected Result ---------------- -j=a -j=c k=d -Error: end of `data' in line 80 at: -80 read j$,k$ - ^ - -test09.bas -========== -LOCAL variables - -Test File ---------- -10 def fna(a) -20 local b -30 b=a+1 -40 =b -60 b=3 -70 print b -80 print fna(4) -90 print b - -Expected Result ---------------- - 3 - 5 - 3 - -test10.bas -========== -PRINT USING - -Test File ---------- - 10 print using "!";"abcdef" - 20 print using "\ \";"abcdef" - 30 print using "###-";-1 - 40 print using "###-";0 - 50 print using "###-";1 - 60 print using "###+";-1 - 70 print using "###+";0 - 80 print using "###+";1 - 90 print using "#####,";1000 -100 print using "**#,##.##";1000.00 -110 print using "+##.##";1 -120 print using "+##.##";1.23400 -130 print using "+##.##";123.456 -140 print using "+##.";123.456 -150 print using "+##";123.456 -160 print using "abc def ###.## efg";1.3 -170 print using "###.##^^^^^";5 -180 print using "###.##^^^^";1000 -190 print using ".##^^^^";5.0 -200 print using "##^^^^";2.3e-9 -210 print using ".##^^^^";2.3e-9 -220 print using "#.#^^^^";2.3e-9 -230 print using ".####^^^^^";-011466 -240 print using "$*,***,***,***.**";3729825.24 -250 print using "$**********.**";3729825.24 -260 print using "$$###.##";456.78 -270 print using "a!b";"S" -280 print using "a!b";"S","T" -290 print using "a!b!c";"S" -300 print using "a!b!c";"S","T" - -Expected Result ---------------- -a -abc - 1- - 0 - 1 - 1- - 0+ - 1+ - 1,000 -*1,000.00 - +1.00 - +1.23 -+123.46 -+123. -+123 -abc def 1.30 efg -500.00E-002 -100.00E+01 -.50E+01 -23E-10 -.23E-08 -2.3E-09 --.1147E+005 -$***3,729,825.24 -$**3729825.24 -$456.78 -aSb -aSbaTb -aSb -aSbTc - -test11.bas -========== -OPEN and LINE INPUT - -Test File ---------- -10 open "i",1,"test.bas" -20 while not eof(1) -30 line input #1,a$ -40 print a$ -50 wend - -Expected Result ---------------- -10 open "i",1,"test.bas" -20 while not eof(1) -30 line input #1,a$ -40 print a$ -50 wend - -test12.bas -========== -Exception handling - -Test File ---------- -10 on error print "global handler 1 caught error in line ";erl : resume 30 -20 print mid$("",-1) -30 on error print "global handler 2 caught error in line ";erl : end -40 def procx -50 on error print "local handler caught error in line";erl : goto 70 -60 print 1/0 -70 end proc -80 procx -90 print 1 mod 0 - -Expected Result ---------------- -global handler 1 caught error in line 20 -local handler caught error in line 60 -global handler 2 caught error in line 90 - -test01.bas -========== -Unnumbered lines - -Test File ---------- -print "a" -goto 20 -print "b" -20 print "c" - -Expected Result ---------------- -a -c - -test14.bas -========== -SELECT CASE - -Test File ---------- - 10 for i=0 to 9 - 20 for j=0 to 9 - 30 print i,j - 40 select case i - 50 case 0 - 60 print "i after case 0" - 70 case 1 - 80 print "i after case 1" - 90 select case j -100 case 0 -110 print "j after case 0" -120 end select -130 case 3 to 5,7 -140 print "i after case 3 to 5, 7" -150 case is <9 -160 print "is after case is <9" -170 case else -180 print "i after case else" -190 end select -200 next -210 next - -Expected Result ---------------- - 0 0 -i after case 0 - 0 1 -i after case 0 - 0 2 -i after case 0 - 0 3 -i after case 0 - 0 4 -i after case 0 - 0 5 -i after case 0 - 0 6 -i after case 0 - 0 7 -i after case 0 - 0 8 -i after case 0 - 0 9 -i after case 0 - 1 0 -i after case 1 -j after case 0 - 1 1 -i after case 1 - 1 2 -i after case 1 - 1 3 -i after case 1 - 1 4 -i after case 1 - 1 5 -i after case 1 - 1 6 -i after case 1 - 1 7 -i after case 1 - 1 8 -i after case 1 - 1 9 -i after case 1 - 2 0 -is after case is <9 - 2 1 -is after case is <9 - 2 2 -is after case is <9 - 2 3 -is after case is <9 - 2 4 -is after case is <9 - 2 5 -is after case is <9 - 2 6 -is after case is <9 - 2 7 -is after case is <9 - 2 8 -is after case is <9 - 2 9 -is after case is <9 - 3 0 -i after case 3 to 5, 7 - 3 1 -i after case 3 to 5, 7 - 3 2 -i after case 3 to 5, 7 - 3 3 -i after case 3 to 5, 7 - 3 4 -i after case 3 to 5, 7 - 3 5 -i after case 3 to 5, 7 - 3 6 -i after case 3 to 5, 7 - 3 7 -i after case 3 to 5, 7 - 3 8 -i after case 3 to 5, 7 - 3 9 -i after case 3 to 5, 7 - 4 0 -i after case 3 to 5, 7 - 4 1 -i after case 3 to 5, 7 - 4 2 -i after case 3 to 5, 7 - 4 3 -i after case 3 to 5, 7 - 4 4 -i after case 3 to 5, 7 - 4 5 -i after case 3 to 5, 7 - 4 6 -i after case 3 to 5, 7 - 4 7 -i after case 3 to 5, 7 - 4 8 -i after case 3 to 5, 7 - 4 9 -i after case 3 to 5, 7 - 5 0 -i after case 3 to 5, 7 - 5 1 -i after case 3 to 5, 7 - 5 2 -i after case 3 to 5, 7 - 5 3 -i after case 3 to 5, 7 - 5 4 -i after case 3 to 5, 7 - 5 5 -i after case 3 to 5, 7 - 5 6 -i after case 3 to 5, 7 - 5 7 -i after case 3 to 5, 7 - 5 8 -i after case 3 to 5, 7 - 5 9 -i after case 3 to 5, 7 - 6 0 -is after case is <9 - 6 1 -is after case is <9 - 6 2 -is after case is <9 - 6 3 -is after case is <9 - 6 4 -is after case is <9 - 6 5 -is after case is <9 - 6 6 -is after case is <9 - 6 7 -is after case is <9 - 6 8 -is after case is <9 - 6 9 -is after case is <9 - 7 0 -i after case 3 to 5, 7 - 7 1 -i after case 3 to 5, 7 - 7 2 -i after case 3 to 5, 7 - 7 3 -i after case 3 to 5, 7 - 7 4 -i after case 3 to 5, 7 - 7 5 -i after case 3 to 5, 7 - 7 6 -i after case 3 to 5, 7 - 7 7 -i after case 3 to 5, 7 - 7 8 -i after case 3 to 5, 7 - 7 9 -i after case 3 to 5, 7 - 8 0 -is after case is <9 - 8 1 -is after case is <9 - 8 2 -is after case is <9 - 8 3 -is after case is <9 - 8 4 -is after case is <9 - 8 5 -is after case is <9 - 8 6 -is after case is <9 - 8 7 -is after case is <9 - 8 8 -is after case is <9 - 8 9 -is after case is <9 - 9 0 -i after case else - 9 1 -i after case else - 9 2 -i after case else - 9 3 -i after case else - 9 4 -i after case else - 9 5 -i after case else - 9 6 -i after case else - 9 7 -i after case else - 9 8 -i after case else - 9 9 -i after case else - -test15.bas -========== -FIELD, PUT and GET - -Test File ---------- -a$="a" -open "r",1,"test.dat",128 -print "before field a$=";a$ -field #1,10 as a$ -field #1,5 as b$,5 as c$ -lset b$="hi" -rset c$="ya" -print "a$=";a$ -put #1 -close #1 -print "after close a$=";a$ -open "r",2,"test.dat",128 -field #2,10 as b$ -get #2 -print "after get b$=";b$ -close #2 -kill "test.dat" - -Expected Result ---------------- -before field a$=a -a$=hi ya -after close a$= -after get b$=hi ya - -test16.bas -========== -SWAP - -Test File ---------- -a=1 : b=2 -print "a=";a;"b=";b -swap a,b -print "a=";a;"b=";b -dim a$(1,1),b$(1,1) -a$(1,0)="a" : b$(0,1)="b" -print "a$(1,0)=";a$(1,0);"b$(0,1)=";b$(0,1) -swap a$(1,0),b$(0,1) -print "a$(1,0)=";a$(1,0);"b$(0,1)=";b$(0,1) - -Expected Result ---------------- -a= 1 b= 2 -a= 2 b= 1 -a$(1,0)=ab$(0,1)=b -a$(1,0)=bb$(0,1)=a - -test17.bas -========== -DO, EXIT DO, LOOP - -Test File ---------- -print "loop started" -i=1 -do - print "i is";i - i=i+1 - if i>10 then exit do -loop -print "loop ended" - -Expected Result ---------------- -loop started -i is 1 -i is 2 -i is 3 -i is 4 -i is 5 -i is 6 -i is 7 -i is 8 -i is 9 -i is 10 -loop ended - -test18.bas -========== -DO WHILE, LOOP - -Test File ---------- -print "loop started" -x$="" -do while len(x$)<3 - print "x$ is ";x$ - x$=x$+"a" - y$="" - do while len(y$)<2 - print "y$ is ";y$ - y$=y$+"b" - loop -loop -print "loop ended" - -Expected Result ---------------- -loop started -x$ is -y$ is -y$ is b -x$ is a -y$ is -y$ is b -x$ is aa -y$ is -y$ is b -loop ended - -test19.bas -========== -ELSEIF - -Test File ---------- -for x=1 to 3 - if x=1 then - print "1a" - else - if x=2 then - print "2a" - else - print "3a" - end if - end if -next - -for x=1 to 3 - if x=1 then - print "1b" - elseif x=2 then - print "2b" - elseif x=3 then print "3b" -next - -Expected Result ---------------- -1a -2a -3a -1b -2b -3b - -test20.bas -========== -Caller trace - -Test File ---------- - 10 gosub 20 - 20 gosub 30 - 30 procb - 40 def proca - 50 print "hi" - 60 stop - 70 end proc - 80 def procb - 90 proca -100 end proc - -Expected Result ---------------- -hi -Break in line 60 at: -60 stop - ^ -Proc Called in line 90 at: -90 proca - ^ -Proc Called in line 30 at: -30 procb - ^ -Called in line 20 at: -20 gosub 30 - ^ -Called in line 10 at: -10 gosub 20 - ^ - -test21.bas -========== -Matrix assignment - -Test File ---------- -dim a(3,4) -for i=0 to 3 - for j=0 to 4 - a(i,j)=i*10+j - print a(i,j); - next - print -next -mat b=a -for i=0 to 3 - for j=0 to 4 - print b(i,j); - next - print -next - -Expected Result ---------------- - 0 1 2 3 4 - 10 11 12 13 14 - 20 21 22 23 24 - 30 31 32 33 34 - 0 0 0 0 0 - 0 11 12 13 14 - 0 21 22 23 24 - 0 31 32 33 34 - -test22.bas -========== -MAT PRINT - -Test File ---------- -dim a(2,2) -for i=0 to 2 - for j=0 to 2 - a(i,j)=i*10+j - next -next -for j=1 to 2 - for i=1 to 2 - print using " ##.##";a(i,j), - next - print -next -mat print using " ##.##";a,a - -Expected Result ---------------- - 11.00 21.00 - 12.00 22.00 - 11.00 12.00 - 21.00 22.00 - - 11.00 12.00 - 21.00 22.00 - -test23.bas -========== -Matrix addition and subtraction - -Test File ---------- -dim a(2,2) -a(2,2)=2.5 -dim b%(2,2) -b%(2,2)=3 -mat print a -mat a=a-b% -mat print a -dim c$(2,2) -c$(2,1)="hi" -mat print c$ -mat c$=c$+c$ -mat print c$ - -Expected Result ---------------- - 0 0 - 0 2.5 - 0 0 - 0 -0.5 - -hi - -hihi - -test24.bas -========== -Matrix multiplication - -Test File ---------- -10 dim b(2,3),c(3,2) -20 for i=1 to 2 : for j=1 to 3 : read b(i,j) : next : next -30 for i=1 to 3 : for j=1 to 2 : read c(i,j) : next : next -40 mat a=b*c -50 mat print b,c,a -60 data 1,2,3,3,2,1 -70 data 1,2,2,1,3,3 - -Expected Result ---------------- - 1 2 3 - 3 2 1 - - 1 2 - 2 1 - 3 3 - - 14 13 - 10 11 - -test25.bas -========== -Matrix scalar multiplication - -Test File ---------- -10 dim a(3,3) -20 for i=1 to 3 : for j=1 to 3 : read a(i,j) : next : next -30 mat print a -40 mat a=(3)*a -45 print -50 mat print a -60 data 1,2,3,4,5,6,7,8,9 -80 dim inch_array(5,1),cm_array(5,1) -90 mat read inch_array -100 data 1,12,36,100,39.37 -110 mat print inch_array -120 mat cm_array=(2.54)*inch_array -130 mat print cm_array - -Expected Result ---------------- - 1 2 3 - 4 5 6 - 7 8 9 - - 3 6 9 - 12 15 18 - 21 24 27 - 1 - 12 - 36 - 100 - 39.37 - 2.54 - 30.48 - 91.44 - 254 - 99.9998 - -test26.bas -========== -MAT READ - -Test File ---------- -dim a(3,3) -data 5,5,5,8,8,8,3,3 -mat read a(2,3) -mat print a - -Expected Result ---------------- - 5 5 5 - 8 8 8 - -test27.bas -========== -Matrix inversion - -Test File ---------- -data 1,2,3,4 -mat read a(2,2) -mat print a -mat b=inv(a) -mat print b -mat c=a*b -mat print c - -Expected Result ---------------- - 1 2 - 3 4 --2 1 - 1.5 -0.5 - 1 0 - 0 1 - -test28.bas -========== -TDL BASIC FNRETURN/FNEND - -Test File ---------- -def fnfac(n) - if n=1 then fnreturn 1 -fnend n*fnfac(n-1) - -print fnfac(10) - -Expected Result ---------------- - 3628800 - -test29.bas -========== -TDL INSTR - -Test File ---------- -print instr("123456789","456");" = 4?" -print INSTR("123456789","654");" = 0?" -print INSTR("1234512345","34");" = 3?" -print INSTR("1234512345","34",6);" = 8?" -print INSTR("1234512345","34",6,2);" = 0?" -print INSTR("1234512345","34",6,4);" = 8?" - -Expected Result ---------------- - 4 = 4? - 0 = 0? - 3 = 3? - 8 = 8? - 0 = 0? - 8 = 8? - -test30.bas -========== -Type mismatch check - -Test File ---------- -print 1+"a" - -Expected Result ---------------- -Error: Invalid binary operand at: end of program - -test31.bas -========== -PRINT default format - -Test File ---------- -10 for i=-8 to 8 -20 x=1+1/3 : y=1 : j=i -30 for j=i to -1 : x=x/10 : y=y/10 : next -40 for j=i to 1 step -1 : x=x*10 : y=y*10 : next -50 print x,y -60 next - -Expected Result ---------------- - 1.333333e-08 1e-08 - 1.333333e-07 1e-07 - 1.333333e-06 1e-06 - 1.333333e-05 1e-05 - 0.000133 0.0001 - 0.001333 0.001 - 0.013333 0.01 - 0.133333 0.1 - 1.333333 1 - 13.33333 10 - 133.3333 100 - 1333.333 1000 - 13333.33 10000 - 133333.3 100000 - 1333333 1000000 - 1.333333e+07 1e+07 - 1.333333e+08 1e+08 - -test032.bas -========== -SUB routines - -Test File ---------- -PUTS("abc") -END - -SUB PUTS(s$) - FOR i=1 to LEN(s$) : print mid$(s$,i,1); : NEXT - PRINT -END SUB - -Expected Result ---------------- -abc - -test33.bas -========== -OPEN FOR BINARY - -Test File ---------- -open "test.out" for binary as 1 -put 1,1,"xy" -put 1,3,"z!" -put 1,10,1/3 -put 1,20,9999 -close 1 -open "test.out" for binary as 1 -s$=" " -get 1,1,s$ -get 1,10,x -get 1,20,n% -close -print s$ -print x -print n% -kill "test.out" - -Expected Result ---------------- -xyz! - 0.333333 - 9999 - -test34.bas -========== -OPTION BASE - -Test File ---------- -option base 3 -dim a(3,5) -a(3,3)=1 -a(3,5)=2 - -print a(3,3) -print a(3,5) - -option base -2 -dim b(-1,2) -b(-2,-2)=10 -b(-1,2)=20 - -print a(3,3) -print a(3,5) -print b(-2,-2) -print b(-1,2) - -Expected Result ---------------- - 1 - 2 - 1 - 2 - 10 - 20 - -test35.bas -========== -Real to integer conversion - -Test File ---------- -a%=1.2 -print a% -a%=1.7 -print a% -a%=-0.2 -print a% -a%=-0.7 -print a% - -Expected Result ---------------- - 1 - 2 - 0 --1 - -test36.bas -========== -OPEN file locking - -Test File ---------- -on error goto 10 -print "opening file" -open "test.out" for output lock write as #1 -print "open succeeded" -if command$<>"enough" then shell "sh ./test/runbas test.bas enough" -end -10 print "open failed" - -Expected Result ---------------- -opening file -open succeeded -opening file -open failed - -test37.bas -========== -LINE INPUT reaching EOF - -Test File ---------- -10 open "i",1,"test.ref" -20 while not eof(1) -30 line input #1,a$ -40 if a$="abc" then print a$; else print "def" -50 wend - -Result ------- - Output should match test.ref - -test38.bas -========== -MAT REDIM - -Test File ---------- -dim x(10) -mat read x -mat print x -mat redim x(7) -mat print x -mat redim x(12) -mat print x -data 1,2,3,4,5,6,7,8,9,10 - -Expected Result ---------------- - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 0 - 0 - 0 - 0 - 0 - -test39.bas -========== -Nested function and procedure calls - -Test File ---------- -def proc_a(x) -print fn_b(1,x) -end proc - -def fn_b(a,b) -= a+fn_c(b) - -def fn_c(b) -= b+3 - -proc_a(2) - -Expected Result ---------------- - 6 - -test40.bas -========== -IMAGE - -Test File ---------- - d=3.1 - print using "#.#";d - print using 10;d -10 image #.## - -Expected Result ---------------- -3.1 -3.10 - -test41.bas -========== -EXIT FUNCTION - -Test File ---------- -function f(c) -print "f running" -if (c) then f=42 : exit function -f=43 -end function - -print f(0) -print f(1) - -Expected Result ---------------- -f running - 43 -f running - 42 - -test42.bas -========== -Arithmetic - -Test File ---------- -10 print 4.7\3 -20 print -2.3\1 -30 print int(-2.3) -40 print int(2.3) -50 print fix(-2.3) -60 print fix(2.3) -70 print fp(-2.3) -80 print fp(2.3) - -Expected Result ---------------- - 1 --2 --3 - 2 --2 - 2 --0.3 - 0.3 - -test43.bas -========== -Matrix multiplication size checks - -Test File ---------- -DIM a(3,3),b(3,1),c(3,3) -MAT READ a -MAT READ b -MAT c=a*b -MAT PRINT c -DATA 1,2,3,4,5,6,7,8,9 -DATA 5,3,2 - -erase b -DIM b(3) -RESTORE -MAT READ a -MAT READ b -MAT c=a*b -MAT PRINT c - -Expected Result ---------------- - 17 - 47 - 77 -Error: Dimension mismatch in line 14 at: -mat c=a*b - ^ - -test44.bas -========== -DELETE - -Test File ---------- -10 print 10 -20 print 20 -30 print 30 -40 print 40 -50 print 50 -60 print 60 -70 print 70 - -Usage ------ -load "test.bas" -delete -20 -delete 60- -delete 30-40 -delete 15 -list - -Expected Result ---------------- -Error: No such line at: 15 -50 print 50 - -test45.bas -========== -MID$ on left side - -Test File ---------- -10 mid$(a$,6,4) = "ABCD" -20 print a$ -30 a$="0123456789" -40 mid$(a$,6,4) = "ABCD" -50 print a$ -60 a$="0123456789" -70 let mid$(a$,6,4) = "ABCD" -80 print a$ - -Expected Result ---------------- - -01234ABCD9 -01234ABCD9 - -test46.bas -========== -END used without program - -Test File ---------- -for i=1 to 10:print i;:next i:end - -Expected Result ---------------- - 1 2 3 4 5 6 7 8 9 10 - -test47.bas -========== -MAT WRITE - -Test File ---------- -dim a(3,4) -for i=0 to 3 - for j=0 to 4 - a(i,j)=i*10+j - print a(i,j); - next - print -next -mat write a - -Expected Result ---------------- - 0 1 2 3 4 - 10 11 12 13 14 - 20 21 22 23 24 - 30 31 32 33 34 -11,12,13,14 -21,22,23,24 -31,32,33,34 - -test48.bas -========== -Multi assignment - -Test File ---------- -a,b = 10 -print a,b -dim c(10) -a,c(a) = 2 -print a,c(2),c(10) -a$,b$="test" -print a$,b$ - -Expected Result ---------------- - 10 10 - 2 0 2 -test test - -test49.bas -========== -Matrix determinant - -Test File ---------- -width 120 -dim a(7,7),b(7,7) -mat read a -mat print a; -print -data 58,71,67,36,35,19,60 -data 50,71,71,56,45,20,52 -data 64,40,84,50,51,43,69 -data 31,28,41,54,31,18,33 -data 45,23,46,38,50,43,50 -data 41,10,28,17,33,41,46 -data 66,72,71,38,40,27,69 -mat b=inv(a) -mat print b -print det - -Expected Result ---------------- - 58 71 67 36 35 19 60 - 50 71 71 56 45 20 52 - 64 40 84 50 51 43 69 - 31 28 41 54 31 18 33 - 45 23 46 38 50 43 50 - 41 10 28 17 33 41 46 - 66 72 71 38 40 27 69 - - 9.636025e+07 320206 -537449 2323650 -1.135486e+07 3.019632e+07 - -9.650941e+07 - 4480 15 -25 108 -528 1404 -4487 --39436 -131 220 -951 4647 -12358 39497 - 273240 908 -1524 6589 -32198 85625 -273663 --1846174 -6135 10297 -44519 217549 -578534 1849032 - 1.315035e+07 43699 -73346 317110 -1549606 4120912 -1.31707e+07 - --9.636079e+07 -320208 537452 -2323663 1.135493e+07 -3.019649e+07 - 9.650995e+07 - 1 - -test50.bas -========== -Min and max function - -Test File ---------- -print min(1,2) -print min(2,1) -print min(-0.3,0.3) -print min(-0.3,4) -print max(1,2) -print max(2,1) -print max(-0.3,0.3) -print max(-0.3,4) - -Expected Result ---------------- - 1 - 1 --0.3 --0.3 - 2 - 2 - 0.3 - 4 - -test51.bas -========== -Print items - -Test File ---------- -PRINT "Line 1";TAB(78);1.23456789 - -Expected Result ---------------- -Line 1 - 1.234568 - -test52.bas -========== -MAT INPUT - -Test File ---------- -dim a(2,2) -mat input a -mat print a -mat input a -mat print a - -Test File ---------- -1,2,3,4,5 -1 -3,4 - -Expected Result ---------------- -? - 1 2 - 3 4 -? ? - 1 0 - 3 4 diff --git a/apps/examples/bas/tests/test01.bas b/apps/examples/bas/tests/test01.bas deleted file mode 100644 index d2c3494e0..000000000 --- a/apps/examples/bas/tests/test01.bas +++ /dev/null @@ -1,10 +0,0 @@ -10 a=1 -20 print a -30 a$="hello" -40 print a$ -50 a=0.0002 -60 print a -70 a=2.e-6 -80 print a -90 a=.2e-6 -100 print a diff --git a/apps/examples/bas/tests/test02.bas b/apps/examples/bas/tests/test02.bas deleted file mode 100644 index cc8b50ebc..000000000 --- a/apps/examples/bas/tests/test02.bas +++ /dev/null @@ -1,8 +0,0 @@ -10 dim a(1) -20 a(0)=10 -30 a(1)=11 -40 a=12 -50 print a(0) -60 print a(1) -70 print a - diff --git a/apps/examples/bas/tests/test03.bas b/apps/examples/bas/tests/test03.bas deleted file mode 100644 index 5d991d330..000000000 --- a/apps/examples/bas/tests/test03.bas +++ /dev/null @@ -1,16 +0,0 @@ - 10 for i=0 to 10 - 20 print i - 30 if i=5 then exit for - 40 next - 50 for i=0 to 0 - 60 print i - 70 next I - 80 for i=1 to 0 step -1 - 90 print i -100 next -110 for i=1 to 0 -120 print i -130 next -140 for i$="" to "aaaaaaaaaa" step "a" -150 print i$ -160 next diff --git a/apps/examples/bas/tests/test04.bas b/apps/examples/bas/tests/test04.bas deleted file mode 100644 index f2755e5a9..000000000 --- a/apps/examples/bas/tests/test04.bas +++ /dev/null @@ -1,6 +0,0 @@ -10 a=1 -20 repeat -30 print a -40 a=a+1 -50 until a=10 - diff --git a/apps/examples/bas/tests/test05.bas b/apps/examples/bas/tests/test05.bas deleted file mode 100644 index 49100a00e..000000000 --- a/apps/examples/bas/tests/test05.bas +++ /dev/null @@ -1,8 +0,0 @@ -10 gosub 100 -20 gosub 100 -30 end -100 gosub 200 -110 gosub 200 -120 return -200 print "hello, world":return - diff --git a/apps/examples/bas/tests/test06.bas b/apps/examples/bas/tests/test06.bas deleted file mode 100644 index ddd6efe78..000000000 --- a/apps/examples/bas/tests/test06.bas +++ /dev/null @@ -1,12 +0,0 @@ -10 def fnloop -20 if n=0.0 then -30 r=0.0 -40 else -50 print n -60 n=n-1.0 -70 r=fnloop() -80 end if -90 =r -100 n=10 -110 print fnloop - diff --git a/apps/examples/bas/tests/test07.bas b/apps/examples/bas/tests/test07.bas deleted file mode 100644 index 12c0cbdc7..000000000 --- a/apps/examples/bas/tests/test07.bas +++ /dev/null @@ -1,5 +0,0 @@ -10 def fna(x) -20 if x=0 then r=1 else r=x*fna(x-1) -30 =r -40 print fna(7) - diff --git a/apps/examples/bas/tests/test08.bas b/apps/examples/bas/tests/test08.bas deleted file mode 100644 index 0e6f13ad6..000000000 --- a/apps/examples/bas/tests/test08.bas +++ /dev/null @@ -1,10 +0,0 @@ -10 data "a",b -20 data "c","d -40 read j$ -50 print "j=";j$ -60 restore 20 -70 for i=1 to 3 -80 read j$,k$ -90 print "j=";j$;" k=";k$ -100 next - diff --git a/apps/examples/bas/tests/test09.bas b/apps/examples/bas/tests/test09.bas deleted file mode 100644 index 7d5f72735..000000000 --- a/apps/examples/bas/tests/test09.bas +++ /dev/null @@ -1,9 +0,0 @@ -10 def fna(a) -20 local b -30 b=a+1 -40 =b -60 b=3 -70 print b -80 print fna(4) -90 print b - diff --git a/apps/examples/bas/tests/test10.bas b/apps/examples/bas/tests/test10.bas deleted file mode 100644 index 41a935cca..000000000 --- a/apps/examples/bas/tests/test10.bas +++ /dev/null @@ -1,31 +0,0 @@ - 10 print using "!";"abcdef" - 20 print using "\ \";"abcdef" - 30 print using "###-";-1 - 40 print using "###-";0 - 50 print using "###-";1 - 60 print using "###+";-1 - 70 print using "###+";0 - 80 print using "###+";1 - 90 print using "#####,";1000 -100 print using "**#,##.##";1000.00 -110 print using "+##.##";1 -120 print using "+##.##";1.23400 -130 print using "+##.##";123.456 -140 print using "+##.";123.456 -150 print using "+##";123.456 -160 print using "abc def ###.## efg";1.3 -170 print using "###.##^^^^^";5 -180 print using "###.##^^^^";1000 -190 print using ".##^^^^";5.0 -200 print using "##^^^^";2.3e-9 -210 print using ".##^^^^";2.3e-9 -220 print using "#.#^^^^";2.3e-9 -230 print using ".####^^^^^";-011466 -240 print using "$*,***,***,***.**";3729825.24 -250 print using "$**********.**";3729825.24 -260 print using "$$###.##";456.78 -270 print using "a!b";"S" -280 print using "a!b";"S","T" -290 print using "a!b!c";"S" -300 print using "a!b!c";"S","T" - diff --git a/apps/examples/bas/tests/test11.bas b/apps/examples/bas/tests/test11.bas deleted file mode 100644 index 78eb6d1c6..000000000 --- a/apps/examples/bas/tests/test11.bas +++ /dev/null @@ -1,6 +0,0 @@ -10 open "i",1,"test.bas" -20 while not eof(1) -30 line input #1,a$ -40 print a$ -50 wend - diff --git a/apps/examples/bas/tests/test12.bas b/apps/examples/bas/tests/test12.bas deleted file mode 100644 index ecbb9d138..000000000 --- a/apps/examples/bas/tests/test12.bas +++ /dev/null @@ -1,10 +0,0 @@ -10 on error print "global handler 1 caught error in line ";erl : resume 30 -20 print mid$("",-1) -30 on error print "global handler 2 caught error in line ";erl : end -40 def procx -50 on error print "local handler caught error in line";erl : goto 70 -60 print 1/0 -70 end proc -80 procx -90 print 1 mod 0 - diff --git a/apps/examples/bas/tests/test13.bas b/apps/examples/bas/tests/test13.bas deleted file mode 100644 index e3be7a00b..000000000 --- a/apps/examples/bas/tests/test13.bas +++ /dev/null @@ -1,4 +0,0 @@ -print "a" -goto 20 -print "b" -20 print "c" diff --git a/apps/examples/bas/tests/test14.bas b/apps/examples/bas/tests/test14.bas deleted file mode 100644 index 56040112a..000000000 --- a/apps/examples/bas/tests/test14.bas +++ /dev/null @@ -1,22 +0,0 @@ - 10 for i=0 to 9 - 20 for j=0 to 9 - 30 print i,j - 40 select case i - 50 case 0 - 60 print "i after case 0" - 70 case 1 - 80 print "i after case 1" - 90 select case j -100 case 0 -110 print "j after case 0" -120 end select -130 case 3 to 5,7 -140 print "i after case 3 to 5, 7" -150 case is <9 -160 print "is after case is <9" -170 case else -180 print "i after case else" -190 end select -200 next -210 next - diff --git a/apps/examples/bas/tests/test15.bas b/apps/examples/bas/tests/test15.bas deleted file mode 100644 index a9195bf4b..000000000 --- a/apps/examples/bas/tests/test15.bas +++ /dev/null @@ -1,18 +0,0 @@ -a$="a" -open "r",1,"test.dat",128 -print "before field a$=";a$ -field #1,10 as a$ -field #1,5 as b$,5 as c$ -lset b$="hi" -rset c$="ya" -print "a$=";a$ -put #1 -close #1 -print "after close a$=";a$ -open "r",2,"test.dat",128 -field #2,10 as b$ -get #2 -print "after get b$=";b$ -close #2 -kill "test.dat" - diff --git a/apps/examples/bas/tests/test16.bas b/apps/examples/bas/tests/test16.bas deleted file mode 100644 index 809137d75..000000000 --- a/apps/examples/bas/tests/test16.bas +++ /dev/null @@ -1,10 +0,0 @@ -a=1 : b=2 -print "a=";a;"b=";b -swap a,b -print "a=";a;"b=";b -dim a$(1,1),b$(1,1) -a$(1,0)="a" : b$(0,1)="b" -print "a$(1,0)=";a$(1,0);"b$(0,1)=";b$(0,1) -swap a$(1,0),b$(0,1) -print "a$(1,0)=";a$(1,0);"b$(0,1)=";b$(0,1) - diff --git a/apps/examples/bas/tests/test17.bas b/apps/examples/bas/tests/test17.bas deleted file mode 100644 index bfe0c9c2c..000000000 --- a/apps/examples/bas/tests/test17.bas +++ /dev/null @@ -1,9 +0,0 @@ -print "loop started" -i=1 -do - print "i is";i - i=i+1 - if i>10 then exit do -loop -print "loop ended" - diff --git a/apps/examples/bas/tests/test18.bas b/apps/examples/bas/tests/test18.bas deleted file mode 100644 index 73ab93e1b..000000000 --- a/apps/examples/bas/tests/test18.bas +++ /dev/null @@ -1,13 +0,0 @@ -print "loop started" -x$="" -do while len(x$)<3 - print "x$ is ";x$ - x$=x$+"a" - y$="" - do while len(y$)<2 - print "y$ is ";y$ - y$=y$+"b" - loop -loop -print "loop ended" - diff --git a/apps/examples/bas/tests/test19.bas b/apps/examples/bas/tests/test19.bas deleted file mode 100644 index aa19fa4ae..000000000 --- a/apps/examples/bas/tests/test19.bas +++ /dev/null @@ -1,20 +0,0 @@ -for x=1 to 3 - if x=1 then - print "1a" - else - if x=2 then - print "2a" - else - print "3a" - end if - end if -next - -for x=1 to 3 - if x=1 then - print "1b" - elseif x=2 then - print "2b" - elseif x=3 then print "3b" -next - diff --git a/apps/examples/bas/tests/test20.bas b/apps/examples/bas/tests/test20.bas deleted file mode 100644 index 6b982bf89..000000000 --- a/apps/examples/bas/tests/test20.bas +++ /dev/null @@ -1,11 +0,0 @@ - 10 gosub 20 - 20 gosub 30 - 30 procb - 40 def proca - 50 print "hi" - 60 stop - 70 end proc - 80 def procb - 90 proca -100 end proc - diff --git a/apps/examples/bas/tests/test21.bas b/apps/examples/bas/tests/test21.bas deleted file mode 100644 index dd0f63beb..000000000 --- a/apps/examples/bas/tests/test21.bas +++ /dev/null @@ -1,16 +0,0 @@ -dim a(3,4) -for i=0 to 3 - for j=0 to 4 - a(i,j)=i*10+j - print a(i,j); - next - print -next -mat b=a -for i=0 to 3 - for j=0 to 4 - print b(i,j); - next - print -next - diff --git a/apps/examples/bas/tests/test22.bas b/apps/examples/bas/tests/test22.bas deleted file mode 100644 index e10b03a14..000000000 --- a/apps/examples/bas/tests/test22.bas +++ /dev/null @@ -1,14 +0,0 @@ -dim a(2,2) -for i=0 to 2 - for j=0 to 2 - a(i,j)=i*10+j - next -next -for j=1 to 2 - for i=1 to 2 - print using " ##.##";a(i,j), - next - print -next -mat print using " ##.##";a,a - diff --git a/apps/examples/bas/tests/test23.bas b/apps/examples/bas/tests/test23.bas deleted file mode 100644 index faf5c5593..000000000 --- a/apps/examples/bas/tests/test23.bas +++ /dev/null @@ -1,13 +0,0 @@ -dim a(2,2) -a(2,2)=2.5 -dim b%(2,2) -b%(2,2)=3 -mat print a -mat a=a-b% -mat print a -dim c$(2,2) -c$(2,1)="hi" -mat print c$ -mat c$=c$+c$ -mat print c$ - diff --git a/apps/examples/bas/tests/test24.bas b/apps/examples/bas/tests/test24.bas deleted file mode 100644 index 95678830b..000000000 --- a/apps/examples/bas/tests/test24.bas +++ /dev/null @@ -1,8 +0,0 @@ -10 dim b(2,3),c(3,2) -20 for i=1 to 2 : for j=1 to 3 : read b(i,j) : next : next -30 for i=1 to 3 : for j=1 to 2 : read c(i,j) : next : next -40 mat a=b*c -50 mat print b,c,a -60 data 1,2,3,3,2,1 -70 data 1,2,2,1,3,3 - diff --git a/apps/examples/bas/tests/test25.bas b/apps/examples/bas/tests/test25.bas deleted file mode 100644 index bf4d34c93..000000000 --- a/apps/examples/bas/tests/test25.bas +++ /dev/null @@ -1,14 +0,0 @@ -10 dim a(3,3) -20 for i=1 to 3 : for j=1 to 3 : read a(i,j) : next : next -30 mat print a -40 mat a=(3)*a -45 print -50 mat print a -60 data 1,2,3,4,5,6,7,8,9 -80 dim inch_array(5,1),cm_array(5,1) -90 mat read inch_array -100 data 1,12,36,100,39.37 -110 mat print inch_array -120 mat cm_array=(2.54)*inch_array -130 mat print cm_array - diff --git a/apps/examples/bas/tests/test26.bas b/apps/examples/bas/tests/test26.bas deleted file mode 100644 index 8055735a1..000000000 --- a/apps/examples/bas/tests/test26.bas +++ /dev/null @@ -1,5 +0,0 @@ -dim a(3,3) -data 5,5,5,8,8,8,3,3 -mat read a(2,3) -mat print a - diff --git a/apps/examples/bas/tests/test27.bas b/apps/examples/bas/tests/test27.bas deleted file mode 100644 index 92ba744a8..000000000 --- a/apps/examples/bas/tests/test27.bas +++ /dev/null @@ -1,8 +0,0 @@ -data 1,2,3,4 -mat read a(2,2) -mat print a -mat b=inv(a) -mat print b -mat c=a*b -mat print c - diff --git a/apps/examples/bas/tests/test28.bas b/apps/examples/bas/tests/test28.bas deleted file mode 100644 index d5185ca98..000000000 --- a/apps/examples/bas/tests/test28.bas +++ /dev/null @@ -1,6 +0,0 @@ -def fnfac(n) - if n=1 then fnreturn 1 -fnend n*fnfac(n-1) - -print fnfac(10) - diff --git a/apps/examples/bas/tests/test29.bas b/apps/examples/bas/tests/test29.bas deleted file mode 100644 index fbc20942c..000000000 --- a/apps/examples/bas/tests/test29.bas +++ /dev/null @@ -1,7 +0,0 @@ -print instr("123456789","456");" = 4?" -print INSTR("123456789","654");" = 0?" -print INSTR("1234512345","34");" = 3?" -print INSTR("1234512345","34",6);" = 8?" -print INSTR("1234512345","34",6,2);" = 0?" -print INSTR("1234512345","34",6,4);" = 8?" - diff --git a/apps/examples/bas/tests/test30.bas b/apps/examples/bas/tests/test30.bas deleted file mode 100644 index 06cea549a..000000000 --- a/apps/examples/bas/tests/test30.bas +++ /dev/null @@ -1,2 +0,0 @@ -print 1+"a" - diff --git a/apps/examples/bas/tests/test31.bas b/apps/examples/bas/tests/test31.bas deleted file mode 100644 index d168bd072..000000000 --- a/apps/examples/bas/tests/test31.bas +++ /dev/null @@ -1,7 +0,0 @@ -10 for i=-8 to 8 -20 x=1+1/3 : y=1 : j=i -30 for j=i to -1 : x=x/10 : y=y/10 : next -40 for j=i to 1 step -1 : x=x*10 : y=y*10 : next -50 print x,y -60 next - diff --git a/apps/examples/bas/tests/test32.bas b/apps/examples/bas/tests/test32.bas deleted file mode 100644 index 43fdc4cf5..000000000 --- a/apps/examples/bas/tests/test32.bas +++ /dev/null @@ -1,8 +0,0 @@ -PUTS("abc") -END - -SUB PUTS(s$) - FOR i=1 to LEN(s$) : print mid$(s$,i,1); : NEXT - PRINT -END SUB - diff --git a/apps/examples/bas/tests/test33.bas b/apps/examples/bas/tests/test33.bas deleted file mode 100644 index 2d64a4d05..000000000 --- a/apps/examples/bas/tests/test33.bas +++ /dev/null @@ -1,17 +0,0 @@ -open "test.out" for binary as 1 -put 1,1,"xy" -put 1,3,"z!" -put 1,10,1/3 -put 1,20,9999 -close 1 -open "test.out" for binary as 1 -s$=" " -get 1,1,s$ -get 1,10,x -get 1,20,n% -close -print s$ -print x -print n% -kill "test.out" - diff --git a/apps/examples/bas/tests/test34.bas b/apps/examples/bas/tests/test34.bas deleted file mode 100644 index 2cd77b914..000000000 --- a/apps/examples/bas/tests/test34.bas +++ /dev/null @@ -1,18 +0,0 @@ -option base 3 -dim a(3,5) -a(3,3)=1 -a(3,5)=2 - -print a(3,3) -print a(3,5) - -option base -2 -dim b(-1,2) -b(-2,-2)=10 -b(-1,2)=20 - -print a(3,3) -print a(3,5) -print b(-2,-2) -print b(-1,2) - diff --git a/apps/examples/bas/tests/test35.bas b/apps/examples/bas/tests/test35.bas deleted file mode 100644 index 158f20719..000000000 --- a/apps/examples/bas/tests/test35.bas +++ /dev/null @@ -1,9 +0,0 @@ -a%=1.2 -print a% -a%=1.7 -print a% -a%=-0.2 -print a% -a%=-0.7 -print a% - diff --git a/apps/examples/bas/tests/test36.bas b/apps/examples/bas/tests/test36.bas deleted file mode 100644 index c7bd6f054..000000000 --- a/apps/examples/bas/tests/test36.bas +++ /dev/null @@ -1,8 +0,0 @@ -on error goto 10 -print "opening file" -open "test.out" for output lock write as #1 -print "open succeeded" -if command$<>"enough" then shell "sh ./test/runbas test.bas enough" -end -10 print "open failed" - diff --git a/apps/examples/bas/tests/test37.bas b/apps/examples/bas/tests/test37.bas deleted file mode 100644 index 80f65a7de..000000000 --- a/apps/examples/bas/tests/test37.bas +++ /dev/null @@ -1,6 +0,0 @@ -10 open "i",1,"test.ref" -20 while not eof(1) -30 line input #1,a$ -40 if a$="abc" then print a$; else print "def" -50 wend - diff --git a/apps/examples/bas/tests/test38.bas b/apps/examples/bas/tests/test38.bas deleted file mode 100644 index c1b151eee..000000000 --- a/apps/examples/bas/tests/test38.bas +++ /dev/null @@ -1,9 +0,0 @@ -dim x(10) -mat read x -mat print x -mat redim x(7) -mat print x -mat redim x(12) -mat print x -data 1,2,3,4,5,6,7,8,9,10 - diff --git a/apps/examples/bas/tests/test39.bas b/apps/examples/bas/tests/test39.bas deleted file mode 100644 index 076c07be9..000000000 --- a/apps/examples/bas/tests/test39.bas +++ /dev/null @@ -1,12 +0,0 @@ -def proc_a(x) -print fn_b(1,x) -end proc - -def fn_b(a,b) -= a+fn_c(b) - -def fn_c(b) -= b+3 - -proc_a(2) - diff --git a/apps/examples/bas/tests/test40.bas b/apps/examples/bas/tests/test40.bas deleted file mode 100644 index 5ddc05009..000000000 --- a/apps/examples/bas/tests/test40.bas +++ /dev/null @@ -1,5 +0,0 @@ - d=3.1 - print using "#.#";d - print using 10;d -10 image #.## - diff --git a/apps/examples/bas/tests/test41.bas b/apps/examples/bas/tests/test41.bas deleted file mode 100644 index f307a866d..000000000 --- a/apps/examples/bas/tests/test41.bas +++ /dev/null @@ -1,9 +0,0 @@ -function f(c) -print "f running" -if (c) then f=42 : exit function -f=43 -end function - -print f(0) -print f(1) - diff --git a/apps/examples/bas/tests/test42.bas b/apps/examples/bas/tests/test42.bas deleted file mode 100644 index 5be79ac26..000000000 --- a/apps/examples/bas/tests/test42.bas +++ /dev/null @@ -1,9 +0,0 @@ -10 print 4.7\3 -20 print -2.3\1 -30 print int(-2.3) -40 print int(2.3) -50 print fix(-2.3) -60 print fix(2.3) -70 print fp(-2.3) -80 print fp(2.3) - diff --git a/apps/examples/bas/tests/test43.bas b/apps/examples/bas/tests/test43.bas deleted file mode 100644 index 26ac0dd02..000000000 --- a/apps/examples/bas/tests/test43.bas +++ /dev/null @@ -1,16 +0,0 @@ -DIM a(3,3),b(3,1),c(3,3) -MAT READ a -MAT READ b -MAT c=a*b -MAT PRINT c -DATA 1,2,3,4,5,6,7,8,9 -DATA 5,3,2 - -erase b -DIM b(3) -RESTORE -MAT READ a -MAT READ b -MAT c=a*b -MAT PRINT c - diff --git a/apps/examples/bas/tests/test44.bas b/apps/examples/bas/tests/test44.bas deleted file mode 100644 index 72cb37ccf..000000000 --- a/apps/examples/bas/tests/test44.bas +++ /dev/null @@ -1,8 +0,0 @@ -10 print 10 -20 print 20 -30 print 30 -40 print 40 -50 print 50 -60 print 60 -70 print 70 - diff --git a/apps/examples/bas/tests/test45.bas b/apps/examples/bas/tests/test45.bas deleted file mode 100644 index cea534dda..000000000 --- a/apps/examples/bas/tests/test45.bas +++ /dev/null @@ -1,9 +0,0 @@ -10 mid$(a$,6,4) = "ABCD" -20 print a$ -30 a$="0123456789" -40 mid$(a$,6,4) = "ABCD" -50 print a$ -60 a$="0123456789" -70 let mid$(a$,6,4) = "ABCD" -80 print a$ - diff --git a/apps/examples/bas/tests/test46.bas b/apps/examples/bas/tests/test46.bas deleted file mode 100644 index f7a08468d..000000000 --- a/apps/examples/bas/tests/test46.bas +++ /dev/null @@ -1,2 +0,0 @@ -for i=1 to 10:print i;:next i:end - diff --git a/apps/examples/bas/tests/test47.bas b/apps/examples/bas/tests/test47.bas deleted file mode 100644 index 960ac46c5..000000000 --- a/apps/examples/bas/tests/test47.bas +++ /dev/null @@ -1,10 +0,0 @@ -dim a(3,4) -for i=0 to 3 - for j=0 to 4 - a(i,j)=i*10+j - print a(i,j); - next - print -next -mat write a - diff --git a/apps/examples/bas/tests/test48.bas b/apps/examples/bas/tests/test48.bas deleted file mode 100644 index 223bc1c3e..000000000 --- a/apps/examples/bas/tests/test48.bas +++ /dev/null @@ -1,8 +0,0 @@ -a,b = 10 -print a,b -dim c(10) -a,c(a) = 2 -print a,c(2),c(10) -a$,b$="test" -print a$,b$ - diff --git a/apps/examples/bas/tests/test49.bas b/apps/examples/bas/tests/test49.bas deleted file mode 100644 index d9b167af0..000000000 --- a/apps/examples/bas/tests/test49.bas +++ /dev/null @@ -1,16 +0,0 @@ -width 120 -dim a(7,7),b(7,7) -mat read a -mat print a; -print -data 58,71,67,36,35,19,60 -data 50,71,71,56,45,20,52 -data 64,40,84,50,51,43,69 -data 31,28,41,54,31,18,33 -data 45,23,46,38,50,43,50 -data 41,10,28,17,33,41,46 -data 66,72,71,38,40,27,69 -mat b=inv(a) -mat print b -print det - diff --git a/apps/examples/bas/tests/test50.bas b/apps/examples/bas/tests/test50.bas deleted file mode 100644 index de12fbe87..000000000 --- a/apps/examples/bas/tests/test50.bas +++ /dev/null @@ -1,9 +0,0 @@ -print min(1,2) -print min(2,1) -print min(-0.3,0.3) -print min(-0.3,4) -print max(1,2) -print max(2,1) -print max(-0.3,0.3) -print max(-0.3,4) - diff --git a/apps/examples/bas/tests/test51.bas b/apps/examples/bas/tests/test51.bas deleted file mode 100644 index 503cb2693..000000000 --- a/apps/examples/bas/tests/test51.bas +++ /dev/null @@ -1,2 +0,0 @@ -PRINT "Line 1";TAB(78);1.23456789 - diff --git a/apps/examples/bas/tests/test52.bas b/apps/examples/bas/tests/test52.bas deleted file mode 100644 index 4470bb5b2..000000000 --- a/apps/examples/bas/tests/test52.bas +++ /dev/null @@ -1,6 +0,0 @@ -dim a(2,2) -mat input a -mat print a -mat input a -mat print a - diff --git a/apps/examples/bastest/.gitignore b/apps/examples/bastest/.gitignore new file mode 100644 index 000000000..fa1ec7579 --- /dev/null +++ b/apps/examples/bastest/.gitignore @@ -0,0 +1,11 @@ +/Make.dep +/.depend +/.built +/*.asm +/*.obj +/*.rel +/*.lst +/*.sym +/*.adb +/*.lib +/*.src diff --git a/apps/examples/bastest/Kconfig b/apps/examples/bastest/Kconfig new file mode 100644 index 000000000..3c56df48d --- /dev/null +++ b/apps/examples/bastest/Kconfig @@ -0,0 +1,31 @@ +# +# For a description of the syntax of this configuration file, +# see misc/tools/kconfig-language.txt. +# + +config EXAMPLES_BASTEST + bool "Setup Test Files for BAS" + default n + depends on INTERPRETERS_BAS + ---help--- + Mount the ROMFS file system containing the BAS test files. + +if EXAMPLES_BASTEST + +config EXAMPLES_BASTEST_DEVMINOR + int "ROMFS Minor Device Number" + default 0 + ---help--- + The minor device number of the ROMFS block. For example, the N in /dev/ramN. + Used for registering the RAM block driver that will hold the ROMFS file system + containing the BASIC files to be tested. Default: 0 + +config EXAMPLES_BASTEST_DEVPATH + string "ROMFS Device Path" + default "/dev/ram0" + ---help--- + The path to the ROMFS block driver device. This must match EXAMPLES_BASTEST_DEVMINOR. + Used for registering the RAM block driver that will hold the ROMFS file system + containing the BASIC files to be tested. Default: "/dev/ram0" + +endif diff --git a/apps/examples/bastest/Makefile b/apps/examples/bastest/Makefile new file mode 100644 index 000000000..144a9cfd6 --- /dev/null +++ b/apps/examples/bastest/Makefile @@ -0,0 +1,153 @@ +############################################################################ +# apps/examples/bastest/Makefile +# +# Copyright (C) 2014 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +-include $(TOPDIR)/.config +-include $(TOPDIR)/Make.defs +include $(APPDIR)/Make.defs + +# BAS test volume mounter + +APPNAME = bastest +PRIORITY = SCHED_PRIORITY_DEFAULT +STACKSIZE = 2048 + +# Hello, World! Example + +ASRCS = +CSRCS = +MAINSRC = bastest_main.c + +AOBJS = $(ASRCS:.S=$(OBJEXT)) +COBJS = $(CSRCS:.c=$(OBJEXT)) +MAINOBJ = $(MAINSRC:.c=$(OBJEXT)) + +SRCS = $(ASRCS) $(CSRCS) $(MAINSRC) +OBJS = $(AOBJS) $(COBJS) + +ifneq ($(CONFIG_BUILD_KERNEL),y) + OBJS += $(MAINOBJ) +endif + +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + BIN = ..\..\libapps$(LIBEXT) +else +ifeq ($(WINTOOL),y) + BIN = ..\\..\\libapps$(LIBEXT) +else + BIN = ../../libapps$(LIBEXT) +endif +endif + +ifeq ($(WINTOOL),y) + INSTALL_DIR = "${shell cygpath -w $(BIN_DIR)}" +else + INSTALL_DIR = $(BIN_DIR) +endif + +BASTEST_DIR = $(APPDIR)$(DELIM)examples$(DELIM)bastest +TESTS_DIR = $(BASTEST_DIR)$(DELIM)tests +ROMFS_IMG = $(BASTEST_DIR)$(DELIM)romfs.img +ROMFS_HDR = $(BASTEST_DIR)$(DELIM)romfs.h + +PROGNAME = bastest$(EXEEXT) + +ROOTDEPPATH = --dep-path . + +# Common build + +VPATH = + +all: .built +.PHONY: clean depend distclean + +$(AOBJS): %$(OBJEXT): %.S + $(call ASSEMBLE, $<, $@) + +$(COBJS) $(MAINOBJ): %$(OBJEXT): %.c + $(call COMPILE, $<, $@) + +.built: $(OBJS) + $(call ARCHIVE, $(BIN), $(OBJS)) + @touch .built + +# Create the romfs.h header file from the tests/ directory + +$(ROMFS_HDR) : $(ROMFS_IMG) + $(Q) genromfs -f $@ -d $(TESTS_DIR) -V "BASTEST" + $(Q) (xxd -i romfs.img | sed -e "s/^unsigned/static const unsigned/g" >$@) + +# Link and install the program binary + +ifeq ($(CONFIG_BUILD_KERNEL),y) +$(BIN_DIR)$(DELIM)$(PROGNAME): $(OBJS) $(MAINOBJ) + @echo "LD: $(PROGNAME)" + $(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $(INSTALL_DIR)$(DELIM)$(PROGNAME) $(ARCHCRT0OBJ) $(MAINOBJ) $(LDLIBS) + $(Q) $(NM) -u $(INSTALL_DIR)$(DELIM)$(PROGNAME) + +install: $(BIN_DIR)$(DELIM)$(PROGNAME) + +else +install: + +endif + +# Register the NSH builtin appliation + +ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile + $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) + +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif + +# Housekeeping stuff + +.depend: Makefile $(SRCS) + @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep + @touch $@ + +depend: .depend + +clean: + $(call DELFILE, .built) + $(call CLEAN) + +distclean: clean + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) + +-include Make.dep diff --git a/apps/examples/bastest/README.txt b/apps/examples/bastest/README.txt new file mode 100644 index 000000000..846fad0e0 --- /dev/null +++ b/apps/examples/bastest/README.txt @@ -0,0 +1,1628 @@ +README +====== + + This directory contains a small program that will mount a ROMFS file system + containing the BASIC test files extracted from the BAS 2.4 release. + +Background +========== + Bas is an interpreter for the classic dialect of the programming language + BASIC. It is pretty compatible to typical BASIC interpreters of the 1980s, + unlike some other UNIX BASIC interpreters, that implement a different + syntax, breaking compatibility to existing programs. Bas offers many ANSI + BASIC statements for structured programming, such as procedures, local + variables and various loop types. Further there are matrix operations, + automatic LIST indentation and many statements and functions found in + specific classic dialects. Line numbers are not required. + + The interpreter tokenises the source and resolves references to variables + and jump targets before running the program. This compilation pass + increases efficiency and catches syntax errors, type errors and references + to variables that are never initialised. Bas is written in ANSI C for + UNIX systems. + +License +======= + BAS 2.4 is released as part of NuttX under the standard 3-clause BSD license + use by all components of NuttX. This is not incompatible with the original + BAS 2.4 licensing + + Copyright (c) 1999-2014 Michael Haardt + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + +TEST OVERVIEW +============= + +test01.bas +========== +Scalar variable assignment + +Test File +--------- +10 a=1 +20 print a +30 a$="hello" +40 print a$ +50 a=0.0002 +60 print a +70 a=2.e-6 +80 print a +90 a=.2e-6 +100 print a + +Expected Result +--------------- + 1 +hello + 0.0002 + 2e-06 + 2e-07 + +test02.bas +========== +Array variable assignment + +Test File +--------- +10 dim a(1) +20 a(0)=10 +30 a(1)=11 +40 a=12 +50 print a(0) +60 print a(1) +70 print a + +Expected Result +--------------- + 10 + 11 + 12 + +test03.bas +========== +FOR loops + +Test File +--------- + 10 for i=0 to 10 + 20 print i + 30 if i=5 then exit for + 40 next + 50 for i=0 to 0 + 60 print i + 70 next I + 80 for i=1 to 0 step -1 + 90 print i +100 next +110 for i=1 to 0 +120 print i +130 next +140 for i$="" to "aaaaaaaaaa" step "a" +150 print i$ +160 next + +Expected Result +--------------- + 0 + 1 + 2 + 3 + 4 + 5 + 0 + 1 + 0 + +a +aa +aaa +aaaa +aaaaa +aaaaaa +aaaaaaa +aaaaaaaa +aaaaaaaaa +aaaaaaaaaa + +test04.bas +========== +REPEAT UNTIL loop + +Test File +--------- +10 a=1 +20 repeat +30 print a +40 a=a+1 +50 until a=10 + +Expected Result +--------------- + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + +test05.bas +========== +GOSUB RETURN subroutines + +Test File +--------- +10 gosub 100 +20 gosub 100 +30 end +100 gosub 200 +110 gosub 200 +120 return +200 print "hello, world":return + +Expected Result +--------------- +hello, world +hello, world +hello, world +hello, world + +test06.bas +========== +Recursive function without arguments + +Test File +--------- +10 def fnloop +20 if n=0.0 then +30 r=0.0 +40 else +50 print n +60 n=n-1.0 +70 r=fnloop() +80 end if +90 =r +100 n=10 +110 print fnloop + +Expected Result +--------------- + 10 + 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1 + 0 + +test07.bas +========== +Recursive function with arguments + +Test File +--------- +10 def fna(x) +20 if x=0 then r=1 else r=x*fna(x-1) +30 =r +40 print fna(7) + +Expected Result +--------------- + 5040 + +test08.bas +========== +DATA, READ and RESTORE + +Test File +--------- +10 data "a",b +20 data "c","d +40 read j$ +50 print "j=";j$ +60 restore 20 +70 for i=1 to 3 +80 read j$,k$ +90 print "j=";j$;" k=";k$ +100 next + +Expected Result +--------------- +j=a +j=c k=d +Error: end of `data' in line 80 at: +80 read j$,k$ + ^ + +test09.bas +========== +LOCAL variables + +Test File +--------- +10 def fna(a) +20 local b +30 b=a+1 +40 =b +60 b=3 +70 print b +80 print fna(4) +90 print b + +Expected Result +--------------- + 3 + 5 + 3 + +test10.bas +========== +PRINT USING + +Test File +--------- + 10 print using "!";"abcdef" + 20 print using "\ \";"abcdef" + 30 print using "###-";-1 + 40 print using "###-";0 + 50 print using "###-";1 + 60 print using "###+";-1 + 70 print using "###+";0 + 80 print using "###+";1 + 90 print using "#####,";1000 +100 print using "**#,##.##";1000.00 +110 print using "+##.##";1 +120 print using "+##.##";1.23400 +130 print using "+##.##";123.456 +140 print using "+##.";123.456 +150 print using "+##";123.456 +160 print using "abc def ###.## efg";1.3 +170 print using "###.##^^^^^";5 +180 print using "###.##^^^^";1000 +190 print using ".##^^^^";5.0 +200 print using "##^^^^";2.3e-9 +210 print using ".##^^^^";2.3e-9 +220 print using "#.#^^^^";2.3e-9 +230 print using ".####^^^^^";-011466 +240 print using "$*,***,***,***.**";3729825.24 +250 print using "$**********.**";3729825.24 +260 print using "$$###.##";456.78 +270 print using "a!b";"S" +280 print using "a!b";"S","T" +290 print using "a!b!c";"S" +300 print using "a!b!c";"S","T" + +Expected Result +--------------- +a +abc + 1- + 0 + 1 + 1- + 0+ + 1+ + 1,000 +*1,000.00 + +1.00 + +1.23 ++123.46 ++123. ++123 +abc def 1.30 efg +500.00E-002 +100.00E+01 +.50E+01 +23E-10 +.23E-08 +2.3E-09 +-.1147E+005 +$***3,729,825.24 +$**3729825.24 +$456.78 +aSb +aSbaTb +aSb +aSbTc + +test11.bas +========== +OPEN and LINE INPUT + +Test File +--------- +10 open "i",1,"test.bas" +20 while not eof(1) +30 line input #1,a$ +40 print a$ +50 wend + +Expected Result +--------------- +10 open "i",1,"test.bas" +20 while not eof(1) +30 line input #1,a$ +40 print a$ +50 wend + +test12.bas +========== +Exception handling + +Test File +--------- +10 on error print "global handler 1 caught error in line ";erl : resume 30 +20 print mid$("",-1) +30 on error print "global handler 2 caught error in line ";erl : end +40 def procx +50 on error print "local handler caught error in line";erl : goto 70 +60 print 1/0 +70 end proc +80 procx +90 print 1 mod 0 + +Expected Result +--------------- +global handler 1 caught error in line 20 +local handler caught error in line 60 +global handler 2 caught error in line 90 + +test01.bas +========== +Unnumbered lines + +Test File +--------- +print "a" +goto 20 +print "b" +20 print "c" + +Expected Result +--------------- +a +c + +test14.bas +========== +SELECT CASE + +Test File +--------- + 10 for i=0 to 9 + 20 for j=0 to 9 + 30 print i,j + 40 select case i + 50 case 0 + 60 print "i after case 0" + 70 case 1 + 80 print "i after case 1" + 90 select case j +100 case 0 +110 print "j after case 0" +120 end select +130 case 3 to 5,7 +140 print "i after case 3 to 5, 7" +150 case is <9 +160 print "is after case is <9" +170 case else +180 print "i after case else" +190 end select +200 next +210 next + +Expected Result +--------------- + 0 0 +i after case 0 + 0 1 +i after case 0 + 0 2 +i after case 0 + 0 3 +i after case 0 + 0 4 +i after case 0 + 0 5 +i after case 0 + 0 6 +i after case 0 + 0 7 +i after case 0 + 0 8 +i after case 0 + 0 9 +i after case 0 + 1 0 +i after case 1 +j after case 0 + 1 1 +i after case 1 + 1 2 +i after case 1 + 1 3 +i after case 1 + 1 4 +i after case 1 + 1 5 +i after case 1 + 1 6 +i after case 1 + 1 7 +i after case 1 + 1 8 +i after case 1 + 1 9 +i after case 1 + 2 0 +is after case is <9 + 2 1 +is after case is <9 + 2 2 +is after case is <9 + 2 3 +is after case is <9 + 2 4 +is after case is <9 + 2 5 +is after case is <9 + 2 6 +is after case is <9 + 2 7 +is after case is <9 + 2 8 +is after case is <9 + 2 9 +is after case is <9 + 3 0 +i after case 3 to 5, 7 + 3 1 +i after case 3 to 5, 7 + 3 2 +i after case 3 to 5, 7 + 3 3 +i after case 3 to 5, 7 + 3 4 +i after case 3 to 5, 7 + 3 5 +i after case 3 to 5, 7 + 3 6 +i after case 3 to 5, 7 + 3 7 +i after case 3 to 5, 7 + 3 8 +i after case 3 to 5, 7 + 3 9 +i after case 3 to 5, 7 + 4 0 +i after case 3 to 5, 7 + 4 1 +i after case 3 to 5, 7 + 4 2 +i after case 3 to 5, 7 + 4 3 +i after case 3 to 5, 7 + 4 4 +i after case 3 to 5, 7 + 4 5 +i after case 3 to 5, 7 + 4 6 +i after case 3 to 5, 7 + 4 7 +i after case 3 to 5, 7 + 4 8 +i after case 3 to 5, 7 + 4 9 +i after case 3 to 5, 7 + 5 0 +i after case 3 to 5, 7 + 5 1 +i after case 3 to 5, 7 + 5 2 +i after case 3 to 5, 7 + 5 3 +i after case 3 to 5, 7 + 5 4 +i after case 3 to 5, 7 + 5 5 +i after case 3 to 5, 7 + 5 6 +i after case 3 to 5, 7 + 5 7 +i after case 3 to 5, 7 + 5 8 +i after case 3 to 5, 7 + 5 9 +i after case 3 to 5, 7 + 6 0 +is after case is <9 + 6 1 +is after case is <9 + 6 2 +is after case is <9 + 6 3 +is after case is <9 + 6 4 +is after case is <9 + 6 5 +is after case is <9 + 6 6 +is after case is <9 + 6 7 +is after case is <9 + 6 8 +is after case is <9 + 6 9 +is after case is <9 + 7 0 +i after case 3 to 5, 7 + 7 1 +i after case 3 to 5, 7 + 7 2 +i after case 3 to 5, 7 + 7 3 +i after case 3 to 5, 7 + 7 4 +i after case 3 to 5, 7 + 7 5 +i after case 3 to 5, 7 + 7 6 +i after case 3 to 5, 7 + 7 7 +i after case 3 to 5, 7 + 7 8 +i after case 3 to 5, 7 + 7 9 +i after case 3 to 5, 7 + 8 0 +is after case is <9 + 8 1 +is after case is <9 + 8 2 +is after case is <9 + 8 3 +is after case is <9 + 8 4 +is after case is <9 + 8 5 +is after case is <9 + 8 6 +is after case is <9 + 8 7 +is after case is <9 + 8 8 +is after case is <9 + 8 9 +is after case is <9 + 9 0 +i after case else + 9 1 +i after case else + 9 2 +i after case else + 9 3 +i after case else + 9 4 +i after case else + 9 5 +i after case else + 9 6 +i after case else + 9 7 +i after case else + 9 8 +i after case else + 9 9 +i after case else + +test15.bas +========== +FIELD, PUT and GET + +Test File +--------- +a$="a" +open "r",1,"test.dat",128 +print "before field a$=";a$ +field #1,10 as a$ +field #1,5 as b$,5 as c$ +lset b$="hi" +rset c$="ya" +print "a$=";a$ +put #1 +close #1 +print "after close a$=";a$ +open "r",2,"test.dat",128 +field #2,10 as b$ +get #2 +print "after get b$=";b$ +close #2 +kill "test.dat" + +Expected Result +--------------- +before field a$=a +a$=hi ya +after close a$= +after get b$=hi ya + +test16.bas +========== +SWAP + +Test File +--------- +a=1 : b=2 +print "a=";a;"b=";b +swap a,b +print "a=";a;"b=";b +dim a$(1,1),b$(1,1) +a$(1,0)="a" : b$(0,1)="b" +print "a$(1,0)=";a$(1,0);"b$(0,1)=";b$(0,1) +swap a$(1,0),b$(0,1) +print "a$(1,0)=";a$(1,0);"b$(0,1)=";b$(0,1) + +Expected Result +--------------- +a= 1 b= 2 +a= 2 b= 1 +a$(1,0)=ab$(0,1)=b +a$(1,0)=bb$(0,1)=a + +test17.bas +========== +DO, EXIT DO, LOOP + +Test File +--------- +print "loop started" +i=1 +do + print "i is";i + i=i+1 + if i>10 then exit do +loop +print "loop ended" + +Expected Result +--------------- +loop started +i is 1 +i is 2 +i is 3 +i is 4 +i is 5 +i is 6 +i is 7 +i is 8 +i is 9 +i is 10 +loop ended + +test18.bas +========== +DO WHILE, LOOP + +Test File +--------- +print "loop started" +x$="" +do while len(x$)<3 + print "x$ is ";x$ + x$=x$+"a" + y$="" + do while len(y$)<2 + print "y$ is ";y$ + y$=y$+"b" + loop +loop +print "loop ended" + +Expected Result +--------------- +loop started +x$ is +y$ is +y$ is b +x$ is a +y$ is +y$ is b +x$ is aa +y$ is +y$ is b +loop ended + +test19.bas +========== +ELSEIF + +Test File +--------- +for x=1 to 3 + if x=1 then + print "1a" + else + if x=2 then + print "2a" + else + print "3a" + end if + end if +next + +for x=1 to 3 + if x=1 then + print "1b" + elseif x=2 then + print "2b" + elseif x=3 then print "3b" +next + +Expected Result +--------------- +1a +2a +3a +1b +2b +3b + +test20.bas +========== +Caller trace + +Test File +--------- + 10 gosub 20 + 20 gosub 30 + 30 procb + 40 def proca + 50 print "hi" + 60 stop + 70 end proc + 80 def procb + 90 proca +100 end proc + +Expected Result +--------------- +hi +Break in line 60 at: +60 stop + ^ +Proc Called in line 90 at: +90 proca + ^ +Proc Called in line 30 at: +30 procb + ^ +Called in line 20 at: +20 gosub 30 + ^ +Called in line 10 at: +10 gosub 20 + ^ + +test21.bas +========== +Matrix assignment + +Test File +--------- +dim a(3,4) +for i=0 to 3 + for j=0 to 4 + a(i,j)=i*10+j + print a(i,j); + next + print +next +mat b=a +for i=0 to 3 + for j=0 to 4 + print b(i,j); + next + print +next + +Expected Result +--------------- + 0 1 2 3 4 + 10 11 12 13 14 + 20 21 22 23 24 + 30 31 32 33 34 + 0 0 0 0 0 + 0 11 12 13 14 + 0 21 22 23 24 + 0 31 32 33 34 + +test22.bas +========== +MAT PRINT + +Test File +--------- +dim a(2,2) +for i=0 to 2 + for j=0 to 2 + a(i,j)=i*10+j + next +next +for j=1 to 2 + for i=1 to 2 + print using " ##.##";a(i,j), + next + print +next +mat print using " ##.##";a,a + +Expected Result +--------------- + 11.00 21.00 + 12.00 22.00 + 11.00 12.00 + 21.00 22.00 + + 11.00 12.00 + 21.00 22.00 + +test23.bas +========== +Matrix addition and subtraction + +Test File +--------- +dim a(2,2) +a(2,2)=2.5 +dim b%(2,2) +b%(2,2)=3 +mat print a +mat a=a-b% +mat print a +dim c$(2,2) +c$(2,1)="hi" +mat print c$ +mat c$=c$+c$ +mat print c$ + +Expected Result +--------------- + 0 0 + 0 2.5 + 0 0 + 0 -0.5 + +hi + +hihi + +test24.bas +========== +Matrix multiplication + +Test File +--------- +10 dim b(2,3),c(3,2) +20 for i=1 to 2 : for j=1 to 3 : read b(i,j) : next : next +30 for i=1 to 3 : for j=1 to 2 : read c(i,j) : next : next +40 mat a=b*c +50 mat print b,c,a +60 data 1,2,3,3,2,1 +70 data 1,2,2,1,3,3 + +Expected Result +--------------- + 1 2 3 + 3 2 1 + + 1 2 + 2 1 + 3 3 + + 14 13 + 10 11 + +test25.bas +========== +Matrix scalar multiplication + +Test File +--------- +10 dim a(3,3) +20 for i=1 to 3 : for j=1 to 3 : read a(i,j) : next : next +30 mat print a +40 mat a=(3)*a +45 print +50 mat print a +60 data 1,2,3,4,5,6,7,8,9 +80 dim inch_array(5,1),cm_array(5,1) +90 mat read inch_array +100 data 1,12,36,100,39.37 +110 mat print inch_array +120 mat cm_array=(2.54)*inch_array +130 mat print cm_array + +Expected Result +--------------- + 1 2 3 + 4 5 6 + 7 8 9 + + 3 6 9 + 12 15 18 + 21 24 27 + 1 + 12 + 36 + 100 + 39.37 + 2.54 + 30.48 + 91.44 + 254 + 99.9998 + +test26.bas +========== +MAT READ + +Test File +--------- +dim a(3,3) +data 5,5,5,8,8,8,3,3 +mat read a(2,3) +mat print a + +Expected Result +--------------- + 5 5 5 + 8 8 8 + +test27.bas +========== +Matrix inversion + +Test File +--------- +data 1,2,3,4 +mat read a(2,2) +mat print a +mat b=inv(a) +mat print b +mat c=a*b +mat print c + +Expected Result +--------------- + 1 2 + 3 4 +-2 1 + 1.5 -0.5 + 1 0 + 0 1 + +test28.bas +========== +TDL BASIC FNRETURN/FNEND + +Test File +--------- +def fnfac(n) + if n=1 then fnreturn 1 +fnend n*fnfac(n-1) + +print fnfac(10) + +Expected Result +--------------- + 3628800 + +test29.bas +========== +TDL INSTR + +Test File +--------- +print instr("123456789","456");" = 4?" +print INSTR("123456789","654");" = 0?" +print INSTR("1234512345","34");" = 3?" +print INSTR("1234512345","34",6);" = 8?" +print INSTR("1234512345","34",6,2);" = 0?" +print INSTR("1234512345","34",6,4);" = 8?" + +Expected Result +--------------- + 4 = 4? + 0 = 0? + 3 = 3? + 8 = 8? + 0 = 0? + 8 = 8? + +test30.bas +========== +Type mismatch check + +Test File +--------- +print 1+"a" + +Expected Result +--------------- +Error: Invalid binary operand at: end of program + +test31.bas +========== +PRINT default format + +Test File +--------- +10 for i=-8 to 8 +20 x=1+1/3 : y=1 : j=i +30 for j=i to -1 : x=x/10 : y=y/10 : next +40 for j=i to 1 step -1 : x=x*10 : y=y*10 : next +50 print x,y +60 next + +Expected Result +--------------- + 1.333333e-08 1e-08 + 1.333333e-07 1e-07 + 1.333333e-06 1e-06 + 1.333333e-05 1e-05 + 0.000133 0.0001 + 0.001333 0.001 + 0.013333 0.01 + 0.133333 0.1 + 1.333333 1 + 13.33333 10 + 133.3333 100 + 1333.333 1000 + 13333.33 10000 + 133333.3 100000 + 1333333 1000000 + 1.333333e+07 1e+07 + 1.333333e+08 1e+08 + +test032.bas +========== +SUB routines + +Test File +--------- +PUTS("abc") +END + +SUB PUTS(s$) + FOR i=1 to LEN(s$) : print mid$(s$,i,1); : NEXT + PRINT +END SUB + +Expected Result +--------------- +abc + +test33.bas +========== +OPEN FOR BINARY + +Test File +--------- +open "test.out" for binary as 1 +put 1,1,"xy" +put 1,3,"z!" +put 1,10,1/3 +put 1,20,9999 +close 1 +open "test.out" for binary as 1 +s$=" " +get 1,1,s$ +get 1,10,x +get 1,20,n% +close +print s$ +print x +print n% +kill "test.out" + +Expected Result +--------------- +xyz! + 0.333333 + 9999 + +test34.bas +========== +OPTION BASE + +Test File +--------- +option base 3 +dim a(3,5) +a(3,3)=1 +a(3,5)=2 + +print a(3,3) +print a(3,5) + +option base -2 +dim b(-1,2) +b(-2,-2)=10 +b(-1,2)=20 + +print a(3,3) +print a(3,5) +print b(-2,-2) +print b(-1,2) + +Expected Result +--------------- + 1 + 2 + 1 + 2 + 10 + 20 + +test35.bas +========== +Real to integer conversion + +Test File +--------- +a%=1.2 +print a% +a%=1.7 +print a% +a%=-0.2 +print a% +a%=-0.7 +print a% + +Expected Result +--------------- + 1 + 2 + 0 +-1 + +test36.bas +========== +OPEN file locking + +Test File +--------- +on error goto 10 +print "opening file" +open "test.out" for output lock write as #1 +print "open succeeded" +if command$<>"enough" then shell "sh ./test/runbas test.bas enough" +end +10 print "open failed" + +Expected Result +--------------- +opening file +open succeeded +opening file +open failed + +test37.bas +========== +LINE INPUT reaching EOF + +Test File +--------- +10 open "i",1,"test.ref" +20 while not eof(1) +30 line input #1,a$ +40 if a$="abc" then print a$; else print "def" +50 wend + +Result +------ + Output should match test.ref + +test38.bas +========== +MAT REDIM + +Test File +--------- +dim x(10) +mat read x +mat print x +mat redim x(7) +mat print x +mat redim x(12) +mat print x +data 1,2,3,4,5,6,7,8,9,10 + +Expected Result +--------------- + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 0 + 0 + 0 + 0 + 0 + +test39.bas +========== +Nested function and procedure calls + +Test File +--------- +def proc_a(x) +print fn_b(1,x) +end proc + +def fn_b(a,b) += a+fn_c(b) + +def fn_c(b) += b+3 + +proc_a(2) + +Expected Result +--------------- + 6 + +test40.bas +========== +IMAGE + +Test File +--------- + d=3.1 + print using "#.#";d + print using 10;d +10 image #.## + +Expected Result +--------------- +3.1 +3.10 + +test41.bas +========== +EXIT FUNCTION + +Test File +--------- +function f(c) +print "f running" +if (c) then f=42 : exit function +f=43 +end function + +print f(0) +print f(1) + +Expected Result +--------------- +f running + 43 +f running + 42 + +test42.bas +========== +Arithmetic + +Test File +--------- +10 print 4.7\3 +20 print -2.3\1 +30 print int(-2.3) +40 print int(2.3) +50 print fix(-2.3) +60 print fix(2.3) +70 print fp(-2.3) +80 print fp(2.3) + +Expected Result +--------------- + 1 +-2 +-3 + 2 +-2 + 2 +-0.3 + 0.3 + +test43.bas +========== +Matrix multiplication size checks + +Test File +--------- +DIM a(3,3),b(3,1),c(3,3) +MAT READ a +MAT READ b +MAT c=a*b +MAT PRINT c +DATA 1,2,3,4,5,6,7,8,9 +DATA 5,3,2 + +erase b +DIM b(3) +RESTORE +MAT READ a +MAT READ b +MAT c=a*b +MAT PRINT c + +Expected Result +--------------- + 17 + 47 + 77 +Error: Dimension mismatch in line 14 at: +mat c=a*b + ^ + +test44.bas +========== +DELETE + +Test File +--------- +10 print 10 +20 print 20 +30 print 30 +40 print 40 +50 print 50 +60 print 60 +70 print 70 + +Usage +----- +load "test.bas" +delete -20 +delete 60- +delete 30-40 +delete 15 +list + +Expected Result +--------------- +Error: No such line at: 15 +50 print 50 + +test45.bas +========== +MID$ on left side + +Test File +--------- +10 mid$(a$,6,4) = "ABCD" +20 print a$ +30 a$="0123456789" +40 mid$(a$,6,4) = "ABCD" +50 print a$ +60 a$="0123456789" +70 let mid$(a$,6,4) = "ABCD" +80 print a$ + +Expected Result +--------------- + +01234ABCD9 +01234ABCD9 + +test46.bas +========== +END used without program + +Test File +--------- +for i=1 to 10:print i;:next i:end + +Expected Result +--------------- + 1 2 3 4 5 6 7 8 9 10 + +test47.bas +========== +MAT WRITE + +Test File +--------- +dim a(3,4) +for i=0 to 3 + for j=0 to 4 + a(i,j)=i*10+j + print a(i,j); + next + print +next +mat write a + +Expected Result +--------------- + 0 1 2 3 4 + 10 11 12 13 14 + 20 21 22 23 24 + 30 31 32 33 34 +11,12,13,14 +21,22,23,24 +31,32,33,34 + +test48.bas +========== +Multi assignment + +Test File +--------- +a,b = 10 +print a,b +dim c(10) +a,c(a) = 2 +print a,c(2),c(10) +a$,b$="test" +print a$,b$ + +Expected Result +--------------- + 10 10 + 2 0 2 +test test + +test49.bas +========== +Matrix determinant + +Test File +--------- +width 120 +dim a(7,7),b(7,7) +mat read a +mat print a; +print +data 58,71,67,36,35,19,60 +data 50,71,71,56,45,20,52 +data 64,40,84,50,51,43,69 +data 31,28,41,54,31,18,33 +data 45,23,46,38,50,43,50 +data 41,10,28,17,33,41,46 +data 66,72,71,38,40,27,69 +mat b=inv(a) +mat print b +print det + +Expected Result +--------------- + 58 71 67 36 35 19 60 + 50 71 71 56 45 20 52 + 64 40 84 50 51 43 69 + 31 28 41 54 31 18 33 + 45 23 46 38 50 43 50 + 41 10 28 17 33 41 46 + 66 72 71 38 40 27 69 + + 9.636025e+07 320206 -537449 2323650 -1.135486e+07 3.019632e+07 + -9.650941e+07 + 4480 15 -25 108 -528 1404 -4487 +-39436 -131 220 -951 4647 -12358 39497 + 273240 908 -1524 6589 -32198 85625 -273663 +-1846174 -6135 10297 -44519 217549 -578534 1849032 + 1.315035e+07 43699 -73346 317110 -1549606 4120912 -1.31707e+07 + +-9.636079e+07 -320208 537452 -2323663 1.135493e+07 -3.019649e+07 + 9.650995e+07 + 1 + +test50.bas +========== +Min and max function + +Test File +--------- +print min(1,2) +print min(2,1) +print min(-0.3,0.3) +print min(-0.3,4) +print max(1,2) +print max(2,1) +print max(-0.3,0.3) +print max(-0.3,4) + +Expected Result +--------------- + 1 + 1 +-0.3 +-0.3 + 2 + 2 + 0.3 + 4 + +test51.bas +========== +Print items + +Test File +--------- +PRINT "Line 1";TAB(78);1.23456789 + +Expected Result +--------------- +Line 1 + 1.234568 + +test52.bas +========== +MAT INPUT + +Test File +--------- +dim a(2,2) +mat input a +mat print a +mat input a +mat print a + +Test File +--------- +1,2,3,4,5 +1 +3,4 + +Expected Result +--------------- +? + 1 2 + 3 4 +? ? + 1 0 + 3 4 diff --git a/apps/examples/bastest/bastest_main.c b/apps/examples/bastest/bastest_main.c new file mode 100644 index 000000000..3cf70c681 --- /dev/null +++ b/apps/examples/bastest/bastest_main.c @@ -0,0 +1,121 @@ +/**************************************************************************** + * examples/bastest/bastest_main.c + * + * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#include "romfs.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ +/* Check configuration. This is not all of the configuration settings that + * are required -- only the more obvious. + */ + +#if CONFIG_NFILE_DESCRIPTORS < 1 +# error "You must provide file descriptors via CONFIG_NFILE_DESCRIPTORS in your configuration file" +#endif + +#ifndef CONFIG_FS_ROMFS +# error "You must select CONFIG_FS_ROMFS in your configuration file" +#endif + +#ifdef CONFIG_DISABLE_MOUNTPOINT +# error "You must not disable mountpoints via CONFIG_DISABLE_MOUNTPOINT in your configuration file" +#endif + +/* Describe the ROMFS file system */ + +#define SECTORSIZE 512 +#define NSECTORS(b) (((b)+SECTORSIZE-1)/SECTORSIZE) +#define MOUNTPT "/mnt/romfs" + +#ifndef CONFIG_EXAMPLES_BASTEST_DEVMINOR +# define CONFIG_EXAMPLES_BASTEST_DEVMINOR 0 +#endif + +#ifndef CONFIG_EXAMPLES_BASTEST_DEVPATH +# define CONFIG_EXAMPLES_BASTEST_DEVPATH "/dev/ram0" +#endif + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * bastest_main + ****************************************************************************/ + +#ifdef CONFIG_BUILD_KERNEL +int main(int argc, FAR char *argv[]) +#else +int bastest_main(int argc, char *argv[]) +#endif +{ + /* Create a ROM disk for the ROMFS filesystem */ + + printf("Registering romdisk at /dev/ram%d\n", CONFIG_EXAMPLES_BASTEST_DEVMINOR); + ret = romdisk_register(CONFIG_EXAMPLES_BASTEST_DEVMINOR, (FAR uint8_t *)romfs_img, + NSECTORS(romfs_img_len), SECTORSIZE); + if (ret < 0) + { + err("ERROR: romdisk_register failed: %d\n", ret); + return 1; + } + + /* Mount the file system */ + + message("Mounting ROMFS filesystem at target=%s with source=%s\n", + MOUNTPT, CONFIG_EXAMPLES_BASTEST_DEVPATH); + + ret = mount(CONFIG_EXAMPLES_BASTEST_DEVPATH, MOUNTPT, "romfs", MS_RDONLY, NULL); + if (ret < 0) + { + err("ERROR: mount(%s,%s,romfs) failed: %s\n", + CONFIG_EXAMPLES_BASTEST_DEVPATH, MOUNTPT, errno); + return 1; + } + + return 0; +} diff --git a/apps/examples/bastest/tests/test01.bas b/apps/examples/bastest/tests/test01.bas new file mode 100644 index 000000000..d2c3494e0 --- /dev/null +++ b/apps/examples/bastest/tests/test01.bas @@ -0,0 +1,10 @@ +10 a=1 +20 print a +30 a$="hello" +40 print a$ +50 a=0.0002 +60 print a +70 a=2.e-6 +80 print a +90 a=.2e-6 +100 print a diff --git a/apps/examples/bastest/tests/test02.bas b/apps/examples/bastest/tests/test02.bas new file mode 100644 index 000000000..cc8b50ebc --- /dev/null +++ b/apps/examples/bastest/tests/test02.bas @@ -0,0 +1,8 @@ +10 dim a(1) +20 a(0)=10 +30 a(1)=11 +40 a=12 +50 print a(0) +60 print a(1) +70 print a + diff --git a/apps/examples/bastest/tests/test03.bas b/apps/examples/bastest/tests/test03.bas new file mode 100644 index 000000000..5d991d330 --- /dev/null +++ b/apps/examples/bastest/tests/test03.bas @@ -0,0 +1,16 @@ + 10 for i=0 to 10 + 20 print i + 30 if i=5 then exit for + 40 next + 50 for i=0 to 0 + 60 print i + 70 next I + 80 for i=1 to 0 step -1 + 90 print i +100 next +110 for i=1 to 0 +120 print i +130 next +140 for i$="" to "aaaaaaaaaa" step "a" +150 print i$ +160 next diff --git a/apps/examples/bastest/tests/test04.bas b/apps/examples/bastest/tests/test04.bas new file mode 100644 index 000000000..f2755e5a9 --- /dev/null +++ b/apps/examples/bastest/tests/test04.bas @@ -0,0 +1,6 @@ +10 a=1 +20 repeat +30 print a +40 a=a+1 +50 until a=10 + diff --git a/apps/examples/bastest/tests/test05.bas b/apps/examples/bastest/tests/test05.bas new file mode 100644 index 000000000..49100a00e --- /dev/null +++ b/apps/examples/bastest/tests/test05.bas @@ -0,0 +1,8 @@ +10 gosub 100 +20 gosub 100 +30 end +100 gosub 200 +110 gosub 200 +120 return +200 print "hello, world":return + diff --git a/apps/examples/bastest/tests/test06.bas b/apps/examples/bastest/tests/test06.bas new file mode 100644 index 000000000..ddd6efe78 --- /dev/null +++ b/apps/examples/bastest/tests/test06.bas @@ -0,0 +1,12 @@ +10 def fnloop +20 if n=0.0 then +30 r=0.0 +40 else +50 print n +60 n=n-1.0 +70 r=fnloop() +80 end if +90 =r +100 n=10 +110 print fnloop + diff --git a/apps/examples/bastest/tests/test07.bas b/apps/examples/bastest/tests/test07.bas new file mode 100644 index 000000000..12c0cbdc7 --- /dev/null +++ b/apps/examples/bastest/tests/test07.bas @@ -0,0 +1,5 @@ +10 def fna(x) +20 if x=0 then r=1 else r=x*fna(x-1) +30 =r +40 print fna(7) + diff --git a/apps/examples/bastest/tests/test08.bas b/apps/examples/bastest/tests/test08.bas new file mode 100644 index 000000000..0e6f13ad6 --- /dev/null +++ b/apps/examples/bastest/tests/test08.bas @@ -0,0 +1,10 @@ +10 data "a",b +20 data "c","d +40 read j$ +50 print "j=";j$ +60 restore 20 +70 for i=1 to 3 +80 read j$,k$ +90 print "j=";j$;" k=";k$ +100 next + diff --git a/apps/examples/bastest/tests/test09.bas b/apps/examples/bastest/tests/test09.bas new file mode 100644 index 000000000..7d5f72735 --- /dev/null +++ b/apps/examples/bastest/tests/test09.bas @@ -0,0 +1,9 @@ +10 def fna(a) +20 local b +30 b=a+1 +40 =b +60 b=3 +70 print b +80 print fna(4) +90 print b + diff --git a/apps/examples/bastest/tests/test10.bas b/apps/examples/bastest/tests/test10.bas new file mode 100644 index 000000000..41a935cca --- /dev/null +++ b/apps/examples/bastest/tests/test10.bas @@ -0,0 +1,31 @@ + 10 print using "!";"abcdef" + 20 print using "\ \";"abcdef" + 30 print using "###-";-1 + 40 print using "###-";0 + 50 print using "###-";1 + 60 print using "###+";-1 + 70 print using "###+";0 + 80 print using "###+";1 + 90 print using "#####,";1000 +100 print using "**#,##.##";1000.00 +110 print using "+##.##";1 +120 print using "+##.##";1.23400 +130 print using "+##.##";123.456 +140 print using "+##.";123.456 +150 print using "+##";123.456 +160 print using "abc def ###.## efg";1.3 +170 print using "###.##^^^^^";5 +180 print using "###.##^^^^";1000 +190 print using ".##^^^^";5.0 +200 print using "##^^^^";2.3e-9 +210 print using ".##^^^^";2.3e-9 +220 print using "#.#^^^^";2.3e-9 +230 print using ".####^^^^^";-011466 +240 print using "$*,***,***,***.**";3729825.24 +250 print using "$**********.**";3729825.24 +260 print using "$$###.##";456.78 +270 print using "a!b";"S" +280 print using "a!b";"S","T" +290 print using "a!b!c";"S" +300 print using "a!b!c";"S","T" + diff --git a/apps/examples/bastest/tests/test11.bas b/apps/examples/bastest/tests/test11.bas new file mode 100644 index 000000000..78eb6d1c6 --- /dev/null +++ b/apps/examples/bastest/tests/test11.bas @@ -0,0 +1,6 @@ +10 open "i",1,"test.bas" +20 while not eof(1) +30 line input #1,a$ +40 print a$ +50 wend + diff --git a/apps/examples/bastest/tests/test12.bas b/apps/examples/bastest/tests/test12.bas new file mode 100644 index 000000000..ecbb9d138 --- /dev/null +++ b/apps/examples/bastest/tests/test12.bas @@ -0,0 +1,10 @@ +10 on error print "global handler 1 caught error in line ";erl : resume 30 +20 print mid$("",-1) +30 on error print "global handler 2 caught error in line ";erl : end +40 def procx +50 on error print "local handler caught error in line";erl : goto 70 +60 print 1/0 +70 end proc +80 procx +90 print 1 mod 0 + diff --git a/apps/examples/bastest/tests/test13.bas b/apps/examples/bastest/tests/test13.bas new file mode 100644 index 000000000..e3be7a00b --- /dev/null +++ b/apps/examples/bastest/tests/test13.bas @@ -0,0 +1,4 @@ +print "a" +goto 20 +print "b" +20 print "c" diff --git a/apps/examples/bastest/tests/test14.bas b/apps/examples/bastest/tests/test14.bas new file mode 100644 index 000000000..56040112a --- /dev/null +++ b/apps/examples/bastest/tests/test14.bas @@ -0,0 +1,22 @@ + 10 for i=0 to 9 + 20 for j=0 to 9 + 30 print i,j + 40 select case i + 50 case 0 + 60 print "i after case 0" + 70 case 1 + 80 print "i after case 1" + 90 select case j +100 case 0 +110 print "j after case 0" +120 end select +130 case 3 to 5,7 +140 print "i after case 3 to 5, 7" +150 case is <9 +160 print "is after case is <9" +170 case else +180 print "i after case else" +190 end select +200 next +210 next + diff --git a/apps/examples/bastest/tests/test15.bas b/apps/examples/bastest/tests/test15.bas new file mode 100644 index 000000000..a9195bf4b --- /dev/null +++ b/apps/examples/bastest/tests/test15.bas @@ -0,0 +1,18 @@ +a$="a" +open "r",1,"test.dat",128 +print "before field a$=";a$ +field #1,10 as a$ +field #1,5 as b$,5 as c$ +lset b$="hi" +rset c$="ya" +print "a$=";a$ +put #1 +close #1 +print "after close a$=";a$ +open "r",2,"test.dat",128 +field #2,10 as b$ +get #2 +print "after get b$=";b$ +close #2 +kill "test.dat" + diff --git a/apps/examples/bastest/tests/test16.bas b/apps/examples/bastest/tests/test16.bas new file mode 100644 index 000000000..809137d75 --- /dev/null +++ b/apps/examples/bastest/tests/test16.bas @@ -0,0 +1,10 @@ +a=1 : b=2 +print "a=";a;"b=";b +swap a,b +print "a=";a;"b=";b +dim a$(1,1),b$(1,1) +a$(1,0)="a" : b$(0,1)="b" +print "a$(1,0)=";a$(1,0);"b$(0,1)=";b$(0,1) +swap a$(1,0),b$(0,1) +print "a$(1,0)=";a$(1,0);"b$(0,1)=";b$(0,1) + diff --git a/apps/examples/bastest/tests/test17.bas b/apps/examples/bastest/tests/test17.bas new file mode 100644 index 000000000..bfe0c9c2c --- /dev/null +++ b/apps/examples/bastest/tests/test17.bas @@ -0,0 +1,9 @@ +print "loop started" +i=1 +do + print "i is";i + i=i+1 + if i>10 then exit do +loop +print "loop ended" + diff --git a/apps/examples/bastest/tests/test18.bas b/apps/examples/bastest/tests/test18.bas new file mode 100644 index 000000000..73ab93e1b --- /dev/null +++ b/apps/examples/bastest/tests/test18.bas @@ -0,0 +1,13 @@ +print "loop started" +x$="" +do while len(x$)<3 + print "x$ is ";x$ + x$=x$+"a" + y$="" + do while len(y$)<2 + print "y$ is ";y$ + y$=y$+"b" + loop +loop +print "loop ended" + diff --git a/apps/examples/bastest/tests/test19.bas b/apps/examples/bastest/tests/test19.bas new file mode 100644 index 000000000..aa19fa4ae --- /dev/null +++ b/apps/examples/bastest/tests/test19.bas @@ -0,0 +1,20 @@ +for x=1 to 3 + if x=1 then + print "1a" + else + if x=2 then + print "2a" + else + print "3a" + end if + end if +next + +for x=1 to 3 + if x=1 then + print "1b" + elseif x=2 then + print "2b" + elseif x=3 then print "3b" +next + diff --git a/apps/examples/bastest/tests/test20.bas b/apps/examples/bastest/tests/test20.bas new file mode 100644 index 000000000..6b982bf89 --- /dev/null +++ b/apps/examples/bastest/tests/test20.bas @@ -0,0 +1,11 @@ + 10 gosub 20 + 20 gosub 30 + 30 procb + 40 def proca + 50 print "hi" + 60 stop + 70 end proc + 80 def procb + 90 proca +100 end proc + diff --git a/apps/examples/bastest/tests/test21.bas b/apps/examples/bastest/tests/test21.bas new file mode 100644 index 000000000..dd0f63beb --- /dev/null +++ b/apps/examples/bastest/tests/test21.bas @@ -0,0 +1,16 @@ +dim a(3,4) +for i=0 to 3 + for j=0 to 4 + a(i,j)=i*10+j + print a(i,j); + next + print +next +mat b=a +for i=0 to 3 + for j=0 to 4 + print b(i,j); + next + print +next + diff --git a/apps/examples/bastest/tests/test22.bas b/apps/examples/bastest/tests/test22.bas new file mode 100644 index 000000000..e10b03a14 --- /dev/null +++ b/apps/examples/bastest/tests/test22.bas @@ -0,0 +1,14 @@ +dim a(2,2) +for i=0 to 2 + for j=0 to 2 + a(i,j)=i*10+j + next +next +for j=1 to 2 + for i=1 to 2 + print using " ##.##";a(i,j), + next + print +next +mat print using " ##.##";a,a + diff --git a/apps/examples/bastest/tests/test23.bas b/apps/examples/bastest/tests/test23.bas new file mode 100644 index 000000000..faf5c5593 --- /dev/null +++ b/apps/examples/bastest/tests/test23.bas @@ -0,0 +1,13 @@ +dim a(2,2) +a(2,2)=2.5 +dim b%(2,2) +b%(2,2)=3 +mat print a +mat a=a-b% +mat print a +dim c$(2,2) +c$(2,1)="hi" +mat print c$ +mat c$=c$+c$ +mat print c$ + diff --git a/apps/examples/bastest/tests/test24.bas b/apps/examples/bastest/tests/test24.bas new file mode 100644 index 000000000..95678830b --- /dev/null +++ b/apps/examples/bastest/tests/test24.bas @@ -0,0 +1,8 @@ +10 dim b(2,3),c(3,2) +20 for i=1 to 2 : for j=1 to 3 : read b(i,j) : next : next +30 for i=1 to 3 : for j=1 to 2 : read c(i,j) : next : next +40 mat a=b*c +50 mat print b,c,a +60 data 1,2,3,3,2,1 +70 data 1,2,2,1,3,3 + diff --git a/apps/examples/bastest/tests/test25.bas b/apps/examples/bastest/tests/test25.bas new file mode 100644 index 000000000..bf4d34c93 --- /dev/null +++ b/apps/examples/bastest/tests/test25.bas @@ -0,0 +1,14 @@ +10 dim a(3,3) +20 for i=1 to 3 : for j=1 to 3 : read a(i,j) : next : next +30 mat print a +40 mat a=(3)*a +45 print +50 mat print a +60 data 1,2,3,4,5,6,7,8,9 +80 dim inch_array(5,1),cm_array(5,1) +90 mat read inch_array +100 data 1,12,36,100,39.37 +110 mat print inch_array +120 mat cm_array=(2.54)*inch_array +130 mat print cm_array + diff --git a/apps/examples/bastest/tests/test26.bas b/apps/examples/bastest/tests/test26.bas new file mode 100644 index 000000000..8055735a1 --- /dev/null +++ b/apps/examples/bastest/tests/test26.bas @@ -0,0 +1,5 @@ +dim a(3,3) +data 5,5,5,8,8,8,3,3 +mat read a(2,3) +mat print a + diff --git a/apps/examples/bastest/tests/test27.bas b/apps/examples/bastest/tests/test27.bas new file mode 100644 index 000000000..92ba744a8 --- /dev/null +++ b/apps/examples/bastest/tests/test27.bas @@ -0,0 +1,8 @@ +data 1,2,3,4 +mat read a(2,2) +mat print a +mat b=inv(a) +mat print b +mat c=a*b +mat print c + diff --git a/apps/examples/bastest/tests/test28.bas b/apps/examples/bastest/tests/test28.bas new file mode 100644 index 000000000..d5185ca98 --- /dev/null +++ b/apps/examples/bastest/tests/test28.bas @@ -0,0 +1,6 @@ +def fnfac(n) + if n=1 then fnreturn 1 +fnend n*fnfac(n-1) + +print fnfac(10) + diff --git a/apps/examples/bastest/tests/test29.bas b/apps/examples/bastest/tests/test29.bas new file mode 100644 index 000000000..fbc20942c --- /dev/null +++ b/apps/examples/bastest/tests/test29.bas @@ -0,0 +1,7 @@ +print instr("123456789","456");" = 4?" +print INSTR("123456789","654");" = 0?" +print INSTR("1234512345","34");" = 3?" +print INSTR("1234512345","34",6);" = 8?" +print INSTR("1234512345","34",6,2);" = 0?" +print INSTR("1234512345","34",6,4);" = 8?" + diff --git a/apps/examples/bastest/tests/test30.bas b/apps/examples/bastest/tests/test30.bas new file mode 100644 index 000000000..06cea549a --- /dev/null +++ b/apps/examples/bastest/tests/test30.bas @@ -0,0 +1,2 @@ +print 1+"a" + diff --git a/apps/examples/bastest/tests/test31.bas b/apps/examples/bastest/tests/test31.bas new file mode 100644 index 000000000..d168bd072 --- /dev/null +++ b/apps/examples/bastest/tests/test31.bas @@ -0,0 +1,7 @@ +10 for i=-8 to 8 +20 x=1+1/3 : y=1 : j=i +30 for j=i to -1 : x=x/10 : y=y/10 : next +40 for j=i to 1 step -1 : x=x*10 : y=y*10 : next +50 print x,y +60 next + diff --git a/apps/examples/bastest/tests/test32.bas b/apps/examples/bastest/tests/test32.bas new file mode 100644 index 000000000..43fdc4cf5 --- /dev/null +++ b/apps/examples/bastest/tests/test32.bas @@ -0,0 +1,8 @@ +PUTS("abc") +END + +SUB PUTS(s$) + FOR i=1 to LEN(s$) : print mid$(s$,i,1); : NEXT + PRINT +END SUB + diff --git a/apps/examples/bastest/tests/test33.bas b/apps/examples/bastest/tests/test33.bas new file mode 100644 index 000000000..2d64a4d05 --- /dev/null +++ b/apps/examples/bastest/tests/test33.bas @@ -0,0 +1,17 @@ +open "test.out" for binary as 1 +put 1,1,"xy" +put 1,3,"z!" +put 1,10,1/3 +put 1,20,9999 +close 1 +open "test.out" for binary as 1 +s$=" " +get 1,1,s$ +get 1,10,x +get 1,20,n% +close +print s$ +print x +print n% +kill "test.out" + diff --git a/apps/examples/bastest/tests/test34.bas b/apps/examples/bastest/tests/test34.bas new file mode 100644 index 000000000..2cd77b914 --- /dev/null +++ b/apps/examples/bastest/tests/test34.bas @@ -0,0 +1,18 @@ +option base 3 +dim a(3,5) +a(3,3)=1 +a(3,5)=2 + +print a(3,3) +print a(3,5) + +option base -2 +dim b(-1,2) +b(-2,-2)=10 +b(-1,2)=20 + +print a(3,3) +print a(3,5) +print b(-2,-2) +print b(-1,2) + diff --git a/apps/examples/bastest/tests/test35.bas b/apps/examples/bastest/tests/test35.bas new file mode 100644 index 000000000..158f20719 --- /dev/null +++ b/apps/examples/bastest/tests/test35.bas @@ -0,0 +1,9 @@ +a%=1.2 +print a% +a%=1.7 +print a% +a%=-0.2 +print a% +a%=-0.7 +print a% + diff --git a/apps/examples/bastest/tests/test36.bas b/apps/examples/bastest/tests/test36.bas new file mode 100644 index 000000000..c7bd6f054 --- /dev/null +++ b/apps/examples/bastest/tests/test36.bas @@ -0,0 +1,8 @@ +on error goto 10 +print "opening file" +open "test.out" for output lock write as #1 +print "open succeeded" +if command$<>"enough" then shell "sh ./test/runbas test.bas enough" +end +10 print "open failed" + diff --git a/apps/examples/bastest/tests/test37.bas b/apps/examples/bastest/tests/test37.bas new file mode 100644 index 000000000..80f65a7de --- /dev/null +++ b/apps/examples/bastest/tests/test37.bas @@ -0,0 +1,6 @@ +10 open "i",1,"test.ref" +20 while not eof(1) +30 line input #1,a$ +40 if a$="abc" then print a$; else print "def" +50 wend + diff --git a/apps/examples/bastest/tests/test38.bas b/apps/examples/bastest/tests/test38.bas new file mode 100644 index 000000000..c1b151eee --- /dev/null +++ b/apps/examples/bastest/tests/test38.bas @@ -0,0 +1,9 @@ +dim x(10) +mat read x +mat print x +mat redim x(7) +mat print x +mat redim x(12) +mat print x +data 1,2,3,4,5,6,7,8,9,10 + diff --git a/apps/examples/bastest/tests/test39.bas b/apps/examples/bastest/tests/test39.bas new file mode 100644 index 000000000..076c07be9 --- /dev/null +++ b/apps/examples/bastest/tests/test39.bas @@ -0,0 +1,12 @@ +def proc_a(x) +print fn_b(1,x) +end proc + +def fn_b(a,b) += a+fn_c(b) + +def fn_c(b) += b+3 + +proc_a(2) + diff --git a/apps/examples/bastest/tests/test40.bas b/apps/examples/bastest/tests/test40.bas new file mode 100644 index 000000000..5ddc05009 --- /dev/null +++ b/apps/examples/bastest/tests/test40.bas @@ -0,0 +1,5 @@ + d=3.1 + print using "#.#";d + print using 10;d +10 image #.## + diff --git a/apps/examples/bastest/tests/test41.bas b/apps/examples/bastest/tests/test41.bas new file mode 100644 index 000000000..f307a866d --- /dev/null +++ b/apps/examples/bastest/tests/test41.bas @@ -0,0 +1,9 @@ +function f(c) +print "f running" +if (c) then f=42 : exit function +f=43 +end function + +print f(0) +print f(1) + diff --git a/apps/examples/bastest/tests/test42.bas b/apps/examples/bastest/tests/test42.bas new file mode 100644 index 000000000..5be79ac26 --- /dev/null +++ b/apps/examples/bastest/tests/test42.bas @@ -0,0 +1,9 @@ +10 print 4.7\3 +20 print -2.3\1 +30 print int(-2.3) +40 print int(2.3) +50 print fix(-2.3) +60 print fix(2.3) +70 print fp(-2.3) +80 print fp(2.3) + diff --git a/apps/examples/bastest/tests/test43.bas b/apps/examples/bastest/tests/test43.bas new file mode 100644 index 000000000..26ac0dd02 --- /dev/null +++ b/apps/examples/bastest/tests/test43.bas @@ -0,0 +1,16 @@ +DIM a(3,3),b(3,1),c(3,3) +MAT READ a +MAT READ b +MAT c=a*b +MAT PRINT c +DATA 1,2,3,4,5,6,7,8,9 +DATA 5,3,2 + +erase b +DIM b(3) +RESTORE +MAT READ a +MAT READ b +MAT c=a*b +MAT PRINT c + diff --git a/apps/examples/bastest/tests/test44.bas b/apps/examples/bastest/tests/test44.bas new file mode 100644 index 000000000..72cb37ccf --- /dev/null +++ b/apps/examples/bastest/tests/test44.bas @@ -0,0 +1,8 @@ +10 print 10 +20 print 20 +30 print 30 +40 print 40 +50 print 50 +60 print 60 +70 print 70 + diff --git a/apps/examples/bastest/tests/test45.bas b/apps/examples/bastest/tests/test45.bas new file mode 100644 index 000000000..cea534dda --- /dev/null +++ b/apps/examples/bastest/tests/test45.bas @@ -0,0 +1,9 @@ +10 mid$(a$,6,4) = "ABCD" +20 print a$ +30 a$="0123456789" +40 mid$(a$,6,4) = "ABCD" +50 print a$ +60 a$="0123456789" +70 let mid$(a$,6,4) = "ABCD" +80 print a$ + diff --git a/apps/examples/bastest/tests/test46.bas b/apps/examples/bastest/tests/test46.bas new file mode 100644 index 000000000..f7a08468d --- /dev/null +++ b/apps/examples/bastest/tests/test46.bas @@ -0,0 +1,2 @@ +for i=1 to 10:print i;:next i:end + diff --git a/apps/examples/bastest/tests/test47.bas b/apps/examples/bastest/tests/test47.bas new file mode 100644 index 000000000..960ac46c5 --- /dev/null +++ b/apps/examples/bastest/tests/test47.bas @@ -0,0 +1,10 @@ +dim a(3,4) +for i=0 to 3 + for j=0 to 4 + a(i,j)=i*10+j + print a(i,j); + next + print +next +mat write a + diff --git a/apps/examples/bastest/tests/test48.bas b/apps/examples/bastest/tests/test48.bas new file mode 100644 index 000000000..223bc1c3e --- /dev/null +++ b/apps/examples/bastest/tests/test48.bas @@ -0,0 +1,8 @@ +a,b = 10 +print a,b +dim c(10) +a,c(a) = 2 +print a,c(2),c(10) +a$,b$="test" +print a$,b$ + diff --git a/apps/examples/bastest/tests/test49.bas b/apps/examples/bastest/tests/test49.bas new file mode 100644 index 000000000..d9b167af0 --- /dev/null +++ b/apps/examples/bastest/tests/test49.bas @@ -0,0 +1,16 @@ +width 120 +dim a(7,7),b(7,7) +mat read a +mat print a; +print +data 58,71,67,36,35,19,60 +data 50,71,71,56,45,20,52 +data 64,40,84,50,51,43,69 +data 31,28,41,54,31,18,33 +data 45,23,46,38,50,43,50 +data 41,10,28,17,33,41,46 +data 66,72,71,38,40,27,69 +mat b=inv(a) +mat print b +print det + diff --git a/apps/examples/bastest/tests/test50.bas b/apps/examples/bastest/tests/test50.bas new file mode 100644 index 000000000..de12fbe87 --- /dev/null +++ b/apps/examples/bastest/tests/test50.bas @@ -0,0 +1,9 @@ +print min(1,2) +print min(2,1) +print min(-0.3,0.3) +print min(-0.3,4) +print max(1,2) +print max(2,1) +print max(-0.3,0.3) +print max(-0.3,4) + diff --git a/apps/examples/bastest/tests/test51.bas b/apps/examples/bastest/tests/test51.bas new file mode 100644 index 000000000..503cb2693 --- /dev/null +++ b/apps/examples/bastest/tests/test51.bas @@ -0,0 +1,2 @@ +PRINT "Line 1";TAB(78);1.23456789 + diff --git a/apps/examples/bastest/tests/test52.bas b/apps/examples/bastest/tests/test52.bas new file mode 100644 index 000000000..4470bb5b2 --- /dev/null +++ b/apps/examples/bastest/tests/test52.bas @@ -0,0 +1,6 @@ +dim a(2,2) +mat input a +mat print a +mat input a +mat print a + diff --git a/apps/interpreters/bas/README.txt b/apps/interpreters/bas/README.txt index d9d9425f9..d8435930e 100644 --- a/apps/interpreters/bas/README.txt +++ b/apps/interpreters/bas/README.txt @@ -1,8 +1,8 @@ README ====== -Introductions -============= +Introduction +============ Bas is an interpreter for the classic dialect of the programming language BASIC. It is pretty compatible to typical BASIC interpreters of the 1980s, unlike some other UNIX BASIC interpreters, that implement a different @@ -18,9 +18,6 @@ Introductions to variables that are never initialised. Bas is written in ANSI C for UNIX systems. - Please do "make check" after compiling bas to run a couple regression - tests. - License ======= BAS 2.4 is released as part of NuttX under the standard 3-clause BSD license diff --git a/nuttx/Documentation/README.html b/nuttx/Documentation/README.html index 3a8ab4be7..a15681e95 100644 --- a/nuttx/Documentation/README.html +++ b/nuttx/Documentation/README.html @@ -8,7 +8,7 @@

NuttX README Files

-

Last Updated: October 27, 2014

+

Last Updated: November 7, 2014

@@ -303,6 +303,7 @@ |- apps/ | |- README.txt | |- examples/ + | | |- bastest/README.txt | | |- json/README.txt | | |- pashello/README.txt | | `- README.txt diff --git a/nuttx/README.txt b/nuttx/README.txt index 0c5641527..e1b9f943e 100644 --- a/nuttx/README.txt +++ b/nuttx/README.txt @@ -1259,6 +1259,7 @@ nuttx apps |- examples/ + | |- bastest/README.txt | |- json/README.txt | |- pashello/README.txt | `- README.txt -- cgit v1.2.3