summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBjörn Harrtell <bjornharrtell@users.noreply.github.com>2021-05-03 21:04:34 +0200
committerGitHub <noreply@github.com>2021-05-03 12:04:34 -0700
commit60ff76630d590478f12246ab6c1db50232272437 (patch)
tree0bd43253dfa51883eeab1dfbf7e30edfaf014675 /tests
parenta27c7d809311f102a6888411aa875fa1523c26b7 (diff)
downloadflatbuffers-60ff76630d590478f12246ab6c1db50232272437.tar.gz
flatbuffers-60ff76630d590478f12246ab6c1db50232272437.tar.bz2
flatbuffers-60ff76630d590478f12246ab6c1db50232272437.zip
[TS] Remove wrong and obsolete NS prefix use (#6604)
Diffstat (limited to 'tests')
-rw-r--r--tests/namespace_test/namespace-a/namespace-b/enum-in-nested-n-s.js7
-rw-r--r--tests/namespace_test/namespace-a/namespace-b/struct-in-nested-n-s.js54
-rw-r--r--tests/namespace_test/namespace-a/namespace-b/table-in-nested-n-s.js64
-rw-r--r--tests/namespace_test/namespace-a/namespace-b/union-in-nested-n-s.js21
-rw-r--r--tests/namespace_test/namespace-a/second-table-in-a.js58
-rw-r--r--tests/namespace_test/namespace-a/table-in-first-n-s.js119
-rw-r--r--tests/namespace_test/namespace-c/table-in-c.js67
-rw-r--r--tests/tsconfig.json4
8 files changed, 391 insertions, 3 deletions
diff --git a/tests/namespace_test/namespace-a/namespace-b/enum-in-nested-n-s.js b/tests/namespace_test/namespace-a/namespace-b/enum-in-nested-n-s.js
new file mode 100644
index 00000000..9105ed44
--- /dev/null
+++ b/tests/namespace_test/namespace-a/namespace-b/enum-in-nested-n-s.js
@@ -0,0 +1,7 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+export var EnumInNestedNS;
+(function (EnumInNestedNS) {
+ EnumInNestedNS[EnumInNestedNS["A"] = 0] = "A";
+ EnumInNestedNS[EnumInNestedNS["B"] = 1] = "B";
+ EnumInNestedNS[EnumInNestedNS["C"] = 2] = "C";
+})(EnumInNestedNS || (EnumInNestedNS = {}));
diff --git a/tests/namespace_test/namespace-a/namespace-b/struct-in-nested-n-s.js b/tests/namespace_test/namespace-a/namespace-b/struct-in-nested-n-s.js
new file mode 100644
index 00000000..918e238e
--- /dev/null
+++ b/tests/namespace_test/namespace-a/namespace-b/struct-in-nested-n-s.js
@@ -0,0 +1,54 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+export class StructInNestedNS {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ a() {
+ return this.bb.readInt32(this.bb_pos);
+ }
+ mutate_a(value) {
+ this.bb.writeInt32(this.bb_pos + 0, value);
+ return true;
+ }
+ b() {
+ return this.bb.readInt32(this.bb_pos + 4);
+ }
+ mutate_b(value) {
+ this.bb.writeInt32(this.bb_pos + 4, value);
+ return true;
+ }
+ static getFullyQualifiedName() {
+ return 'NamespaceA.NamespaceB.StructInNestedNS';
+ }
+ static sizeOf() {
+ return 8;
+ }
+ static createStructInNestedNS(builder, a, b) {
+ builder.prep(4, 8);
+ builder.writeInt32(b);
+ builder.writeInt32(a);
+ return builder.offset();
+ }
+ unpack() {
+ return new StructInNestedNST(this.a(), this.b());
+ }
+ unpackTo(_o) {
+ _o.a = this.a();
+ _o.b = this.b();
+ }
+}
+export class StructInNestedNST {
+ constructor(a = 0, b = 0) {
+ this.a = a;
+ this.b = b;
+ }
+ pack(builder) {
+ return StructInNestedNS.createStructInNestedNS(builder, this.a, this.b);
+ }
+}
diff --git a/tests/namespace_test/namespace-a/namespace-b/table-in-nested-n-s.js b/tests/namespace_test/namespace-a/namespace-b/table-in-nested-n-s.js
new file mode 100644
index 00000000..fca1668c
--- /dev/null
+++ b/tests/namespace_test/namespace-a/namespace-b/table-in-nested-n-s.js
@@ -0,0 +1,64 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+import * as flatbuffers from 'flatbuffers';
+export class TableInNestedNS {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ static getRootAsTableInNestedNS(bb, obj) {
+ return (obj || new TableInNestedNS()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getSizePrefixedRootAsTableInNestedNS(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new TableInNestedNS()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ foo() {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;
+ }
+ mutate_foo(value) {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt32(this.bb_pos + offset, value);
+ return true;
+ }
+ static getFullyQualifiedName() {
+ return 'NamespaceA.NamespaceB.TableInNestedNS';
+ }
+ static startTableInNestedNS(builder) {
+ builder.startObject(1);
+ }
+ static addFoo(builder, foo) {
+ builder.addFieldInt32(0, foo, 0);
+ }
+ static endTableInNestedNS(builder) {
+ const offset = builder.endObject();
+ return offset;
+ }
+ static createTableInNestedNS(builder, foo) {
+ TableInNestedNS.startTableInNestedNS(builder);
+ TableInNestedNS.addFoo(builder, foo);
+ return TableInNestedNS.endTableInNestedNS(builder);
+ }
+ unpack() {
+ return new TableInNestedNST(this.foo());
+ }
+ unpackTo(_o) {
+ _o.foo = this.foo();
+ }
+}
+export class TableInNestedNST {
+ constructor(foo = 0) {
+ this.foo = foo;
+ }
+ pack(builder) {
+ return TableInNestedNS.createTableInNestedNS(builder, this.foo);
+ }
+}
diff --git a/tests/namespace_test/namespace-a/namespace-b/union-in-nested-n-s.js b/tests/namespace_test/namespace-a/namespace-b/union-in-nested-n-s.js
new file mode 100644
index 00000000..b820bcea
--- /dev/null
+++ b/tests/namespace_test/namespace-a/namespace-b/union-in-nested-n-s.js
@@ -0,0 +1,21 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+import { TableInNestedNS } from '../../namespace-a/namespace-b/table-in-nested-n-s';
+export var UnionInNestedNS;
+(function (UnionInNestedNS) {
+ UnionInNestedNS[UnionInNestedNS["NONE"] = 0] = "NONE";
+ UnionInNestedNS[UnionInNestedNS["TableInNestedNS"] = 1] = "TableInNestedNS";
+})(UnionInNestedNS || (UnionInNestedNS = {}));
+export function unionToUnionInNestedNS(type, accessor) {
+ switch (UnionInNestedNS[type]) {
+ case 'NONE': return null;
+ case 'TableInNestedNS': return accessor(new TableInNestedNS());
+ default: return null;
+ }
+}
+export function unionListToUnionInNestedNS(type, accessor, index) {
+ switch (UnionInNestedNS[type]) {
+ case 'NONE': return null;
+ case 'TableInNestedNS': return accessor(index, new TableInNestedNS());
+ default: return null;
+ }
+}
diff --git a/tests/namespace_test/namespace-a/second-table-in-a.js b/tests/namespace_test/namespace-a/second-table-in-a.js
new file mode 100644
index 00000000..fe848e01
--- /dev/null
+++ b/tests/namespace_test/namespace-a/second-table-in-a.js
@@ -0,0 +1,58 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+import * as flatbuffers from 'flatbuffers';
+import { TableInC } from '../namespace-c/table-in-c';
+export class SecondTableInA {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ static getRootAsSecondTableInA(bb, obj) {
+ return (obj || new SecondTableInA()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getSizePrefixedRootAsSecondTableInA(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new SecondTableInA()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ referToC(obj) {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? (obj || new TableInC()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
+ }
+ static getFullyQualifiedName() {
+ return 'NamespaceA.SecondTableInA';
+ }
+ static startSecondTableInA(builder) {
+ builder.startObject(1);
+ }
+ static addReferToC(builder, referToCOffset) {
+ builder.addFieldOffset(0, referToCOffset, 0);
+ }
+ static endSecondTableInA(builder) {
+ const offset = builder.endObject();
+ return offset;
+ }
+ static createSecondTableInA(builder, referToCOffset) {
+ SecondTableInA.startSecondTableInA(builder);
+ SecondTableInA.addReferToC(builder, referToCOffset);
+ return SecondTableInA.endSecondTableInA(builder);
+ }
+ unpack() {
+ return new SecondTableInAT((this.referToC() !== null ? this.referToC().unpack() : null));
+ }
+ unpackTo(_o) {
+ _o.referToC = (this.referToC() !== null ? this.referToC().unpack() : null);
+ }
+}
+export class SecondTableInAT {
+ constructor(referToC = null) {
+ this.referToC = referToC;
+ }
+ pack(builder) {
+ const referToC = (this.referToC !== null ? this.referToC.pack(builder) : 0);
+ return SecondTableInA.createSecondTableInA(builder, referToC);
+ }
+}
diff --git a/tests/namespace_test/namespace-a/table-in-first-n-s.js b/tests/namespace_test/namespace-a/table-in-first-n-s.js
new file mode 100644
index 00000000..91bcc856
--- /dev/null
+++ b/tests/namespace_test/namespace-a/table-in-first-n-s.js
@@ -0,0 +1,119 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+import * as flatbuffers from 'flatbuffers';
+import { EnumInNestedNS } from '../namespace-a/namespace-b/enum-in-nested-n-s';
+import { StructInNestedNS } from '../namespace-a/namespace-b/struct-in-nested-n-s';
+import { TableInNestedNS } from '../namespace-a/namespace-b/table-in-nested-n-s';
+import { UnionInNestedNS, unionToUnionInNestedNS } from '../namespace-a/namespace-b/union-in-nested-n-s';
+export class TableInFirstNS {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ static getRootAsTableInFirstNS(bb, obj) {
+ return (obj || new TableInFirstNS()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getSizePrefixedRootAsTableInFirstNS(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new TableInFirstNS()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ fooTable(obj) {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? (obj || new TableInNestedNS()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
+ }
+ fooEnum() {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? this.bb.readInt8(this.bb_pos + offset) : EnumInNestedNS.A;
+ }
+ mutate_foo_enum(value) {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ if (offset === 0) {
+ return false;
+ }
+ this.bb.writeInt8(this.bb_pos + offset, value);
+ return true;
+ }
+ fooUnionType() {
+ const offset = this.bb.__offset(this.bb_pos, 8);
+ return offset ? this.bb.readUint8(this.bb_pos + offset) : UnionInNestedNS.NONE;
+ }
+ fooUnion(obj) {
+ const offset = this.bb.__offset(this.bb_pos, 10);
+ return offset ? this.bb.__union(obj, this.bb_pos + offset) : null;
+ }
+ fooStruct(obj) {
+ const offset = this.bb.__offset(this.bb_pos, 12);
+ return offset ? (obj || new StructInNestedNS()).__init(this.bb_pos + offset, this.bb) : null;
+ }
+ static getFullyQualifiedName() {
+ return 'NamespaceA.TableInFirstNS';
+ }
+ static startTableInFirstNS(builder) {
+ builder.startObject(5);
+ }
+ static addFooTable(builder, fooTableOffset) {
+ builder.addFieldOffset(0, fooTableOffset, 0);
+ }
+ static addFooEnum(builder, fooEnum) {
+ builder.addFieldInt8(1, fooEnum, EnumInNestedNS.A);
+ }
+ static addFooUnionType(builder, fooUnionType) {
+ builder.addFieldInt8(2, fooUnionType, UnionInNestedNS.NONE);
+ }
+ static addFooUnion(builder, fooUnionOffset) {
+ builder.addFieldOffset(3, fooUnionOffset, 0);
+ }
+ static addFooStruct(builder, fooStructOffset) {
+ builder.addFieldStruct(4, fooStructOffset, 0);
+ }
+ static endTableInFirstNS(builder) {
+ const offset = builder.endObject();
+ return offset;
+ }
+ unpack() {
+ return new TableInFirstNST((this.fooTable() !== null ? this.fooTable().unpack() : null), this.fooEnum(), this.fooUnionType(), (() => {
+ let temp = unionToUnionInNestedNS(this.fooUnionType(), this.fooUnion.bind(this));
+ if (temp === null) {
+ return null;
+ }
+ return temp.unpack();
+ })(), (this.fooStruct() !== null ? this.fooStruct().unpack() : null));
+ }
+ unpackTo(_o) {
+ _o.fooTable = (this.fooTable() !== null ? this.fooTable().unpack() : null);
+ _o.fooEnum = this.fooEnum();
+ _o.fooUnionType = this.fooUnionType();
+ _o.fooUnion = (() => {
+ let temp = unionToUnionInNestedNS(this.fooUnionType(), this.fooUnion.bind(this));
+ if (temp === null) {
+ return null;
+ }
+ return temp.unpack();
+ })();
+ _o.fooStruct = (this.fooStruct() !== null ? this.fooStruct().unpack() : null);
+ }
+}
+export class TableInFirstNST {
+ constructor(fooTable = null, fooEnum = EnumInNestedNS.A, fooUnionType = UnionInNestedNS.NONE, fooUnion = null, fooStruct = null) {
+ this.fooTable = fooTable;
+ this.fooEnum = fooEnum;
+ this.fooUnionType = fooUnionType;
+ this.fooUnion = fooUnion;
+ this.fooStruct = fooStruct;
+ }
+ pack(builder) {
+ const fooTable = (this.fooTable !== null ? this.fooTable.pack(builder) : 0);
+ const fooUnion = builder.createObjectOffset(this.fooUnion);
+ TableInFirstNS.startTableInFirstNS(builder);
+ TableInFirstNS.addFooTable(builder, fooTable);
+ TableInFirstNS.addFooEnum(builder, this.fooEnum);
+ TableInFirstNS.addFooUnionType(builder, this.fooUnionType);
+ TableInFirstNS.addFooUnion(builder, fooUnion);
+ TableInFirstNS.addFooStruct(builder, (this.fooStruct !== null ? this.fooStruct.pack(builder) : 0));
+ return TableInFirstNS.endTableInFirstNS(builder);
+ }
+}
diff --git a/tests/namespace_test/namespace-c/table-in-c.js b/tests/namespace_test/namespace-c/table-in-c.js
new file mode 100644
index 00000000..d097a3c3
--- /dev/null
+++ b/tests/namespace_test/namespace-c/table-in-c.js
@@ -0,0 +1,67 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+import * as flatbuffers from 'flatbuffers';
+import { SecondTableInA } from '../namespace-a/second-table-in-a';
+import { TableInFirstNS } from '../namespace-a/table-in-first-n-s';
+export class TableInC {
+ constructor() {
+ this.bb = null;
+ this.bb_pos = 0;
+ }
+ __init(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+ }
+ static getRootAsTableInC(bb, obj) {
+ return (obj || new TableInC()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ static getSizePrefixedRootAsTableInC(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new TableInC()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+ }
+ referToA1(obj) {
+ const offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? (obj || new TableInFirstNS()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
+ }
+ referToA2(obj) {
+ const offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? (obj || new SecondTableInA()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
+ }
+ static getFullyQualifiedName() {
+ return 'NamespaceC.TableInC';
+ }
+ static startTableInC(builder) {
+ builder.startObject(2);
+ }
+ static addReferToA1(builder, referToA1Offset) {
+ builder.addFieldOffset(0, referToA1Offset, 0);
+ }
+ static addReferToA2(builder, referToA2Offset) {
+ builder.addFieldOffset(1, referToA2Offset, 0);
+ }
+ static endTableInC(builder) {
+ const offset = builder.endObject();
+ return offset;
+ }
+ unpack() {
+ return new TableInCT((this.referToA1() !== null ? this.referToA1().unpack() : null), (this.referToA2() !== null ? this.referToA2().unpack() : null));
+ }
+ unpackTo(_o) {
+ _o.referToA1 = (this.referToA1() !== null ? this.referToA1().unpack() : null);
+ _o.referToA2 = (this.referToA2() !== null ? this.referToA2().unpack() : null);
+ }
+}
+export class TableInCT {
+ constructor(referToA1 = null, referToA2 = null) {
+ this.referToA1 = referToA1;
+ this.referToA2 = referToA2;
+ }
+ pack(builder) {
+ const referToA1 = (this.referToA1 !== null ? this.referToA1.pack(builder) : 0);
+ const referToA2 = (this.referToA2 !== null ? this.referToA2.pack(builder) : 0);
+ TableInC.startTableInC(builder);
+ TableInC.addReferToA1(builder, referToA1);
+ TableInC.addReferToA2(builder, referToA2);
+ return TableInC.endTableInC(builder);
+ }
+}
diff --git a/tests/tsconfig.json b/tests/tsconfig.json
index eff2469c..7d126a28 100644
--- a/tests/tsconfig.json
+++ b/tests/tsconfig.json
@@ -15,9 +15,7 @@
"include": [
"my-game/**/*.ts",
"optional_scalars/**/*.ts",
+ "namespace_test/**/*.ts",
"union_vector/**/*.ts"
- ],
- "exclude": [
- "namespace_test/**/*.ts"
]
}