-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
368 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package typisierung | ||
|
||
import ( | ||
"Tawa/kompilierer/ast" | ||
"Tawa/kompilierer/fehlerberichtung" | ||
"embed" | ||
"testing" | ||
|
||
"github.com/ztrue/tracerr" | ||
) | ||
|
||
//go:embed test/* | ||
var testDateien embed.FS | ||
|
||
func TestDateien(t *testing.T) { | ||
files, feh := testDateien.ReadDir("test/erwarte-gut") | ||
if feh != nil { | ||
panic("fehler: " + feh.Error()) | ||
} | ||
for _, datei := range files { | ||
k := NeuKontext() | ||
|
||
data, feh := testDateien.ReadFile("test/erwarte-gut/" + datei.Name()) | ||
t.Log(datei.Name()) | ||
if feh != nil { | ||
panic("fehler: " + feh.Error()) | ||
} | ||
|
||
modul := ast.Modul{} | ||
feh = ast.Parser.ParseBytes(datei.Name(), data, &modul) | ||
if feh != nil { | ||
panic(feh) | ||
} | ||
|
||
_, feh = zuGetypisierteAst(k, "Tawa", modul) | ||
if feh != nil { | ||
v, ok := feh.(fehlerberichtung.VerketteterFehler) | ||
if ok { | ||
for _, it := range v.Fehler { | ||
t.Logf("%s", tracerr.Sprint(it)) | ||
} | ||
} else { | ||
t.Logf("%s", tracerr.Sprint(feh)) | ||
} | ||
t.FailNow() | ||
} | ||
} | ||
files, feh = testDateien.ReadDir("test/erwarte-schlecht") | ||
if feh != nil { | ||
panic("fehler: " + feh.Error()) | ||
} | ||
for _, datei := range files { | ||
k := NeuKontext() | ||
|
||
data, feh := testDateien.ReadFile("test/erwarte-schlecht/" + datei.Name()) | ||
t.Log(datei.Name()) | ||
if feh != nil { | ||
panic("fehler: " + feh.Error()) | ||
} | ||
|
||
modul := ast.Modul{} | ||
feh = ast.Parser.ParseBytes(datei.Name(), data, &modul) | ||
if feh != nil { | ||
panic(feh) | ||
} | ||
|
||
_, feh = zuGetypisierteAst(k, "Tawa", modul) | ||
if feh == nil { | ||
t.Fatalf("fehler erwartet") | ||
} | ||
println(feh.Error()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
kompilierer/typisierung/test/erwarte-gut/00-annotation.tawa
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
paket Haupt zeigt alles | ||
|
||
funk Annotation() | ||
Debuggen:druck( | ||
Liste:map([1, 2, 3], \(x: Ganz): Ganz => x + 1) | ||
) | ||
|
||
funk KeinAnnotation() | ||
Debuggen:druck( | ||
Liste:map([1, 2, 3], \(x) => x + 1) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
paket Haupt zeigt alles | ||
|
||
funk IstEinheit(): Einheit | ||
Debuggen:druck("jo!") |
5 changes: 5 additions & 0 deletions
5
kompilierer/typisierung/test/erwarte-gut/02-funktionersterklasse.tawa
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
paket Haupt zeigt alles | ||
|
||
funk Annotation(): Ganz | ||
sei x = \(x: Ganz) => x + 1 in | ||
x.(5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
paket Haupt zeigt alles | ||
|
||
funk Liste1() | ||
sei x = [1] in | ||
x | ||
|
||
funk Liste2() | ||
sei x: Liste[Ganz] = [] in | ||
x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
paket Strukt zeigt nichts | ||
|
||
typ Struktur ist | ||
a: Ganz | ||
b: Ganz | ||
beende | ||
|
||
funk NeuStruktur(): Struktur | ||
#Struktur { a = 5, b = 50 } | ||
|
||
funk NeuerStruktur(): Struktur | ||
{ NeuStruktur() | a = 5, b = 3 } | ||
|
||
funk WasIst(a: Struktur): Ganz | ||
a.a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
paket Haupt zeigt nichts | ||
|
||
funk Comp1() | ||
1 < 2 | ||
|
||
funk Comp2() | ||
1 > 2 | ||
|
||
funk Comp3() | ||
1 >= 2 | ||
|
||
funk Comp4() | ||
1 <= 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
paket Haupt zeigt nichts | ||
|
||
funk Verketten1() | ||
[1] ++ [2] |
Oops, something went wrong.