Skip to content

Commit

Permalink
Add tests for compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
nomennescio committed Jan 21, 2024
1 parent 5cf876c commit b78ae13
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/test-compilation-error.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
test-compilation-error.factor

6: : wont-compile ;
^
Expected ( but got ;
(U) Quotation: [ c-to-factor => ]
Word: c-to-factor
(U) Quotation: [ [ (get-catchstack) push ] dip call => (get-catchstack) pop* ]
(O) Word: command-line-startup
(O) Word: run-script
(O) Word: run-file
(O) Word: parse-file
(O) Word: parse-stream
(O) Word: parse-fresh
(O) Word: (parse-lines)
(O) Word: (parse-until)
(O) Word: parse-until-step
(O) Word: execute-parsing
(O) Word: POSTPONE: :
(O) Word: (:)
(O) Word: scan-effect
(O) Word: expect
(O) Word: unexpected
(O) Method: M\ object throw
(U) Quotation: [
OBJ-CURRENT-THREAD special-object error-thread set-global
current-continuation => error-continuation set-global
[ original-error set-global ] [ rethrow ] bi
]
17 changes: 17 additions & 0 deletions test/test-compilation-error.factor
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
! Copyright 2024 nomennescio

USING: tools.testest kernel math ;
IN: tests

: wont-compile ;

: run-tests ( -- )

"Compilation error" describe#{
"Compilation error in user code" it#{
<{ wont-compile -> }>
}#
}#
;

MAIN: run-tests
18 changes: 18 additions & 0 deletions test/test-effect-error.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

<DESCRIBE::>Compilation error

<IT::>Compilation error in user code

==== test-effect-error.factor

test-effect-error.factor: 6

Asset: wont-infer

Stack effect declaration is wrong
inferred ( -- x )
declared ( -- )

<COMPLETEDIN::>0.345100 ms

<COMPLETEDIN::>0.516400 ms
17 changes: 17 additions & 0 deletions test/test-effect-error.factor
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
! Copyright 2024 nomennescio

USING: tools.testest kernel math ;
IN: tests

: wont-infer ( -- ) 0 ;

: run-tests ( -- )

"Compilation error" describe#{
"Compilation error in user code" it#{
<{ wont-infer -> }>
}#
}#
;

MAIN: run-tests

0 comments on commit b78ae13

Please sign in to comment.