Skip to content

Commit

Permalink
Merge pull request #3779 from simonvonhackewitz/replace_negative_test…
Browse files Browse the repository at this point in the history
…s_batch3

tests: replace negative tests with simple_and_negative tests (batch 3)
  • Loading branch information
michaellilltokiwa committed Sep 13, 2024
2 parents 5b72f9f + e3ba566 commit 8a1104b
Show file tree
Hide file tree
Showing 20 changed files with 884 additions and 33 deletions.
2 changes: 1 addition & 1 deletion tests/choice_negative2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
# -----------------------------------------------------------------------

override NAME = choice_negative
include ../negative.mk
include ../simple_and_negative.mk
37 changes: 37 additions & 0 deletions tests/choice_negative2/choice_negative.fz.expected_err
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

--CURDIR--/choice_negative.fz:29:5: error 1: Cyclic field nesting is not permitted
A is
----^
Cyclic value field nesting would result in infinitely large objects.
Cycle of nesting found during clazz layout:
--CURDIR--/choice_negative.fz:30:7:
x A | i32 | String := "Hello" // 4. should flag an error: cyclic choice
------^

To solve this, you could change one or several of the fields involved to a reference type by adding 'ref' before the type.


--CURDIR--/choice_negative.fz:52:5: error 2: Cyclic field nesting is not permitted
A is
----^
Cyclic value field nesting would result in infinitely large objects.
Cycle of nesting found during clazz layout:
--CURDIR--/choice_negative.fz:53:7:
x i32 | A | String := "Hello" // 5. should flag an error: cyclic choice
------^

To solve this, you could change one or several of the fields involved to a reference type by adding 'ref' before the type.


--CURDIR--/choice_negative.fz:75:5: error 3: Cyclic field nesting is not permitted
A is
----^
Cyclic value field nesting would result in infinitely large objects.
Cycle of nesting found during clazz layout:
--CURDIR--/choice_negative.fz:76:7:
x i32 | String | A := "Hello" // 6. should flag an error: cyclic choice
------^

To solve this, you could change one or several of the fields involved to a reference type by adding 'ref' before the type.

3 errors.
Empty file.
3 changes: 2 additions & 1 deletion tests/doubledeclaration_negative/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@
# -----------------------------------------------------------------------

override NAME = doubledeclaration_negative
include ../negative.mk
override FUZION_OPTIONS = -sourceDirs=. # NYI: currently required for this test wo work as expected, see #3777
include ../simple_and_negative.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

./doubledeclaration2.fz:26:43: error 1: Qualified declaration not allowed for field
public doubledeclaration_negative.cyclic1.a := 4 // 1. should flag an error, field not allowed in qualified declaration
------------------------------------------^
All fields have to be declared textually within the source of their outer features.
Field declared: 'doubledeclaration_negative.cyclic1.a'
To solve this, you could move the declaration into the implementation of feature 'doubledeclaration_negative.cyclic1'. Alternatively, you can declare a routine instead.


./doubledeclaration2.fz:26:43: error 2: Duplicate feature declaration
public doubledeclaration_negative.cyclic1.a := 4 // 1. should flag an error, field not allowed in qualified declaration
------------------------------------------^
Feature that was declared repeatedly: 'doubledeclaration_negative.cyclic1.a'
originally declared at --CURDIR--/doubledeclaration_negative.fz:29:12:
public a := 3
-----------^
To solve this, consider renaming one of these two features, e.g., as 'aʼ' (using a unicode modifier letter apostrophe 'ʼ' U+02BC) or adding an additional argument (e.g. '_ unit' for an ignored unit argument used only to disambiguate these two).


./doubledeclaration2.fz:26:43: error 3: Initial value not allowed for feature not embedded in outer feature
public doubledeclaration_negative.cyclic1.a := 4 // 1. should flag an error, field not allowed in qualified declaration
------------------------------------------^
Fuzion currently does not know when to execute this initializer, so it is forbidden.
To solve this, move the declaration inside another feature or ask the Fuzion team for help.


./doubledeclaration2.fz:27:49: error 4: Duplicate feature declaration
public redef doubledeclaration_negative.cyclic1.b => 44 // 2. should flag an error, feature already declared in doubledeclaration_negative.fz
------------------------------------------------^
Feature that was declared repeatedly: 'doubledeclaration_negative.cyclic1.b'
originally declared at --CURDIR--/doubledeclaration_negative.fz:30:12:
public b => 33
-----------^
To solve this, consider renaming one of these two features, e.g., as 'bʼ' (using a unicode modifier letter apostrophe 'ʼ' U+02BC) or adding an additional argument (e.g. '_ unit' for an ignored unit argument used only to disambiguate these two).

4 errors.
Empty file.
2 changes: 1 addition & 1 deletion tests/generics_negative/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@

override NAME = generics_negative
FUZION_OPTIONS = -XenableSetKeyword
include ../negative.mk
include ../simple_and_negative.mk
18 changes: 9 additions & 9 deletions tests/generics_negative/generics_negative.fz
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ generics_negative is
set asdfg1 := uiop.asdfg
set asdfg2 := uiop.asdfg
set uiop := qwert.uiop
features_from_separate_source_file
_ := features_from_separate_source_file

outerGenerics is
A(T,U type) is
Expand All @@ -158,21 +158,21 @@ generics_negative is
x1 (A i32 bool ).B String bool := (A i32 bool).B String bool true
x2 (A i32 i32 ).B String bool := (A i64 bool).B String bool true // 45. should flag an error: incompatible types
x3 (A i32 String).B String bool := x1 // 46. should flag an error: incompatible types
x1.p
x2.p
x3.p
_ := x1.p
_ := x2.p
_ := x3.p
unit
outerGenerics
_ := outerGenerics

opengenerics12 is
F(A type...) ref is
f(a A) is abstract
f(a A) => abstract

G ref : F i32 bool i32 is
redef f(a0 i32, a1 bool, a2 i32) is
redef f(a0 i32, a1 bool, a2 i32) =>

x G := G
x.f 3 true 5
_ := x.f 3 true 5
x.f "String" false 7 // 47. should flag an error: incompatible argument #1
x.f 4 3 7 // 48. should flag an error: incompatible argument #2
x.f 4 false "false" // 49.a should flag an error: incompatible argument #3
Expand All @@ -181,7 +181,7 @@ generics_negative is
y.f "String" false 8 // 49.b should flag an error: incompatible argument #1
y.f 9 10 8 // 50. should flag an error: incompatible argument #2
y.f 9 false "8" // 51. should flag an error: incompatible argument #3
opengenerics12
_ := opengenerics12

ambiguousTypeParameterName =>
outer(X, Y, Z type) is
Expand Down
Loading

0 comments on commit 8a1104b

Please sign in to comment.