From e80aef6ebcc4c17699b9c14cafaaf6a1d217a74c Mon Sep 17 00:00:00 2001 From: Jesse Bouwman Date: Thu, 3 Oct 2024 10:35:25 -0700 Subject: [PATCH] Dead code removal and naming clarification 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. --- coalton.asd | 2 +- src/source.lisp | 13 ------------- tests/{parser-tests.lisp => coalton-tests.lisp} | 4 ++-- tests/loader.lisp | 6 +++--- tests/source-tests.lisp | 14 +++++++------- tests/{parser-test-files => test-files}/README.md | 0 .../define-class.txt | 0 .../define-instance.txt | 0 .../define-type.txt | 0 tests/{parser-test-files => test-files}/define.txt | 0 .../{parser-test-files => test-files}/fundeps.txt | 0 .../hashtable.txt | 0 .../lisp-toplevel-forbid.txt | 0 .../lisp-toplevel.txt | 0 .../{parser-test-files => test-files}/package.txt | 0 .../parse-and.txt | 0 .../parse-attribute.txt | 0 .../parse-body.txt | 0 .../parse-break.txt | 0 .../parse-cond.txt | 0 .../parse-continue.txt | 0 .../parse-declare.txt | 0 .../{parser-test-files => test-files}/parse-do.txt | 0 .../parse-expression.txt | 0 .../{parser-test-files => test-files}/parse-fn.txt | 0 .../parse-for.txt | 0 .../{parser-test-files => test-files}/parse-if.txt | 0 .../parse-let.txt | 0 .../parse-lisp.txt | 0 .../parse-loop.txt | 0 .../parse-match.txt | 0 .../parse-method.txt | 0 .../{parser-test-files => test-files}/parse-or.txt | 0 .../parse-pattern.txt | 0 .../parse-return.txt | 0 .../parse-the.txt | 0 .../parse-toplevel.txt | 0 .../parse-type.txt | 0 .../parse-unless.txt | 0 .../parse-when.txt | 0 .../parse-while-let.txt | 0 .../parse-while.txt | 0 .../recursive-let.txt | 0 tests/{parser-test-files => test-files}/struct.txt | 0 .../toplevel-progn.txt | 0 .../type-inference.txt | 0 .../{parser-test-files => test-files}/unicode.coal | 0 .../{parser-test-files => test-files}/unicode.txt | 0 .../unused-variables.txt | 0 49 files changed, 13 insertions(+), 26 deletions(-) rename tests/{parser-tests.lisp => coalton-tests.lisp} (92%) rename tests/{parser-test-files => test-files}/README.md (100%) rename tests/{parser-test-files => test-files}/define-class.txt (100%) rename tests/{parser-test-files => test-files}/define-instance.txt (100%) rename tests/{parser-test-files => test-files}/define-type.txt (100%) rename tests/{parser-test-files => test-files}/define.txt (100%) rename tests/{parser-test-files => test-files}/fundeps.txt (100%) rename tests/{parser-test-files => test-files}/hashtable.txt (100%) rename tests/{parser-test-files => test-files}/lisp-toplevel-forbid.txt (100%) rename tests/{parser-test-files => test-files}/lisp-toplevel.txt (100%) rename tests/{parser-test-files => test-files}/package.txt (100%) rename tests/{parser-test-files => test-files}/parse-and.txt (100%) rename tests/{parser-test-files => test-files}/parse-attribute.txt (100%) rename tests/{parser-test-files => test-files}/parse-body.txt (100%) rename tests/{parser-test-files => test-files}/parse-break.txt (100%) rename tests/{parser-test-files => test-files}/parse-cond.txt (100%) rename tests/{parser-test-files => test-files}/parse-continue.txt (100%) rename tests/{parser-test-files => test-files}/parse-declare.txt (100%) rename tests/{parser-test-files => test-files}/parse-do.txt (100%) rename tests/{parser-test-files => test-files}/parse-expression.txt (100%) rename tests/{parser-test-files => test-files}/parse-fn.txt (100%) rename tests/{parser-test-files => test-files}/parse-for.txt (100%) rename tests/{parser-test-files => test-files}/parse-if.txt (100%) rename tests/{parser-test-files => test-files}/parse-let.txt (100%) rename tests/{parser-test-files => test-files}/parse-lisp.txt (100%) rename tests/{parser-test-files => test-files}/parse-loop.txt (100%) rename tests/{parser-test-files => test-files}/parse-match.txt (100%) rename tests/{parser-test-files => test-files}/parse-method.txt (100%) rename tests/{parser-test-files => test-files}/parse-or.txt (100%) rename tests/{parser-test-files => test-files}/parse-pattern.txt (100%) rename tests/{parser-test-files => test-files}/parse-return.txt (100%) rename tests/{parser-test-files => test-files}/parse-the.txt (100%) rename tests/{parser-test-files => test-files}/parse-toplevel.txt (100%) rename tests/{parser-test-files => test-files}/parse-type.txt (100%) rename tests/{parser-test-files => test-files}/parse-unless.txt (100%) rename tests/{parser-test-files => test-files}/parse-when.txt (100%) rename tests/{parser-test-files => test-files}/parse-while-let.txt (100%) rename tests/{parser-test-files => test-files}/parse-while.txt (100%) rename tests/{parser-test-files => test-files}/recursive-let.txt (100%) rename tests/{parser-test-files => test-files}/struct.txt (100%) rename tests/{parser-test-files => test-files}/toplevel-progn.txt (100%) rename tests/{parser-test-files => test-files}/type-inference.txt (100%) rename tests/{parser-test-files => test-files}/unicode.coal (100%) rename tests/{parser-test-files => test-files}/unicode.txt (100%) rename tests/{parser-test-files => test-files}/unused-variables.txt (100%) diff --git a/coalton.asd b/coalton.asd index 7bee66b37..625e80bdb 100644 --- a/coalton.asd +++ b/coalton.asd @@ -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") @@ -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") diff --git a/src/source.lisp b/src/source.lisp index 1b7481d42..80ae0e846 100644 --- a/src/source.lisp +++ b/src/source.lisp @@ -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 diff --git a/tests/parser-tests.lisp b/tests/coalton-tests.lisp similarity index 92% rename from tests/parser-tests.lisp rename to tests/coalton-tests.lisp index ffd572f5d..eb6bb3f8a 100644 --- a/tests/parser-tests.lisp +++ b/tests/coalton-tests.lisp @@ -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") diff --git a/tests/loader.lisp b/tests/loader.lisp index 106ee299d..09f82084d 100644 --- a/tests/loader.lisp +++ b/tests/loader.lisp @@ -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 ;;;; diff --git a/tests/source-tests.lisp b/tests/source-tests.lisp index 02451a85f..ed869aadd 100644 --- a/tests/source-tests.lisp +++ b/tests/source-tests.lisp @@ -1,10 +1,10 @@ (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) @@ -12,7 +12,7 @@ := (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) @@ -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")) diff --git a/tests/parser-test-files/README.md b/tests/test-files/README.md similarity index 100% rename from tests/parser-test-files/README.md rename to tests/test-files/README.md diff --git a/tests/parser-test-files/define-class.txt b/tests/test-files/define-class.txt similarity index 100% rename from tests/parser-test-files/define-class.txt rename to tests/test-files/define-class.txt diff --git a/tests/parser-test-files/define-instance.txt b/tests/test-files/define-instance.txt similarity index 100% rename from tests/parser-test-files/define-instance.txt rename to tests/test-files/define-instance.txt diff --git a/tests/parser-test-files/define-type.txt b/tests/test-files/define-type.txt similarity index 100% rename from tests/parser-test-files/define-type.txt rename to tests/test-files/define-type.txt diff --git a/tests/parser-test-files/define.txt b/tests/test-files/define.txt similarity index 100% rename from tests/parser-test-files/define.txt rename to tests/test-files/define.txt diff --git a/tests/parser-test-files/fundeps.txt b/tests/test-files/fundeps.txt similarity index 100% rename from tests/parser-test-files/fundeps.txt rename to tests/test-files/fundeps.txt diff --git a/tests/parser-test-files/hashtable.txt b/tests/test-files/hashtable.txt similarity index 100% rename from tests/parser-test-files/hashtable.txt rename to tests/test-files/hashtable.txt diff --git a/tests/parser-test-files/lisp-toplevel-forbid.txt b/tests/test-files/lisp-toplevel-forbid.txt similarity index 100% rename from tests/parser-test-files/lisp-toplevel-forbid.txt rename to tests/test-files/lisp-toplevel-forbid.txt diff --git a/tests/parser-test-files/lisp-toplevel.txt b/tests/test-files/lisp-toplevel.txt similarity index 100% rename from tests/parser-test-files/lisp-toplevel.txt rename to tests/test-files/lisp-toplevel.txt diff --git a/tests/parser-test-files/package.txt b/tests/test-files/package.txt similarity index 100% rename from tests/parser-test-files/package.txt rename to tests/test-files/package.txt diff --git a/tests/parser-test-files/parse-and.txt b/tests/test-files/parse-and.txt similarity index 100% rename from tests/parser-test-files/parse-and.txt rename to tests/test-files/parse-and.txt diff --git a/tests/parser-test-files/parse-attribute.txt b/tests/test-files/parse-attribute.txt similarity index 100% rename from tests/parser-test-files/parse-attribute.txt rename to tests/test-files/parse-attribute.txt diff --git a/tests/parser-test-files/parse-body.txt b/tests/test-files/parse-body.txt similarity index 100% rename from tests/parser-test-files/parse-body.txt rename to tests/test-files/parse-body.txt diff --git a/tests/parser-test-files/parse-break.txt b/tests/test-files/parse-break.txt similarity index 100% rename from tests/parser-test-files/parse-break.txt rename to tests/test-files/parse-break.txt diff --git a/tests/parser-test-files/parse-cond.txt b/tests/test-files/parse-cond.txt similarity index 100% rename from tests/parser-test-files/parse-cond.txt rename to tests/test-files/parse-cond.txt diff --git a/tests/parser-test-files/parse-continue.txt b/tests/test-files/parse-continue.txt similarity index 100% rename from tests/parser-test-files/parse-continue.txt rename to tests/test-files/parse-continue.txt diff --git a/tests/parser-test-files/parse-declare.txt b/tests/test-files/parse-declare.txt similarity index 100% rename from tests/parser-test-files/parse-declare.txt rename to tests/test-files/parse-declare.txt diff --git a/tests/parser-test-files/parse-do.txt b/tests/test-files/parse-do.txt similarity index 100% rename from tests/parser-test-files/parse-do.txt rename to tests/test-files/parse-do.txt diff --git a/tests/parser-test-files/parse-expression.txt b/tests/test-files/parse-expression.txt similarity index 100% rename from tests/parser-test-files/parse-expression.txt rename to tests/test-files/parse-expression.txt diff --git a/tests/parser-test-files/parse-fn.txt b/tests/test-files/parse-fn.txt similarity index 100% rename from tests/parser-test-files/parse-fn.txt rename to tests/test-files/parse-fn.txt diff --git a/tests/parser-test-files/parse-for.txt b/tests/test-files/parse-for.txt similarity index 100% rename from tests/parser-test-files/parse-for.txt rename to tests/test-files/parse-for.txt diff --git a/tests/parser-test-files/parse-if.txt b/tests/test-files/parse-if.txt similarity index 100% rename from tests/parser-test-files/parse-if.txt rename to tests/test-files/parse-if.txt diff --git a/tests/parser-test-files/parse-let.txt b/tests/test-files/parse-let.txt similarity index 100% rename from tests/parser-test-files/parse-let.txt rename to tests/test-files/parse-let.txt diff --git a/tests/parser-test-files/parse-lisp.txt b/tests/test-files/parse-lisp.txt similarity index 100% rename from tests/parser-test-files/parse-lisp.txt rename to tests/test-files/parse-lisp.txt diff --git a/tests/parser-test-files/parse-loop.txt b/tests/test-files/parse-loop.txt similarity index 100% rename from tests/parser-test-files/parse-loop.txt rename to tests/test-files/parse-loop.txt diff --git a/tests/parser-test-files/parse-match.txt b/tests/test-files/parse-match.txt similarity index 100% rename from tests/parser-test-files/parse-match.txt rename to tests/test-files/parse-match.txt diff --git a/tests/parser-test-files/parse-method.txt b/tests/test-files/parse-method.txt similarity index 100% rename from tests/parser-test-files/parse-method.txt rename to tests/test-files/parse-method.txt diff --git a/tests/parser-test-files/parse-or.txt b/tests/test-files/parse-or.txt similarity index 100% rename from tests/parser-test-files/parse-or.txt rename to tests/test-files/parse-or.txt diff --git a/tests/parser-test-files/parse-pattern.txt b/tests/test-files/parse-pattern.txt similarity index 100% rename from tests/parser-test-files/parse-pattern.txt rename to tests/test-files/parse-pattern.txt diff --git a/tests/parser-test-files/parse-return.txt b/tests/test-files/parse-return.txt similarity index 100% rename from tests/parser-test-files/parse-return.txt rename to tests/test-files/parse-return.txt diff --git a/tests/parser-test-files/parse-the.txt b/tests/test-files/parse-the.txt similarity index 100% rename from tests/parser-test-files/parse-the.txt rename to tests/test-files/parse-the.txt diff --git a/tests/parser-test-files/parse-toplevel.txt b/tests/test-files/parse-toplevel.txt similarity index 100% rename from tests/parser-test-files/parse-toplevel.txt rename to tests/test-files/parse-toplevel.txt diff --git a/tests/parser-test-files/parse-type.txt b/tests/test-files/parse-type.txt similarity index 100% rename from tests/parser-test-files/parse-type.txt rename to tests/test-files/parse-type.txt diff --git a/tests/parser-test-files/parse-unless.txt b/tests/test-files/parse-unless.txt similarity index 100% rename from tests/parser-test-files/parse-unless.txt rename to tests/test-files/parse-unless.txt diff --git a/tests/parser-test-files/parse-when.txt b/tests/test-files/parse-when.txt similarity index 100% rename from tests/parser-test-files/parse-when.txt rename to tests/test-files/parse-when.txt diff --git a/tests/parser-test-files/parse-while-let.txt b/tests/test-files/parse-while-let.txt similarity index 100% rename from tests/parser-test-files/parse-while-let.txt rename to tests/test-files/parse-while-let.txt diff --git a/tests/parser-test-files/parse-while.txt b/tests/test-files/parse-while.txt similarity index 100% rename from tests/parser-test-files/parse-while.txt rename to tests/test-files/parse-while.txt diff --git a/tests/parser-test-files/recursive-let.txt b/tests/test-files/recursive-let.txt similarity index 100% rename from tests/parser-test-files/recursive-let.txt rename to tests/test-files/recursive-let.txt diff --git a/tests/parser-test-files/struct.txt b/tests/test-files/struct.txt similarity index 100% rename from tests/parser-test-files/struct.txt rename to tests/test-files/struct.txt diff --git a/tests/parser-test-files/toplevel-progn.txt b/tests/test-files/toplevel-progn.txt similarity index 100% rename from tests/parser-test-files/toplevel-progn.txt rename to tests/test-files/toplevel-progn.txt diff --git a/tests/parser-test-files/type-inference.txt b/tests/test-files/type-inference.txt similarity index 100% rename from tests/parser-test-files/type-inference.txt rename to tests/test-files/type-inference.txt diff --git a/tests/parser-test-files/unicode.coal b/tests/test-files/unicode.coal similarity index 100% rename from tests/parser-test-files/unicode.coal rename to tests/test-files/unicode.coal diff --git a/tests/parser-test-files/unicode.txt b/tests/test-files/unicode.txt similarity index 100% rename from tests/parser-test-files/unicode.txt rename to tests/test-files/unicode.txt diff --git a/tests/parser-test-files/unused-variables.txt b/tests/test-files/unused-variables.txt similarity index 100% rename from tests/parser-test-files/unused-variables.txt rename to tests/test-files/unused-variables.txt