Skip to content

Commit

Permalink
Dead code removal and naming clarification
Browse files Browse the repository at this point in the history
The names `parser-tests` and `parser-test-files` are slightly
misleading: tests are exercising type checking too: rename to
`coalton-tests` and `test-files`.

Drop one orphan source-error helper that was obsoleted by the
introduction of the source:location generic function.

Minor spelling fixes.
  • Loading branch information
jbouwman committed Oct 3, 2024
1 parent d7a214c commit e80aef6
Show file tree
Hide file tree
Showing 49 changed files with 13 additions and 26 deletions.
2 changes: 1 addition & 1 deletion coalton.asd
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@
(:module "parser"
:serial t
:components ((:file "cursor-tests")))
(:file "parser-tests")
(:file "entry-tests")
(:file "toplevel-tests")
(:file "type-inference-tests")
Expand All @@ -243,6 +242,7 @@
:components ((:file "map-tests")
(:file "lisp-type-tests")))
(:file "environment-persist-tests")
(:file "coalton-tests")
(:file "slice-tests")
(:file "float-tests")
(:file "dual-tests")
Expand Down
13 changes: 0 additions & 13 deletions src/source.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -316,19 +316,6 @@ REPLACE is a 1-argument function that accepts and returns a string to suggest an
:replacement (replace-function note)
:message (message note)))

(defun source-error (&key (type :error) location (highlight :all)
message primary-note notes help-notes)
"Convenience function to unpack a LOCATION into source and span and create a source-error structure."
(declare (type location location))
(source-error:source-error :type type
:span (location-span location)
:source (location-source location)
:highlight highlight
:message message
:primary-note primary-note
:notes notes
:help-notes help-notes))

(defun make-source-error (type message notes)
"Build a SOURCE-ERROR:SOURCE-ERROR structure by destructuring the first note in NOTES, and translating remaining notes to SOURCE-ERROR versions."
(destructuring-bind (primary &rest secondary) notes
Expand Down
4 changes: 2 additions & 2 deletions tests/parser-tests.lisp → tests/coalton-tests.lisp
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
;;;; Run test suites that parse and compile programs to exercise
;;;; specific areas of functionality.
;;;;
;;;; See tests/parser-test-files/README.md for input format and options.
;;;; See tests/test-files/README.md for input format and options.
;;;; See tests/loader.lisp and tests/utilities.lisp for load and
;;;; execution functions.

(in-package #:coalton-tests)

(defun %run-tests (name)
(run-test-file (format nil "tests/parser-test-files/~a" name)))
(run-test-file (format nil "tests/test-files/~a" name)))

(deftest test-coalton-lang ()
(%run-tests "define-class.txt")
Expand Down
6 changes: 3 additions & 3 deletions tests/loader.lisp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
;;;; This package contains the function LOAD-TEST-FILE for loading
;;;; parser tests from specially formatted files.
;;;;
;;;; - The format is documented in tests/parser-test-files/README.md
;;;; - Tests are defined in tests/parser-test-files/*.txt
;;;; - These tests are loaded and run by tests/parser-tests.lisp
;;;; - The format is documented in tests/test-files/README.md
;;;; - Tests are defined in tests/test-files/*.txt
;;;; - These tests are loaded and run by tests/coalton-tests.lisp
;;;; - COALTON-TESTS:RUN-TEST-FILE and COALTON-TESTS:RUN-TEST are
;;;; defined in tests/utilities.lisp
;;;;
Expand Down
14 changes: 7 additions & 7 deletions tests/source-tests.lisp
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
(in-package #:coalton-tests)

;; Check that wrapping a character input stream with
;; char-position-stream class allows callers to collect character
;; offset using 'file-position'. This is for gathering source offsets
;; that remain copmpatible with the offsets reported for source parsed
;; from internal strings.
;;; Check that wrapping a character input stream with
;;; char-position-stream class allows callers to collect character
;;; offset using 'file-position'. This is for gathering source offsets
;;; that remain compatible with the offsets reported for source parsed
;;; from internal strings.

(deftest test-char-position-stream ()
(flet ((stream-contents (stream)
(loop :for char
:= (read-char stream nil nil)
:while char
:collect (cons char (file-position stream)))))
(with-open-file (stream (test-file "tests/parser-test-files/unicode.coal")
(with-open-file (stream (test-file "tests/test-files/unicode.coal")
:direction ':input
:element-type 'character
:external-format :utf-8)
Expand All @@ -22,7 +22,7 @@
(format nil "File expected length 86 != ~A" (length chars)))
(is (equal 72 ; byte offset would have been 76
(cdr (nth 71 chars)))
"Scond kanji is at char offset, not byte offset")))))
"Second kanji is at char offset, not byte offset")))))

(deftest test-location ()
(let* ((source (source:make-source-string "1234567890"))
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit e80aef6

Please sign in to comment.