Skip to content

Commit

Permalink
Add some failure tests for inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
abryant committed Jun 10, 2013
1 parent ab81f94 commit ccb77cb
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/error/cycle/ClassCycle.pth
@@ -0,0 +1,29 @@
// Plinth Test
// Compiler: ClassCycle.pth: 9:1-26: Cyclic inheritance hierarchy detected: Alpha extends itself (perhaps indirectly).
// Compiler: ClassCycle.pth: 13:1-28: Cyclic inheritance hierarchy detected: Bravo extends itself (perhaps indirectly).
// Compiler: ClassCycle.pth: 16:1-28: Cyclic inheritance hierarchy detected: Charlie extends itself (perhaps indirectly).
// Compiler: ClassCycle.pth: 20:1-28: Cyclic inheritance hierarchy detected: Delta extends itself (perhaps indirectly).
// Compiler: ClassCycle.pth: 23:1-25: Cyclic inheritance hierarchy detected: Echo extends itself (perhaps indirectly).
// Compiler: ClassCycle.pth: 26:1-27: Cyclic inheritance hierarchy detected: Foxtrot extends itself (perhaps indirectly).

class Alpha extends Alpha
{
}

class Bravo extends Charlie
{
}
class Charlie extends Bravo
{
}

class Delta extends Foxtrot
{
}
class Echo extends Delta
{
}
class Foxtrot extends Echo
{
}

31 changes: 31 additions & 0 deletions test/error/cycle/InterfaceCycle.pth
@@ -0,0 +1,31 @@
// Plinth Test
// Compiler: InterfaceCycle.pth: 8:1-30: Cyclic inheritance graph detected: Alpha extends itself (perhaps indirectly)
// Compiler: InterfaceCycle.pth: 12:1-39: Cyclic inheritance graph detected: Bravo extends itself (perhaps indirectly)
// Compiler: InterfaceCycle.pth: 15:1-32: Cyclic inheritance graph detected: Charlie extends itself (perhaps indirectly)
// Compiler: InterfaceCycle.pth: 25:1-37: Cyclic inheritance graph detected: Foxtrot extends itself (perhaps indirectly)
// Compiler: InterfaceCycle.pth: 28:1-37: Cyclic inheritance graph detected: Golf extends itself (perhaps indirectly)

interface Alpha extends Alpha
{
}

interface Bravo extends Charlie, Alpha
{
}
interface Charlie extends Bravo
{
}

interface Delta
{
}
interface Echo extends Delta
{
}
interface Foxtrot extends Golf, Echo
{
}
interface Golf extends Echo, Foxtrot
{
}

28 changes: 28 additions & 0 deletions test/error/inheritance/ClassInheritance.pth
@@ -0,0 +1,28 @@
// Plinth Test
// Compiler: ClassInheritance.pth: 7:1-27: A class may not extend a compound type
// Compiler: ClassInheritance.pth: 14:1-28: A class may not extend an interface
// Compiler: ClassInheritance.pth: 21:1-28: A class may not implement another class
// Compiler: ClassInheritance.pth: 25:1-32: A class may not implement a compound type

class Alpha extends string
{
}

interface Bravo
{
}
class Charlie extends Bravo
{
}

class Delta
{
}
class Echo implements Delta
{
}

class Foxtrot implements string
{
}

15 changes: 15 additions & 0 deletions test/error/inheritance/InterfaceInheritance.pth
@@ -0,0 +1,15 @@
// Plinth Test
// Compiler: InterfaceInheritance.pth: 8:1-30: An interface may not extend a class
// Compiler: InterfaceInheritance.pth: 12:1-33: An interface may not extend a compound type

class Alpha
{
}
interface Bravo extends Alpha
{
}

interface Charlie extends string
{
}

17 changes: 17 additions & 0 deletions test/error/inheritance/Linearisation.pth
@@ -0,0 +1,17 @@
// Plinth Test
// Compiler: Linearisation.pth: 14:1-38: Cannot find a good linearisation for the inheritance hierarchy of Charlie: cannot decide which of the following super-types should be preferred:
// Compiler: Alpha
// Compiler: Bravo

interface Alpha
{
}

interface Bravo extends Alpha
{
}

class Charlie implements Alpha, Bravo
{
}

0 comments on commit ccb77cb

Please sign in to comment.