-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-550 Add simple type.panda test and fix call to another constructor…
… through 'this' keyword
- Loading branch information
Showing
3 changed files
with
50 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module lang | ||
|
||
main { | ||
Foo defaultFoo = new Foo() | ||
log 'Static' == Foo.staticField | ||
log 'Static' == defaultFoo.staticField | ||
log 'Default' == defaultFoo.field | ||
log 'Default' == defaultFoo.field() | ||
|
||
Foo foo = new Foo('Custom') | ||
log 'Custom' == foo.field | ||
log 'Custom' == foo.field() | ||
} | ||
|
||
open type Foo { | ||
|
||
open static String staticField = 'Static' | ||
|
||
internal String field | ||
|
||
constructor (String field) { | ||
this.field = field | ||
} | ||
|
||
constructor () { | ||
this('Default') | ||
} | ||
|
||
shared field () -> String { | ||
return field | ||
} | ||
|
||
} |
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
14 changes: 14 additions & 0 deletions
14
panda/src/test/groovy/org/panda_lang/panda/examples/lang/TypeTest.groovy
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,14 @@ | ||
package org.panda_lang.panda.examples.lang | ||
|
||
import groovy.transform.CompileStatic | ||
import org.junit.jupiter.api.Test | ||
|
||
@CompileStatic | ||
class TypeTest extends LangTestSpecification { | ||
|
||
@Test | ||
void 'should handle types' () { | ||
launch 'type.panda' | ||
} | ||
|
||
} |