;; nyacc/lang/c99/c99-03.test		-*- scheme -*-
;;
;; Copyright (C) 2016-2017 Matthew R. Wette
;; 
;; Copying and distribution of this file, with or without modification,
;; are permitted in any medium without royalty provided the copyright
;; notice and this notice are preserved.  This file is offered as-is,
;; without any warranty.

;; test C99 parser in file mode

(define-module (c99-03)
  #:use-module (nyacc lang c99 parser)
  #:use-module (nyacc lang c99 util1)
  #:use-module (test-suite lib))

(define incs '("exam.d"))

(define (parse-string str)
  (with-input-from-string str
    (lambda ()
      (parse-c99 #:inc-dirs incs #:mode 'file #:inc-help c99-std-help))))

(define (parse-file file)
  (with-input-from-file file
    (lambda ()
      (parse-c99 #:inc-dirs incs #:mode 'file))))

;; parser test
(with-test-prefix "nyacc/c99-03, file mode"

  ;; parse with include file
  (pass-if "included files"
    (let* ((sx (with-input-from-file "exam.d/ex01.c"
		 (lambda () (parse-c99 #:inc-dirs incs #:mode 'file)))))
      (pair? sx)))

  ;; parse massive comments file
  (pass-if "comments, wanted and unwanted"
    (let* ((sx (with-input-from-file "exam.d/ex02.c"
		 (lambda () (parse-c99 #:inc-dirs incs #:mode 'file)))))
      (pair? sx)))

  )

;; --- last line ---
