REBOL [
  Title:   "Make Red & Rebol lexer tests"
	Author:  "Peter W A Wood"
	File: 	 %make-lexer-auto-tests.r
	Version: 0.1.0
	Tabs:	 4
	Rights:  "Copyright (C) 2016 Peter W A Wood. All rights reserved."
	License: "BSD-3 - https://github.com/red/red/blob/origin/BSD-3-License.txt"
]

;; initialisations 
red-tests: copy ""                          ;; string to hold tests
rebol-tests: copy ""
make-dir %auto-tests/
red-file-out: %auto-tests/lexer-auto-test.red
rebol-file-out: %auto-tests/lexer-auto-test.r

;; create Red test file with header
append red-tests "Red [^(0A)"
append red-tests {  Title:   "Red auto-generated lexer red-tests"^(0A)}
append red-tests {	Author:  "Peter W A Wood"^(0A)}
append red-tests {  File: 	 %lexer-auto-test.red^(0A)}
append red-tests {  License: "BSD-3 - https://github.com/dockimbel/Red/blob/origin/BSD-3-License.txt"^(0A)}
append red-tests "]^(0A)^(0A)"
append red-tests "^(0A)^(0A)comment {"
append red-tests "  This file is generated by make-lexer-auto-red-tests.r^(0A)"
append red-tests "  Do not edit this file directly.^(0A)"
append red-tests "}^(0A)^(0A)"
append red-tests join ";make-length:" 
                  [length? read %make-lexer-auto-tests.r "^(0A)^(0A)"]
append red-tests {#include  %../../../../quick-test/quick-test.red^(0A)^(0A)}

;; create Red test file with header
append rebol-tests "Rebol [^(0A)"
append rebol-tests {  Title:   "Red auto-generated lexer rebol-tests"^(0A)}
append rebol-tests {	Author:  "Peter W A Wood"^(0A)}
append rebol-tests {  File: 	 %lexer-auto-test.r^(0A)}
append rebol-tests {  License: "BSD-3 - https://github.com/dockimbel/Red/blob/origin/BSD-3-License.txt"^(0A)}
append rebol-tests "]^(0A)^(0A)"
append rebol-tests "^(0A)^(0A)comment {"
append rebol-tests "  This file is generated by make-lexer-auto-rebol-tests.r^(0A)"
append rebol-tests "  Do not edit this file directly.^(0A)"
append rebol-tests "}^(0A)^(0A)"
append rebol-tests {do %../../../../lexer.r^(0A)}
append rebol-tests {do %../../../../quick-test/quick-unit-test.r^(0A)^(0A)}

;; add the actual tests and write out the files
the-tests: read %lexer.tests
append red-tests the-tests
replace/all the-tests "load/all" "lexer/process"
replace/all the-tests "--assert [" "--assert [[] "
replace/all the-tests {lexer/process "} {lexer/process "Red []}
replace/all the-tests "lexer/process {" "lexer/process {Red []"
append rebol-tests the-tests
write red-file-out red-tests
write rebol-file-out rebol-tests
print what-dir

print "lexer auto-test files generated"