--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/compiler/tests/extras/PPCResources.st Sun May 10 06:28:36 2015 +0100
@@ -0,0 +1,94 @@
+"{ Package: 'stx:goodies/petitparser/compiler/tests/extras' }"
+
+"{ NameSpace: Smalltalk }"
+
+TestResource subclass:#PPCResources
+ instanceVariableNames:''
+ classVariableNames:'javaCache'
+ poolDictionaries:''
+ category:'PetitCompiler-Extras-Tests-Support'
+!
+
+PPCResources comment:''
+!
+
+!PPCResources methodsFor:'java'!
+
+javaInDirectory: directory
+ | files |
+ files := self readDirectory: directory.
+ files := self files: files withExtension: 'java'.
+
+ ^ files collect: [ :f | (FileStream fileNamed: f) contents ]
+!
+
+javaLangMath
+ ^ (FileStream fileNamed: '../java-src/java/lang/Math.java') contents
+!
+
+javaSourcesBig
+ ^ self javaInDirectory: '../java-src/java/util'.
+ "^ self workingJavaInDirectory: '../java-src/java/util'"
+!
+
+javaUtilTimer
+ ^ (FileStream fileNamed: '../java-src/java/util/Timer.java') contents
+!
+
+workingJavaInDirectory: directory
+ | sources parser |
+ "return only such a files, that can be parsed by PPJavaSyntax"
+
+ javaCache ifNil: [ javaCache := Dictionary new ].
+
+ ^ javaCache at: directory ifAbsentPut: [
+ sources := self javaInDirectory: directory.
+ parser := PPJavaSyntax new.
+
+ sources select: [ :source | ([parser parse: source ] on: Error do: [ PPFailure new ]) isPetitFailure not ]
+ ]
+! !
+
+!PPCResources methodsFor:'private utilities'!
+
+files: files withExtension: extension
+ ^ files select: [ :f | f extension = extension ]
+!
+
+readDirectory: directory
+ | file |
+ file := directory asFileReference.
+ file exists ifTrue: [
+ ^ file allFiles
+ ].
+ ^ #()
+! !
+
+!PPCResources methodsFor:'smalltalk'!
+
+smalltalkClassMethods
+ ^ self smalltalkInDirectory: '../smalltalk-src/Class/'
+
+!
+
+smalltalkInDirectory: directory
+ | files |
+ files := self readDirectory: directory.
+ files := self files: files withExtension: 'st'.
+
+ ^ files collect: [ :f | (FileStream fileNamed: f) contents ]
+!
+
+smalltalkObjectMethods
+ ^ self smalltalkInDirectory: '../smalltalk-src/Object/'
+
+!
+
+smalltalkSourcesBig
+ ^ self smalltalkInDirectory: '../smalltalk-src/'
+!
+
+smalltalkSourcesSmall
+ ^ (self smalltalkInDirectory: '../smalltalk-src/') copyFrom: 1 to: 5000.
+! !
+