mirror of
https://github.com/netbirdio/gomobile-tvos-fork.git
synced 2026-05-22 18:43:29 -07:00
bind: generate Java constructors for every exported struct
A recent CL added Java constructors to generated classes that extends or implements other Java classes and interfaces. Constructors for a struct S are Go functions on the form func NewS...(...) *S If no such constructors exists, a default empty constructor is generated. Expand that to cover every exported Go struct. Fixes golang/go#17086 Change-Id: I910aba13d5884c3f67c946c62a8ac4a3db8e2ea7 Reviewed-on: https://go-review.googlesource.com/29710 Reviewed-by: David Crawshaw <crawshaw@golang.org>
This commit is contained in:
@@ -527,6 +527,17 @@ public class SeqTest extends InstrumentationTestCase {
|
||||
assertTrue("Go struct passed through Java should not be wrapped", Testpkg.callCDupper(cdup));
|
||||
}
|
||||
|
||||
public void testConstructor() {
|
||||
Interface i = new Concrete();
|
||||
i.f();
|
||||
S2 s = new S2(1, 2);
|
||||
assertEquals("new S2().sum", 3.0, s.sum());
|
||||
assertEquals("new S2().tryTwoStrings", "gostring", s.tryTwoStrings("go", "string"));
|
||||
new S3();
|
||||
S4 s4 = new S4(123);
|
||||
assertEquals("Constructor argument", 123, s4.getI());
|
||||
}
|
||||
|
||||
public void testEmptyError() {
|
||||
try {
|
||||
Testpkg.emptyError();
|
||||
|
||||
Reference in New Issue
Block a user