>From 134f800b57b51c3d02c22de5517fcd398747fe1e Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Wed, 2 Feb 2011 12:53:37 +0100 Subject: [PATCH 2/3] stinst: Start a autotest test for the STInST parser and compiler This also shows a regression in the STInST parser due the addition of the return statement. 2011-02-02 Holger Hans Peter Freyther * tests/stcompiler.ok: New. * tests/stcompiler.st: New. * tests/testsuite.at: Add STInST compiler tests. * tests/Makefile.am: Add STInST compiler tests. --- ChangeLog | 7 ++++ tests/Makefile.am | 3 +- tests/stcompiler.ok | 46 +++++++++++++++++++++++++ tests/stcompiler.st | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/testsuite.at | 1 + 5 files changed, 148 insertions(+), 1 deletions(-) create mode 100644 tests/stcompiler.ok create mode 100644 tests/stcompiler.st diff --git a/ChangeLog b/ChangeLog index 98cc17e..4cb6029 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-02-02 Holger Hans Peter Freyther + + * tests/stcompiler.ok: New. + * tests/stcompiler.st: New. + * tests/testsuite.at: Add STInST compiler tests. + * tests/Makefile.am: Add STInST compiler tests. + 2011-01-25 Paolo Bonzini * scripts/Package.st: Fix String<->File confusion with --prepare. diff --git a/tests/Makefile.am b/tests/Makefile.am index 5cb5d66..260e6de 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -17,7 +17,8 @@ nestedloop.st objdump.ok objdump.st objects.ok objects.st objinst.ok \ objinst.st processes.ok processes.st prodcons.ok prodcons.st quit.ok \ quit.st random-bench.ok random-bench.st untrusted.ok untrusted.st sets.ok \ sets.st sieve.ok sieve.st strcat.ok strcat.st strings.ok strings.st \ -pools.ok pools.st Ansi.st AnsiDB.st AnsiInit.st AnsiLoad.st AnsiRun.st +pools.ok pools.st Ansi.st AnsiDB.st AnsiInit.st AnsiLoad.st AnsiRun.st \ +stcompiler.st stcompiler.ok CLEANFILES = gst.im DISTCLEANFILES = atconfig diff --git a/tests/stcompiler.ok b/tests/stcompiler.ok new file mode 100644 index 0000000..a07cebc --- /dev/null +++ b/tests/stcompiler.ok @@ -0,0 +1,46 @@ + +Execution begins... +Loading package Parser + +Execution begins... +returned value is RBScanner + +Execution begins... +returned value is IdentityDictionary new: 128 "<0>" + +Execution begins... +returned value is DefaultPoolResolution + +Execution begins... +returned value is STCompiler +Loading package Compiler +returned value is 3 + +Execution begins... +'before everything' +-2 +-1 +0 +1 +2 +3 +4 +5 +6 +7 +8 +'okay' +'okay' +now I'm testing 'Cascading' +(true false nil 53 $a ByteArray (1 2 3 ) (1 2 3 ) {Smalltalk.Association} #perform: #perform:with: ' +Arrays... and multi-line strings' ) +and now blocks with parameters... +'okay' +[] in UndefinedObject>>executeStatements (a String:1) +finally, many parameters, +cascading +and block temporaries too! +returned value is TextCollector new "<0>" + +Execution begins... +returned value is OrderedSet new: 32 "<0>" diff --git a/tests/stcompiler.st b/tests/stcompiler.st new file mode 100644 index 0000000..cf5e51c --- /dev/null +++ b/tests/stcompiler.st @@ -0,0 +1,92 @@ +"====================================================================== +| +| Regression tests for the STInST compiler +| +| + ======================================================================" + + +"====================================================================== +| +| Copyright (C) 1999, 200, 2001, 2002, 2011 Free Software Foundation. +| Written by Paolo Bonzini and Holger Hans Peter Freyther. +| +| This file is part of GNU Smalltalk. +| +| GNU Smalltalk is free software; you can redistribute it and/or modify it +| under the terms of the GNU General Public License as published by the Free +| Software Foundation; either version 2, or (at your option) any later version. +| +| GNU Smalltalk is distributed in the hope that it will be useful, but WITHOUT +| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +| FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +| details. +| +| You should have received a copy of the GNU General Public License along with +| GNU Smalltalk; see the file COPYING. If not, write to the Free Software +| Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +| + ======================================================================" + + +Eval [ + "This is testing bug: http://smalltalk.gnu.org/project/issue/527" + PackageLoader fileInPackage: 'Compiler'. + Behavior evaluate: '3'. +] + +Eval [ + "Random code to test features of the parser" + PackageLoader fileInPackage: #Compiler. + + STInST.STEvaluationDriver new parseSmalltalk: ' + | i | + i := ##(| a | a := -2. ''before everything'' printNl. a). + [ i < 5 ] whileTrue: [ i printNl. i := i + 1 ]. + [ i = (900 // 100) ] whileFalse: [ i printNl. i := i + 1 ]. + i even ifTrue: [ i printNl ]. + i odd ifFalse: [ i printNl ]. + (i even or: [i odd]) ifTrue: [ ''okay'' printNl] ifFalse: [ ''huh?!?'' printNl ]. + (i even and: [i odd]) ifFalse: [ ''okay'' printNl] ifTrue: [ ''huh?!?'' printNl ]. + Transcript + nextPutAll: ''now I''''m testing ''; + print: ''Cascading''; + nl. + + #(true false nil 53 $a [1 2 3] (1 2 3) + #{Smalltalk.Association} #perform: #''perform:with:'' '' +Arrays... and multi-line strings'') printNl. + + #(''and now'' '' blocks with parameters...'') do: [ :each | + Transcript nextPutAll: each ]. + + [ :a :b :c | | temp | + temp := Smalltalk::Transcript. + temp + nl; + print: (i = 9 ifTrue: [ ''okay'' ] ifFalse: [ ''huh?!?'' ]); + nl; + print: thisContext; + nl; nextPutAll: a; + nl; nextPutAll: b; + nl; nextPutAll: c; + nl + ] + value: ''finally, many parameters, '' + value: ''cascading '' + value: ''and block temporaries too! ''. +!' with: STInST.STFileInParser. +] + +Eval [ + | squeak | + "Test the import of squeak code" + + squeak := '!String methodsFor: ''*petitparser-core-converting'' stamp: ''lr 11/7/2009 13:32''! +asParser + ^ PPLiteralSequenceParser on: self! !'. + + STInST.STClassLoader new parseSmalltalkStream: squeak readStream + with: STInST.SqueakFileInParser. +] + diff --git a/tests/testsuite.at b/tests/testsuite.at index e84d4ab..ac21ad1 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -72,6 +72,7 @@ AT_DIFF_TEST([prodcons.st]) AT_DIFF_TEST([random-bench.st]) AT_DIFF_TEST([sieve.st]) AT_DIFF_TEST([strcat.st]) +AT_DIFF_TEST([stcompiler.st]) AT_BANNER([Basic packages.]) AT_PACKAGE_TEST([SUnit]) -- 1.7.3.5