Skip to content

Commit

Permalink
Add tests that some obvious problems give errors
Browse files Browse the repository at this point in the history
  • Loading branch information
abryant committed Jun 7, 2013
1 parent 1341829 commit 31133dc
Show file tree
Hide file tree
Showing 22 changed files with 183 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/error/DuplicateType.pth
@@ -0,0 +1,11 @@
// Plinth Test
// Compiler: DuplicateType.pth: 8:1-15: Duplicate type name: a type named 'Test' already exists in this compilation unit

class Test
{
}

interface Test
{
}

8 changes: 8 additions & 0 deletions test/error/class/DuplicateField.pth
@@ -0,0 +1,8 @@
// Plinth Test
// Compiler: DuplicateField.pth: 7:3-9: A field with the name 'x' already exists in 'Foo', so another field cannot be defined with the same name

class Foo
{
uint x;
Foo x;
}
8 changes: 8 additions & 0 deletions test/error/class/DuplicateFieldProperty.pth
@@ -0,0 +1,8 @@
// Plinth Test
// Compiler: DuplicateFieldProperty.pth: 7:3-20: A field with the name 'x' already exists in 'Foo', so a property cannot be defined with the same name

class Foo
{
uint x;
property ulong x;
}
8 changes: 8 additions & 0 deletions test/error/class/DuplicateProperty.pth
@@ -0,0 +1,8 @@
// Plinth Test
// Compiler: DuplicateProperty.pth: 7:3-19: A property with the name 'x' already exists in 'Foo', so another property cannot be defined with the same name

class Foo
{
property uint x;
property long x;
}
8 changes: 8 additions & 0 deletions test/error/class/DuplicatePropertyField.pth
@@ -0,0 +1,8 @@
// Plinth Test
// Compiler: DuplicatePropertyField.pth: 7:3-10: A property with the name 'x' already exists in 'Foo', so a field cannot be defined with the same name

class Foo
{
property ulong x;
uint x;
}
7 changes: 7 additions & 0 deletions test/error/class/DuplicateTypeParameter.pth
@@ -0,0 +1,7 @@
// Plinth Test
// Compiler: DuplicateTypeParameter.pth: 4:14: Duplicate type parameter: T

class Foo<T, T>
{
}

8 changes: 8 additions & 0 deletions test/error/compound/DuplicateField.pth
@@ -0,0 +1,8 @@
// Plinth Test
// Compiler: DuplicateField.pth: 7:3-9: A field with the name 'x' already exists in 'Foo', so another field cannot be defined with the same name

compound Foo
{
uint x;
Foo x;
}
8 changes: 8 additions & 0 deletions test/error/compound/DuplicateFieldProperty.pth
@@ -0,0 +1,8 @@
// Plinth Test
// Compiler: DuplicateFieldProperty.pth: 7:3-20: A field with the name 'x' already exists in 'Foo', so a property cannot be defined with the same name

compound Foo
{
uint x;
property ulong x;
}
8 changes: 8 additions & 0 deletions test/error/compound/DuplicateProperty.pth
@@ -0,0 +1,8 @@
// Plinth Test
// Compiler: DuplicateProperty.pth: 7:3-19: A property with the name 'x' already exists in 'Foo', so another property cannot be defined with the same name

compound Foo
{
property uint x;
property long x;
}
8 changes: 8 additions & 0 deletions test/error/compound/DuplicatePropertyField.pth
@@ -0,0 +1,8 @@
// Plinth Test
// Compiler: DuplicatePropertyField.pth: 7:3-10: A property with the name 'x' already exists in 'Foo', so a field cannot be defined with the same name

compound Foo
{
property ulong x;
uint x;
}
7 changes: 7 additions & 0 deletions test/error/compound/DuplicateTypeParameter.pth
@@ -0,0 +1,7 @@
// Plinth Test
// Compiler: DuplicateTypeParameter.pth: 4:17: Duplicate type parameter: T

compound Foo<T, T>
{
}

9 changes: 9 additions & 0 deletions test/error/interface/Constructor.pth
@@ -0,0 +1,9 @@
// Plinth Test
// Compiler: Constructor.pth: 6:3-11: Interfaces cannot have constructors

interface Test
{
create()
{
}
}
8 changes: 8 additions & 0 deletions test/error/interface/DuplicateField.pth
@@ -0,0 +1,8 @@
// Plinth Test
// Compiler: DuplicateField.pth: 7:3-16: A field with the name 'x' already exists in 'Foo', so another field cannot be defined with the same name

interface Foo
{
static uint x;
static Foo x;
}
8 changes: 8 additions & 0 deletions test/error/interface/DuplicateFieldProperty.pth
@@ -0,0 +1,8 @@
// Plinth Test
// Compiler: DuplicateFieldProperty.pth: 7:3-27: A field with the name 'x' already exists in 'Foo', so a property cannot be defined with the same name

interface Foo
{
static uint x;
static property ulong x;
}
8 changes: 8 additions & 0 deletions test/error/interface/DuplicateProperty.pth
@@ -0,0 +1,8 @@
// Plinth Test
// Compiler: DuplicateProperty.pth: 7:3-19: A property with the name 'x' already exists in 'Foo', so another property cannot be defined with the same name

interface Foo
{
property uint x;
property long x;
}
8 changes: 8 additions & 0 deletions test/error/interface/DuplicatePropertyField.pth
@@ -0,0 +1,8 @@
// Plinth Test
// Compiler: DuplicatePropertyField.pth: 7:3-17: A property with the name 'x' already exists in 'Foo', so a field cannot be defined with the same name

interface Foo
{
static property ulong x;
static uint x;
}
7 changes: 7 additions & 0 deletions test/error/interface/DuplicateTypeParameter.pth
@@ -0,0 +1,7 @@
// Plinth Test
// Compiler: DuplicateTypeParameter.pth: 4:18: Duplicate type parameter: T

interface Foo<T, T>
{
}

9 changes: 9 additions & 0 deletions test/error/interface/NativeUpcall.pth
@@ -0,0 +1,9 @@
// Plinth Test
// Compiler: NativeUpcall.pth: 6:3-36: Non-static methods on generic interfaces cannot be native up-calls

interface Test<T>
{
native "test" void nativeUpcall()
{
}
}
11 changes: 11 additions & 0 deletions test/error/interface/NonStaticBackedProperty.pth
@@ -0,0 +1,11 @@
// Plinth Test
// Compiler: NonStaticBackedProperty.pth: 6:3-18: Interfaces cannot store (non-static) data - should this property be unbacked?

interface Test
{
property uint x
getter
{
return x;
};
}
7 changes: 7 additions & 0 deletions test/error/interface/NonStaticField.pth
@@ -0,0 +1,7 @@
// Plinth Test
// Compiler: NonStaticField.pth: 6:3-10: Interfaces cannot store (non-static) data

interface Foo
{
uint x;
}
9 changes: 9 additions & 0 deletions test/error/interface/NonStaticInitialiser.pth
@@ -0,0 +1,9 @@
// Plinth Test
// Compiler: NonStaticInitialiser.pth: 6:3: Interfaces cannot contain non-static initialisers

interface Foo
{
{
// this is an initialiser
}
}
10 changes: 10 additions & 0 deletions test/error/member/Property.pth
@@ -0,0 +1,10 @@
// Plinth Test
// Compiler: Property.pth: 7:17-22: A property method cannot throw checked exceptions. Consider marking them as unchecked.

class Test
{
property uint foo
getter throws Alpha
{
};
}

0 comments on commit 31133dc

Please sign in to comment.