-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
9 changed files
with
431 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
load( | ||
"//javatests/jsinterop/generator:jsinterop_generator_test.bzl", | ||
"jsinterop_generator_test", | ||
) | ||
|
||
package( | ||
default_applicable_licenses = ["//:license"], | ||
licenses = ["notice"], | ||
) | ||
|
||
jsinterop_generator_test( | ||
name = "nullabletypes", | ||
srcs = ["nullabletypes.js"], | ||
expected_output = glob([ | ||
"*.java.txt", | ||
]), | ||
) |
196 changes: 196 additions & 0 deletions
196
javatests/jsinterop/generator/externs/nullabletypes/ClassWithNullableRefs.java.txt
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,196 @@ | ||
package jsinterop.generator.externs.nullabletypes; | ||
|
||
import jsinterop.annotations.JsFunction; | ||
import jsinterop.annotations.JsOverlay; | ||
import jsinterop.annotations.JsPackage; | ||
import jsinterop.annotations.JsProperty; | ||
import jsinterop.annotations.JsType; | ||
import jsinterop.base.Js; | ||
import jsinterop.base.JsPropertyMap; | ||
|
||
@JsType(isNative = true, namespace = JsPackage.GLOBAL) | ||
public class ClassWithNullableRefs { | ||
@JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) | ||
public interface AnonymousUnionTypeWithNullUnionType { | ||
@JsOverlay | ||
static ClassWithNullableRefs.AnonymousUnionTypeWithNullUnionType of(Object o) { | ||
return Js.cast(o); | ||
} | ||
|
||
@JsOverlay | ||
default double asDouble() { | ||
return Js.asDouble(this); | ||
} | ||
|
||
@JsOverlay | ||
default String asString() { | ||
return Js.asString(this); | ||
} | ||
|
||
@JsOverlay | ||
default boolean isDouble() { | ||
return (Object) this instanceof Double; | ||
} | ||
|
||
@JsOverlay | ||
default boolean isString() { | ||
return (Object) this instanceof String; | ||
} | ||
} | ||
|
||
@JsFunction | ||
public interface NullableAnonymousFunctionTypeRefFn { | ||
boolean onInvoke(String p0); | ||
} | ||
|
||
@JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) | ||
public interface NullableAnonymousRecordRefFieldType { | ||
@JsOverlay | ||
static ClassWithNullableRefs.NullableAnonymousRecordRefFieldType create() { | ||
return Js.uncheckedCast(JsPropertyMap.of()); | ||
} | ||
|
||
@JsProperty | ||
String getBar(); | ||
|
||
@JsProperty | ||
double getFoo(); | ||
|
||
@JsProperty | ||
void setBar(String bar); | ||
|
||
@JsProperty | ||
void setFoo(double foo); | ||
} | ||
|
||
@JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) | ||
public interface NullableAnonymousUnionTypeRef2UnionType { | ||
@JsOverlay | ||
static ClassWithNullableRefs.NullableAnonymousUnionTypeRef2UnionType of(Object o) { | ||
return Js.cast(o); | ||
} | ||
|
||
@JsOverlay | ||
default double asDouble() { | ||
return Js.asDouble(this); | ||
} | ||
|
||
@JsOverlay | ||
default String asString() { | ||
return Js.asString(this); | ||
} | ||
|
||
@JsOverlay | ||
default boolean isDouble() { | ||
return (Object) this instanceof Double; | ||
} | ||
|
||
@JsOverlay | ||
default boolean isString() { | ||
return (Object) this instanceof String; | ||
} | ||
} | ||
|
||
@JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) | ||
public interface NullableAnonymousUnionTypeRefUnionType { | ||
@JsOverlay | ||
static ClassWithNullableRefs.NullableAnonymousUnionTypeRefUnionType of(Object o) { | ||
return Js.cast(o); | ||
} | ||
|
||
@JsOverlay | ||
default double asDouble() { | ||
return Js.asDouble(this); | ||
} | ||
|
||
@JsOverlay | ||
default String asString() { | ||
return Js.asString(this); | ||
} | ||
|
||
@JsOverlay | ||
default boolean isDouble() { | ||
return (Object) this instanceof Double; | ||
} | ||
|
||
@JsOverlay | ||
default boolean isString() { | ||
return (Object) this instanceof String; | ||
} | ||
} | ||
|
||
@JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) | ||
public interface NullableUnionTypeRefUnionType { | ||
@JsOverlay | ||
static ClassWithNullableRefs.NullableUnionTypeRefUnionType of(Object o) { | ||
return Js.cast(o); | ||
} | ||
|
||
@JsOverlay | ||
default double asDouble() { | ||
return Js.asDouble(this); | ||
} | ||
|
||
@JsOverlay | ||
default String asString() { | ||
return Js.asString(this); | ||
} | ||
|
||
@JsOverlay | ||
default boolean isDouble() { | ||
return (Object) this instanceof Double; | ||
} | ||
|
||
@JsOverlay | ||
default boolean isString() { | ||
return (Object) this instanceof String; | ||
} | ||
} | ||
|
||
@JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) | ||
public interface UnionTypeWithNullRefUnionType { | ||
@JsOverlay | ||
static ClassWithNullableRefs.UnionTypeWithNullRefUnionType of(Object o) { | ||
return Js.cast(o); | ||
} | ||
|
||
@JsOverlay | ||
default double asDouble() { | ||
return Js.asDouble(this); | ||
} | ||
|
||
@JsOverlay | ||
default String asString() { | ||
return Js.asString(this); | ||
} | ||
|
||
@JsOverlay | ||
default boolean isDouble() { | ||
return (Object) this instanceof Double; | ||
} | ||
|
||
@JsOverlay | ||
default boolean isString() { | ||
return (Object) this instanceof String; | ||
} | ||
} | ||
|
||
public ClassWithNullableRefs.AnonymousUnionTypeWithNullUnionType anonymousUnionTypeWithNull; | ||
public ClassWithNullableRefs.NullableAnonymousFunctionTypeRefFn nullableAnonymousFunctionTypeRef; | ||
public ClassWithNullableRefs.NullableAnonymousRecordRefFieldType nullableAnonymousRecordRef; | ||
public ClassWithNullableRefs.NullableAnonymousUnionTypeRefUnionType nullableAnonymousUnionTypeRef; | ||
public ClassWithNullableRefs.NullableAnonymousUnionTypeRef2UnionType | ||
nullableAnonymousUnionTypeRef2; | ||
public SimpleEnum nullableEnumRef; | ||
public NullableFunctionType nullableFunctionTypeRef; | ||
public SimpleInterface nullableInterfaceRef; | ||
public double nullableNumber; | ||
public SimpleRecord nullableRecordRef; | ||
public String nullableString; | ||
public NullableTypeDefOfRecord nullableTypeDefOfRecordRef; | ||
public ClassWithNullableRefs.NullableUnionTypeRefUnionType nullableUnionTypeRef; | ||
public SimpleClass simpleClassRef; | ||
public ClassWithNullableRefs.UnionTypeWithNullRefUnionType unionTypeWithNullRef; | ||
|
||
public native SimpleRecord methodWithNullableParam(SimpleInterface foo); | ||
} |
8 changes: 8 additions & 0 deletions
8
javatests/jsinterop/generator/externs/nullabletypes/NullableFunctionType.java.txt
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,8 @@ | ||
package jsinterop.generator.externs.nullabletypes; | ||
|
||
import jsinterop.annotations.JsFunction; | ||
|
||
@JsFunction | ||
public interface NullableFunctionType { | ||
boolean onInvoke(String p0); | ||
} |
28 changes: 28 additions & 0 deletions
28
javatests/jsinterop/generator/externs/nullabletypes/NullableTypeDefOfRecord.java.txt
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,28 @@ | ||
package jsinterop.generator.externs.nullabletypes; | ||
|
||
import jsinterop.annotations.JsOverlay; | ||
import jsinterop.annotations.JsPackage; | ||
import jsinterop.annotations.JsProperty; | ||
import jsinterop.annotations.JsType; | ||
import jsinterop.base.Js; | ||
import jsinterop.base.JsPropertyMap; | ||
|
||
@JsType(isNative = true, namespace = JsPackage.GLOBAL) | ||
public interface NullableTypeDefOfRecord { | ||
@JsOverlay | ||
static NullableTypeDefOfRecord create() { | ||
return Js.uncheckedCast(JsPropertyMap.of()); | ||
} | ||
|
||
@JsProperty | ||
String getBar(); | ||
|
||
@JsProperty | ||
double getFoo(); | ||
|
||
@JsProperty | ||
void setBar(String bar); | ||
|
||
@JsProperty | ||
void setFoo(double foo); | ||
} |
7 changes: 7 additions & 0 deletions
7
javatests/jsinterop/generator/externs/nullabletypes/SimpleClass.java.txt
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,7 @@ | ||
package jsinterop.generator.externs.nullabletypes; | ||
|
||
import jsinterop.annotations.JsPackage; | ||
import jsinterop.annotations.JsType; | ||
|
||
@JsType(isNative = true, namespace = JsPackage.GLOBAL) | ||
public class SimpleClass {} |
10 changes: 10 additions & 0 deletions
10
javatests/jsinterop/generator/externs/nullabletypes/SimpleEnum.java.txt
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,10 @@ | ||
package jsinterop.generator.externs.nullabletypes; | ||
|
||
import jsinterop.annotations.JsEnum; | ||
import jsinterop.annotations.JsPackage; | ||
|
||
@JsEnum(isNative = true, namespace = JsPackage.GLOBAL) | ||
public enum SimpleEnum { | ||
A, | ||
B; | ||
} |
7 changes: 7 additions & 0 deletions
7
javatests/jsinterop/generator/externs/nullabletypes/SimpleInterface.java.txt
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,7 @@ | ||
package jsinterop.generator.externs.nullabletypes; | ||
|
||
import jsinterop.annotations.JsPackage; | ||
import jsinterop.annotations.JsType; | ||
|
||
@JsType(isNative = true, namespace = JsPackage.GLOBAL) | ||
public interface SimpleInterface {} |
7 changes: 7 additions & 0 deletions
7
javatests/jsinterop/generator/externs/nullabletypes/SimpleRecord.java.txt
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,7 @@ | ||
package jsinterop.generator.externs.nullabletypes; | ||
|
||
import jsinterop.annotations.JsPackage; | ||
import jsinterop.annotations.JsType; | ||
|
||
@JsType(isNative = true, namespace = JsPackage.GLOBAL) | ||
public interface SimpleRecord {} |
Oops, something went wrong.