From 60fb525f28a601de90e95bd6ed685cdefe9609ef Mon Sep 17 00:00:00 2001 From: Wade Klingler Date: Fri, 14 Oct 2016 09:24:09 -0600 Subject: [PATCH 1/2] Added implementation for Tuple with up to 3 items --- .../Bootstrap/Core/Classes/System.Tuple.js | 92 +++++++++++++++++++ .../Includes/Bootstrap/Core/Main.js | 2 + JSIL.Libraries/JSIL.Libraries.csproj | 1 + 3 files changed, 95 insertions(+) create mode 100644 JSIL.Libraries/Includes/Bootstrap/Core/Classes/System.Tuple.js diff --git a/JSIL.Libraries/Includes/Bootstrap/Core/Classes/System.Tuple.js b/JSIL.Libraries/Includes/Bootstrap/Core/Classes/System.Tuple.js new file mode 100644 index 000000000..7262c392b --- /dev/null +++ b/JSIL.Libraries/Includes/Bootstrap/Core/Classes/System.Tuple.js @@ -0,0 +1,92 @@ +JSIL.ImplementExternals( + "System.Tuple`1", function ($) { + var mscorlib = JSIL.GetCorlib(); + + function initFields(self) { + self.m_Item1 = null; + } + + $.Method({ Static: false, Public: true }, ".ctor", + (new JSIL.MethodSignature(null, [new JSIL.GenericParameter("T1", "System.Tuple`1")], [])), + function _ctor(item1) { + initFields(this); + + this.m_Item1 = item1; + }); + + $.Method({ Static: false, Public: true }, "get_Item1", + (new JSIL.MethodSignature(new JSIL.GenericParameter("T1", "System.Tuple`1"), [], [])), + function get_Item1() { + return this.m_Item1; + }); + } +); + +JSIL.ImplementExternals( + "System.Tuple`2", function ($) { + function initFields(self) { + self.m_Item1 = null; + self.m_Item2 = null; + } + + $.Method({ Static: false, Public: true }, ".ctor", + (new JSIL.MethodSignature(null, [new JSIL.GenericParameter("T1", "System.Tuple`2"), new JSIL.GenericParameter("T2", "System.Tuple`2")], [])), + function _ctor(item1, item2) { + initFields(this); + + this.m_Item1 = item1; + this.m_Item2 = item2; + }); + + $.Method({ Static: false, Public: true }, "get_Item1", + (new JSIL.MethodSignature(new JSIL.GenericParameter("T1", "System.Tuple`2"), [], [])), + function get_Item1() { + return this.m_Item1; + }); + + $.Method({ Static: false, Public: true }, "get_Item2", + (new JSIL.MethodSignature(new JSIL.GenericParameter("T2", "System.Tuple`2"), [], [])), + function get_Item2() { + return this.m_Item2; + }); + } +); + +JSIL.ImplementExternals( + "System.Tuple`3", function ($) { + function initFields(self) { + self.m_Item1 = null; + self.m_Item2 = null; + self.m_Item3 = null; + } + + $.Method({ Static: false, Public: true }, ".ctor", + (new JSIL.MethodSignature(null, [new JSIL.GenericParameter("T1", "System.Tuple`3"), new JSIL.GenericParameter("T2", "System.Tuple`3"), new JSIL.GenericParameter("T3", "System.Tuple`3")], [])), + function _ctor(item1, item2, item3) { + initFields(this); + + this.m_Item1 = item1; + this.m_Item2 = item2; + this.m_Item3 = item3; + }); + + $.Method({ Static: false, Public: true }, "get_Item1", + (new JSIL.MethodSignature(new JSIL.GenericParameter("T1", "System.Tuple`3"), [], [])), + function get_Item1() { + return this.m_Item1; + }); + + $.Method({ Static: false, Public: true }, "get_Item2", + (new JSIL.MethodSignature(new JSIL.GenericParameter("T2", "System.Tuple`3"), [], [])), + function get_Item2() { + return this.m_Item2; + }); + + $.Method({ Static: false, Public: true }, "get_Item3", + (new JSIL.MethodSignature(new JSIL.GenericParameter("T3", "System.Tuple`3"), [], [])), + function get_Item3() { + return this.m_Item3; + }); + } +); + diff --git a/JSIL.Libraries/Includes/Bootstrap/Core/Main.js b/JSIL.Libraries/Includes/Bootstrap/Core/Main.js index 93cb6a8f9..ffa5ef18b 100644 --- a/JSIL.Libraries/Includes/Bootstrap/Core/Main.js +++ b/JSIL.Libraries/Includes/Bootstrap/Core/Main.js @@ -44,6 +44,8 @@ JSIL.DeclareNamespace("System.Runtime.InteropServices"); //? include("Classes/System.String.js"); writeln(); +//? include("Classes/System.Tuple.js"); writeln(); + //? include("Classes/System.Enum.js"); writeln(); //? include("Classes/System.Activator.js"); writeln(); //? include("Classes/System.Nullable.js"); writeln(); diff --git a/JSIL.Libraries/JSIL.Libraries.csproj b/JSIL.Libraries/JSIL.Libraries.csproj index c6b3584a7..b875bc558 100644 --- a/JSIL.Libraries/JSIL.Libraries.csproj +++ b/JSIL.Libraries/JSIL.Libraries.csproj @@ -36,6 +36,7 @@ 4 + From e50d19462623513068bc2ef235816e484cfb8c3d Mon Sep 17 00:00:00 2001 From: Wade Klingler Date: Tue, 18 Oct 2016 09:31:20 -0600 Subject: [PATCH 2/2] Tuple class is completely implemented with all the constructors and Create methods. --- .../Bootstrap/Core/Classes/System.Tuple.js | 450 +++++++++++++++++- .../Includes/Bootstrap/Core/Main.js | 3 - Tests/ComparisonTests.cs | 16 + Tests/TestCases/Tuple.cs | 118 +++++ Tests/Tests.csproj | 1 + 5 files changed, 579 insertions(+), 9 deletions(-) create mode 100644 Tests/TestCases/Tuple.cs diff --git a/JSIL.Libraries/Includes/Bootstrap/Core/Classes/System.Tuple.js b/JSIL.Libraries/Includes/Bootstrap/Core/Classes/System.Tuple.js index 7262c392b..0ed5ed54c 100644 --- a/JSIL.Libraries/Includes/Bootstrap/Core/Classes/System.Tuple.js +++ b/JSIL.Libraries/Includes/Bootstrap/Core/Classes/System.Tuple.js @@ -1,10 +1,111 @@ JSIL.ImplementExternals( - "System.Tuple`1", function ($) { - var mscorlib = JSIL.GetCorlib(); + "System.Tuple", function($) { + $.Method({ Static: true, Public: true }, "Create", + (new JSIL.MethodSignature($jsilcore.TypeRef("System.Tuple`1", [new JSIL.GenericParameter("T1", "System.Tuple`1")]), + [new JSIL.GenericParameter("T1", "System.Tuple`1")], + [new JSIL.GenericParameter("T1", "System.Tuple`1")])), + function Create$b1(type, item1) { + return new (System.Tuple$b1.Of(type))(item1); + }); - function initFields(self) { - self.m_Item1 = null; - } + $.Method({ Static: true, Public: true }, "Create", + (new JSIL.MethodSignature($jsilcore.TypeRef("System.Tuple`2", [new JSIL.GenericParameter("T1", "System.Tuple`2"), new JSIL.GenericParameter("T2", "System.Tuple`2")]), + [new JSIL.GenericParameter("T1", "System.Tuple`2"), new JSIL.GenericParameter("T2", "System.Tuple`2")], + [new JSIL.GenericParameter("T1", "System.Tuple`2"), new JSIL.GenericParameter("T2", "System.Tuple`2")])), + function Create$b2(type1, type2, item1, item2) { + return new (System.Tuple$b2.Of(type1, type2))(item1, item2); + }); + + $.Method({ Static: true, Public: true }, "Create", + (new JSIL.MethodSignature($jsilcore.TypeRef("System.Tuple`3", [new JSIL.GenericParameter("T1", "System.Tuple`3"), new JSIL.GenericParameter("T2", "System.Tuple`3"), + new JSIL.GenericParameter("T3", "System.Tuple`3")]), + [new JSIL.GenericParameter("T1", "System.Tuple`3"), new JSIL.GenericParameter("T2", "System.Tuple`3"), + new JSIL.GenericParameter("T3", "System.Tuple`3")], + [new JSIL.GenericParameter("T1", "System.Tuple`3"), new JSIL.GenericParameter("T2", "System.Tuple`3"), + new JSIL.GenericParameter("T3", "System.Tuple`3")])), + function Create$b3(type1, type2, type3, item1, item2, item3) { + return new (System.Tuple$b3.Of(type1, type2, type3))(item1, item2, item3); + }); + + $.Method({ Static: true, Public: true }, "Create", + (new JSIL.MethodSignature($jsilcore.TypeRef("System.Tuple`4", [new JSIL.GenericParameter("T1", "System.Tuple`4"), new JSIL.GenericParameter("T2", "System.Tuple`4"), + new JSIL.GenericParameter("T3", "System.Tuple`4"), new JSIL.GenericParameter("T4", "System.Tuple`4")]), + [new JSIL.GenericParameter("T1", "System.Tuple`4"), new JSIL.GenericParameter("T2", "System.Tuple`4"), + new JSIL.GenericParameter("T3", "System.Tuple`4"), new JSIL.GenericParameter("T4", "System.Tuple`4")], + [new JSIL.GenericParameter("T1", "System.Tuple`4"), new JSIL.GenericParameter("T2", "System.Tuple`4"), + new JSIL.GenericParameter("T3", "System.Tuple`4"), new JSIL.GenericParameter("T4", "System.Tuple`4")])), + function Create$b4(type1, type2, type3, type4, item1, item2, item3, item4) { + return new (System.Tuple$b4.Of(type1, type2, type3, type4))(item1, item2, item3, item4); + }); + + $.Method({ Static: true, Public: true }, "Create", + (new JSIL.MethodSignature($jsilcore.TypeRef("System.Tuple`5", [new JSIL.GenericParameter("T1", "System.Tuple`5"), new JSIL.GenericParameter("T2", "System.Tuple`5"), + new JSIL.GenericParameter("T3", "System.Tuple`5"), new JSIL.GenericParameter("T4", "System.Tuple`5"), + new JSIL.GenericParameter("T5", "System.Tuple`5")]), + [new JSIL.GenericParameter("T1", "System.Tuple`5"), new JSIL.GenericParameter("T2", "System.Tuple`5"), + new JSIL.GenericParameter("T3", "System.Tuple`5"), new JSIL.GenericParameter("T4", "System.Tuple`5"), + new JSIL.GenericParameter("T5", "System.Tuple`5")], + [new JSIL.GenericParameter("T1", "System.Tuple`5"), new JSIL.GenericParameter("T2", "System.Tuple`5"), + new JSIL.GenericParameter("T3", "System.Tuple`5"), new JSIL.GenericParameter("T4", "System.Tuple`5"), + new JSIL.GenericParameter("T5", "System.Tuple`5")])), + function Create$b5(type1, type2, type3, type4, type5, item1, item2, item3, item4, item5) { + return new (System.Tuple$b5.Of(type1, type2, type3, type4, type5))(item1, item2, item3, item4, item5); + }); + + $.Method({ Static: true, Public: true }, "Create", + (new JSIL.MethodSignature($jsilcore.TypeRef("System.Tuple`6", [new JSIL.GenericParameter("T1", "System.Tuple`6"), new JSIL.GenericParameter("T2", "System.Tuple`6"), + new JSIL.GenericParameter("T3", "System.Tuple`6"), new JSIL.GenericParameter("T4", "System.Tuple`6"), + new JSIL.GenericParameter("T5", "System.Tuple`6"), new JSIL.GenericParameter("T6", "System.Tuple`6")]), + [new JSIL.GenericParameter("T1", "System.Tuple`6"), new JSIL.GenericParameter("T2", "System.Tuple`6"), + new JSIL.GenericParameter("T3", "System.Tuple`6"), new JSIL.GenericParameter("T4", "System.Tuple`6"), + new JSIL.GenericParameter("T5", "System.Tuple`6"), new JSIL.GenericParameter("T6", "System.Tuple`6")], + [new JSIL.GenericParameter("T1", "System.Tuple`6"), new JSIL.GenericParameter("T2", "System.Tuple`6"), + new JSIL.GenericParameter("T3", "System.Tuple`6"), new JSIL.GenericParameter("T4", "System.Tuple`6"), + new JSIL.GenericParameter("T5", "System.Tuple`6"), new JSIL.GenericParameter("T6", "System.Tuple`6")])), + function Create$b6(type1, type2, type3, type4, type5, type6, item1, item2, item3, item4, item5, item6) { + return new (System.Tuple$b6.Of(type1, type2, type3, type4, type5, type6))(item1, item2, item3, item4, item5, item6); + }); + + $.Method({ Static: true, Public: true }, "Create", + (new JSIL.MethodSignature($jsilcore.TypeRef("System.Tuple`7", [new JSIL.GenericParameter("T1", "System.Tuple`7"), new JSIL.GenericParameter("T2", "System.Tuple`7"), + new JSIL.GenericParameter("T3", "System.Tuple`7"), new JSIL.GenericParameter("T4", "System.Tuple`7"), + new JSIL.GenericParameter("T5", "System.Tuple`7"), new JSIL.GenericParameter("T6", "System.Tuple`7"), + new JSIL.GenericParameter("T7", "System.Tuple`7")]), + [new JSIL.GenericParameter("T1", "System.Tuple`7"), new JSIL.GenericParameter("T2", "System.Tuple`7"), + new JSIL.GenericParameter("T3", "System.Tuple`7"), new JSIL.GenericParameter("T4", "System.Tuple`7"), + new JSIL.GenericParameter("T5", "System.Tuple`7"), new JSIL.GenericParameter("T6", "System.Tuple`7"), + new JSIL.GenericParameter("T7", "System.Tuple`7")], + [new JSIL.GenericParameter("T1", "System.Tuple`7"), new JSIL.GenericParameter("T2", "System.Tuple`7"), + new JSIL.GenericParameter("T3", "System.Tuple`7"), new JSIL.GenericParameter("T4", "System.Tuple`7"), + new JSIL.GenericParameter("T5", "System.Tuple`7"), new JSIL.GenericParameter("T6", "System.Tuple`7"), + new JSIL.GenericParameter("T7", "System.Tuple`7")])), + function Create$b7(type1, type2, type3, type4, type5, type6, type7, item1, item2, item3, item4, item5, item6, item7) { + return new (System.Tuple$b7.Of(type1, type2, type3, type4, type5, type6, type7))(item1, item2, item3, item4, item5, item6, item7); + }); + + $.Method({ Static: true, Public: true }, "Create", + (new JSIL.MethodSignature($jsilcore.TypeRef("System.Tuple`8", [new JSIL.GenericParameter("T1", "System.Tuple`8"), new JSIL.GenericParameter("T2", "System.Tuple`8"), + new JSIL.GenericParameter("T3", "System.Tuple`8"), new JSIL.GenericParameter("T4", "System.Tuple`8"), + new JSIL.GenericParameter("T5", "System.Tuple`8"), new JSIL.GenericParameter("T6", "System.Tuple`8"), + new JSIL.GenericParameter("T7", "System.Tuple`8"), new JSIL.GenericParameter("T8", "System.Tuple`8")]), + [new JSIL.GenericParameter("T1", "System.Tuple`8"), new JSIL.GenericParameter("T2", "System.Tuple`8"), + new JSIL.GenericParameter("T3", "System.Tuple`8"), new JSIL.GenericParameter("T4", "System.Tuple`8"), + new JSIL.GenericParameter("T5", "System.Tuple`8"), new JSIL.GenericParameter("T6", "System.Tuple`8"), + new JSIL.GenericParameter("T7", "System.Tuple`8"), new JSIL.GenericParameter("T8", "System.Tuple`8")], + [new JSIL.GenericParameter("T1", "System.Tuple`8"), new JSIL.GenericParameter("T2", "System.Tuple`8"), + new JSIL.GenericParameter("T3", "System.Tuple`8"), new JSIL.GenericParameter("T4", "System.Tuple`8"), + new JSIL.GenericParameter("T5", "System.Tuple`8"), new JSIL.GenericParameter("T6", "System.Tuple`8"), + new JSIL.GenericParameter("T7", "System.Tuple`8"), new JSIL.GenericParameter("T8", "System.Tuple`8")])), + function Create$b8(type1, type2, type3, type4, type5, type6, type7, type8, item1, item2, item3, item4, item5, item6, item7, item8) { + return new (System.Tuple$b8.Of(type1, type2, type3, type4, type5, type6, type7, type8))(item1, item2, item3, item4, item5, item6, item7, item8); + }); + }); + +JSIL.ImplementExternals( + "System.Tuple`1", function($) { + function initFields(self) { + self.m_Item1 = null; + } $.Method({ Static: false, Public: true }, ".ctor", (new JSIL.MethodSignature(null, [new JSIL.GenericParameter("T1", "System.Tuple`1")], [])), @@ -61,7 +162,8 @@ JSIL.ImplementExternals( } $.Method({ Static: false, Public: true }, ".ctor", - (new JSIL.MethodSignature(null, [new JSIL.GenericParameter("T1", "System.Tuple`3"), new JSIL.GenericParameter("T2", "System.Tuple`3"), new JSIL.GenericParameter("T3", "System.Tuple`3")], [])), + (new JSIL.MethodSignature(null, [new JSIL.GenericParameter("T1", "System.Tuple`3"), new JSIL.GenericParameter("T2", "System.Tuple`3"), + new JSIL.GenericParameter("T3", "System.Tuple`3")], [])), function _ctor(item1, item2, item3) { initFields(this); @@ -90,3 +192,339 @@ JSIL.ImplementExternals( } ); +JSIL.ImplementExternals( + "System.Tuple`4", function ($) { + function initFields(self) { + self.m_Item1 = null; + self.m_Item2 = null; + self.m_Item3 = null; + self.m_Item4 = null; + } + + $.Method({ Static: false, Public: true }, ".ctor", + (new JSIL.MethodSignature(null, [new JSIL.GenericParameter("T1", "System.Tuple`4"), new JSIL.GenericParameter("T2", "System.Tuple`4"), + new JSIL.GenericParameter("T3", "System.Tuple`4"), new JSIL.GenericParameter("T4", "System.Tuple`4")], [])), + function _ctor(item1, item2, item3, item4) { + initFields(this); + + this.m_Item1 = item1; + this.m_Item2 = item2; + this.m_Item3 = item3; + this.m_Item4 = item4; + }); + + $.Method({ Static: false, Public: true }, "get_Item1", + (new JSIL.MethodSignature(new JSIL.GenericParameter("T1", "System.Tuple`4"), [], [])), + function get_Item1() { + return this.m_Item1; + }); + + $.Method({ Static: false, Public: true }, "get_Item2", + (new JSIL.MethodSignature(new JSIL.GenericParameter("T2", "System.Tuple`4"), [], [])), + function get_Item2() { + return this.m_Item2; + }); + + $.Method({ Static: false, Public: true }, "get_Item3", + (new JSIL.MethodSignature(new JSIL.GenericParameter("T3", "System.Tuple`4"), [], [])), + function get_Item3() { + return this.m_Item3; + }); + + $.Method({ Static: false, Public: true }, "get_Item4", + (new JSIL.MethodSignature(new JSIL.GenericParameter("T3", "System.Tuple`4"), [], [])), + function get_Item4() { + return this.m_Item4; + }); + } +); + +JSIL.ImplementExternals( + "System.Tuple`5", function ($) { + function initFields(self) { + self.m_Item1 = null; + self.m_Item2 = null; + self.m_Item3 = null; + self.m_Item4 = null; + self.m_Item5 = null; + } + + $.Method({ Static: false, Public: true }, ".ctor", + (new JSIL.MethodSignature(null, [new JSIL.GenericParameter("T1", "System.Tuple`5"), new JSIL.GenericParameter("T2", "System.Tuple`5"), + new JSIL.GenericParameter("T3", "System.Tuple`5"), new JSIL.GenericParameter("T4", "System.Tuple`5"), + new JSIL.GenericParameter("T5", "System.Tuple`5")], [])), + function _ctor(item1, item2, item3, item4, item5) { + initFields(this); + + this.m_Item1 = item1; + this.m_Item2 = item2; + this.m_Item3 = item3; + this.m_Item4 = item4; + this.m_Item5 = item5; + }); + + $.Method({ Static: false, Public: true }, "get_Item1", + (new JSIL.MethodSignature(new JSIL.GenericParameter("T1", "System.Tuple`5"), [], [])), + function get_Item1() { + return this.m_Item1; + }); + + $.Method({ Static: false, Public: true }, "get_Item2", + (new JSIL.MethodSignature(new JSIL.GenericParameter("T2", "System.Tuple`5"), [], [])), + function get_Item2() { + return this.m_Item2; + }); + + $.Method({ Static: false, Public: true }, "get_Item3", + (new JSIL.MethodSignature(new JSIL.GenericParameter("T3", "System.Tuple`5"), [], [])), + function get_Item3() { + return this.m_Item3; + }); + + $.Method({ Static: false, Public: true }, "get_Item4", + (new JSIL.MethodSignature(new JSIL.GenericParameter("T3", "System.Tuple`5"), [], [])), + function get_Item4() { + return this.m_Item4; + }); + + $.Method({ Static: false, Public: true }, "get_Item5", + (new JSIL.MethodSignature(new JSIL.GenericParameter("T3", "System.Tuple`5"), [], [])), + function get_Item5() { + return this.m_Item5; + }); + } +); + +JSIL.ImplementExternals( + "System.Tuple`6", function ($) { + function initFields(self) { + self.m_Item1 = null; + self.m_Item2 = null; + self.m_Item3 = null; + self.m_Item4 = null; + self.m_Item5 = null; + self.m_Item6 = null; + } + + $.Method({ Static: false, Public: true }, ".ctor", + (new JSIL.MethodSignature(null, [new JSIL.GenericParameter("T1", "System.Tuple`6"), new JSIL.GenericParameter("T2", "System.Tuple`6"), + new JSIL.GenericParameter("T3", "System.Tuple`6"), new JSIL.GenericParameter("T4", "System.Tuple`6"), + new JSIL.GenericParameter("T5", "System.Tuple`6"), new JSIL.GenericParameter("T6", "System.Tuple`6")], [])), + function _ctor(item1, item2, item3, item4, item5, item6) { + initFields(this); + + this.m_Item1 = item1; + this.m_Item2 = item2; + this.m_Item3 = item3; + this.m_Item4 = item4; + this.m_Item5 = item5; + this.m_Item6 = item6; + }); + + $.Method({ Static: false, Public: true }, "get_Item1", + (new JSIL.MethodSignature(new JSIL.GenericParameter("T1", "System.Tuple`6"), [], [])), + function get_Item1() { + return this.m_Item1; + }); + + $.Method({ Static: false, Public: true }, "get_Item2", + (new JSIL.MethodSignature(new JSIL.GenericParameter("T2", "System.Tuple`6"), [], [])), + function get_Item2() { + return this.m_Item2; + }); + + $.Method({ Static: false, Public: true }, "get_Item3", + (new JSIL.MethodSignature(new JSIL.GenericParameter("T3", "System.Tuple`6"), [], [])), + function get_Item3() { + return this.m_Item3; + }); + + $.Method({ Static: false, Public: true }, "get_Item4", + (new JSIL.MethodSignature(new JSIL.GenericParameter("T3", "System.Tuple`6"), [], [])), + function get_Item4() { + return this.m_Item4; + }); + + $.Method({ Static: false, Public: true }, "get_Item5", + (new JSIL.MethodSignature(new JSIL.GenericParameter("T3", "System.Tuple`6"), [], [])), + function get_Item5() { + return this.m_Item5; + }); + + $.Method({ Static: false, Public: true }, "get_Item6", + (new JSIL.MethodSignature(new JSIL.GenericParameter("T3", "System.Tuple`6"), [], [])), + function get_Item6() { + return this.m_Item6; + }); + } +); + +JSIL.ImplementExternals( + "System.Tuple`7", function ($) { + function initFields(self) { + self.m_Item1 = null; + self.m_Item2 = null; + self.m_Item3 = null; + self.m_Item4 = null; + self.m_Item5 = null; + self.m_Item6 = null; + self.m_Item7 = null; + } + + $.Method({ Static: false, Public: true }, ".ctor", + (new JSIL.MethodSignature(null, [new JSIL.GenericParameter("T1", "System.Tuple`7"), new JSIL.GenericParameter("T2", "System.Tuple`7"), + new JSIL.GenericParameter("T3", "System.Tuple`7"), new JSIL.GenericParameter("T4", "System.Tuple`7"), + new JSIL.GenericParameter("T5", "System.Tuple`7"), new JSIL.GenericParameter("T6", "System.Tuple`7"), + new JSIL.GenericParameter("T7", "System.Tuple`7")], [])), + function _ctor(item1, item2, item3, item4, item5, item6, item7) { + initFields(this); + + this.m_Item1 = item1; + this.m_Item2 = item2; + this.m_Item3 = item3; + this.m_Item4 = item4; + this.m_Item5 = item5; + this.m_Item6 = item6; + this.m_Item7 = item7; + }); + + $.Method({ Static: false, Public: true }, "get_Item1", + (new JSIL.MethodSignature(new JSIL.GenericParameter("T1", "System.Tuple`7"), [], [])), + function get_Item1() { + return this.m_Item1; + }); + + $.Method({ Static: false, Public: true }, "get_Item2", + (new JSIL.MethodSignature(new JSIL.GenericParameter("T2", "System.Tuple`7"), [], [])), + function get_Item2() { + return this.m_Item2; + }); + + $.Method({ Static: false, Public: true }, "get_Item3", + (new JSIL.MethodSignature(new JSIL.GenericParameter("T3", "System.Tuple`7"), [], [])), + function get_Item3() { + return this.m_Item3; + }); + + $.Method({ Static: false, Public: true }, "get_Item4", + (new JSIL.MethodSignature(new JSIL.GenericParameter("T3", "System.Tuple`7"), [], [])), + function get_Item4() { + return this.m_Item4; + }); + + $.Method({ Static: false, Public: true }, "get_Item5", + (new JSIL.MethodSignature(new JSIL.GenericParameter("T3", "System.Tuple`7"), [], [])), + function get_Item5() { + return this.m_Item5; + }); + + $.Method({ Static: false, Public: true }, "get_Item6", + (new JSIL.MethodSignature(new JSIL.GenericParameter("T3", "System.Tuple`7"), [], [])), + function get_Item6() { + return this.m_Item6; + }); + + $.Method({ Static: false, Public: true }, "get_Item7", + (new JSIL.MethodSignature(new JSIL.GenericParameter("T3", "System.Tuple`7"), [], [])), + function get_Item7() { + return this.m_Item7; + }); + } +); + +JSIL.ImplementExternals( + "System.Tuple`8", function ($) { + function initFields(self) { + self.m_Item1 = null; + self.m_Item2 = null; + self.m_Item3 = null; + self.m_Item4 = null; + self.m_Item5 = null; + self.m_Item6 = null; + self.m_Item7 = null; + self.m_Item8 = null; + } + + function constructor (that, item1, item2, item3, item4, item5, item6, item7, item8) { + initFields(that); + + that.m_Item1 = item1; + that.m_Item2 = item2; + that.m_Item3 = item3; + that.m_Item4 = item4; + that.m_Item5 = item5; + that.m_Item6 = item6; + that.m_Item7 = item7; + that.m_Item8 = item8; + } + + $.Method({ Static: false, Public: true }, ".ctor", + (new JSIL.MethodSignature(null, [new JSIL.GenericParameter("T1", "System.Tuple`8"), new JSIL.GenericParameter("T2", "System.Tuple`8"), + new JSIL.GenericParameter("T3", "System.Tuple`8"), new JSIL.GenericParameter("T4", "System.Tuple`8"), + new JSIL.GenericParameter("T5", "System.Tuple`8"), new JSIL.GenericParameter("T6", "System.Tuple`8"), + new JSIL.GenericParameter("T7", "System.Tuple`8"), new JSIL.GenericParameter("T8", "System.Tuple`8")], [])), + function _ctor(item1, item2, item3, item4, item5, item6, item7, item8) { + constructor(this, item1, item2, item3, item4, item5, item6, item7, item8); + }); + + $.Method({ Static: false, Public: true }, "get_Item1", + (new JSIL.MethodSignature(new JSIL.GenericParameter("T1", "System.Tuple`8"), [], [])), + function get_Item1() { + return this.m_Item1; + }); + + $.Method({ Static: false, Public: true }, "get_Item2", + (new JSIL.MethodSignature(new JSIL.GenericParameter("T2", "System.Tuple`8"), [], [])), + function get_Item2() { + return this.m_Item2; + }); + + $.Method({ Static: false, Public: true }, "get_Item3", + (new JSIL.MethodSignature(new JSIL.GenericParameter("T3", "System.Tuple`8"), [], [])), + function get_Item3() { + return this.m_Item3; + }); + + $.Method({ Static: false, Public: true }, "get_Item4", + (new JSIL.MethodSignature(new JSIL.GenericParameter("T4", "System.Tuple`8"), [], [])), + function get_Item4() { + return this.m_Item4; + }); + + $.Method({ Static: false, Public: true }, "get_Item5", + (new JSIL.MethodSignature(new JSIL.GenericParameter("T5", "System.Tuple`8"), [], [])), + function get_Item5() { + return this.m_Item5; + }); + + $.Method({ Static: false, Public: true }, "get_Item6", + (new JSIL.MethodSignature(new JSIL.GenericParameter("T6", "System.Tuple`8"), [], [])), + function get_Item6() { + return this.m_Item6; + }); + + $.Method({ Static: false, Public: true }, "get_Item7", + (new JSIL.MethodSignature(new JSIL.GenericParameter("T7", "System.Tuple`8"), [], [])), + function get_Item7() { + return this.m_Item7; + }); + + $.Method({ Static: false, Public: true }, "get_Rest", + (new JSIL.MethodSignature(new JSIL.GenericParameter("T8", "System.Tuple`8"), [], [])), + function get_Rest() { + return this.m_Item8; + }); + + $.Method({ Static: true, Public: true }, "Create$b8", + (new JSIL.MethodSignature($jsilcore.TypeRef("System.Tuple"), [new JSIL.GenericParameter("T1", "System.Tuple`8"), new JSIL.GenericParameter("T2", "System.Tuple`8"), + new JSIL.GenericParameter("T3", "System.Tuple`8"), new JSIL.GenericParameter("T4", "System.Tuple`8"), + new JSIL.GenericParameter("T5", "System.Tuple`8"), new JSIL.GenericParameter("T6", "System.Tuple`8"), + new JSIL.GenericParameter("T7", "System.Tuple`8"), new JSIL.GenericParameter("T8", "System.Tuple`8") + ], [])), + function Create(item1, item2, item3, item4, item5, item6, item7, item8) { + constructor(this, item1, item2, item3, item4, item5, item6, item7, item8); + return this; + }); + } +); + diff --git a/JSIL.Libraries/Includes/Bootstrap/Core/Main.js b/JSIL.Libraries/Includes/Bootstrap/Core/Main.js index ffa5ef18b..4e410477b 100644 --- a/JSIL.Libraries/Includes/Bootstrap/Core/Main.js +++ b/JSIL.Libraries/Includes/Bootstrap/Core/Main.js @@ -302,9 +302,6 @@ JSIL.MakeClass($jsilcore.TypeRef("System.Object"), "System.Tuple`7", true, ["T1" JSIL.MakeClass($jsilcore.TypeRef("System.Object"), "System.Tuple`8", true, ["T1", "T2", "T3", "T4", "T5", "T6", "T7", "T8"], function ($) { }); -JSIL.MakeClass($jsilcore.TypeRef("System.Object"), "System.Tuple`9", true, ["T1", "T2", "T3", "T4", "T5", "T6", "T7", "T8", "T9"], function ($) { -}); - JSIL.MakeInterface( "System.IAsyncResult", true, [], function ($) { $.Method({}, "get_IsCompleted", new JSIL.MethodSignature($.Boolean, [], [])); diff --git a/Tests/ComparisonTests.cs b/Tests/ComparisonTests.cs index 478fbc48b..86a7acc06 100644 --- a/Tests/ComparisonTests.cs +++ b/Tests/ComparisonTests.cs @@ -487,6 +487,22 @@ public void TypeReferences () { ); } + [Test] + [TestCaseSource("TupleSource")] + public void Tuple(object[] parameters) + { + RunSingleComparisonTestCase(parameters); + } + + protected IEnumerable TupleSource() + { + return FilenameTestSource( + new[] { + @"TestCases\Tuple.cs" + }, MakeDefaultProvider(), new AssemblyCache() + ); + } + #region Folders [Test] diff --git a/Tests/TestCases/Tuple.cs b/Tests/TestCases/Tuple.cs new file mode 100644 index 000000000..b5c8fa15c --- /dev/null +++ b/Tests/TestCases/Tuple.cs @@ -0,0 +1,118 @@ +using System; +using JSIL.Meta; + +public static class Program +{ + public static void Main(string[] args) + { + // Tuple (1) + var a = new Tuple("test"); + Console.WriteLine("{0}", a.Item1); + + var a2 = Tuple.Create("test"); + Console.WriteLine("{0}", a2.Item1); + + // Tuple (2) + var c = new Tuple(1, "testc"); + Console.WriteLine("{0} {1}", c.Item1, c.Item2); + + var c2 = Tuple.Create(1, "testc"); + Console.WriteLine("{0} {1}", c2.Item1, c2.Item2); + + // Tuple (3) + var d = new Tuple(30.3, false, 1); + Console.WriteLine("{0} {1} {2}", d.Item1, d.Item2, d.Item3); + + var d2 = Tuple.Create(30.3, false, 1); + Console.WriteLine("{0} {1} {2}", d2.Item1, d2.Item2, d2.Item3); + + // Tuple (4) + var e = new Tuple(true, false, true, false); + Console.WriteLine("{0} {1} {2} {3}", + e.Item1, e.Item2, e.Item3, e.Item4); + + var e2 = Tuple.Create(true, false, true, false); + Console.WriteLine("{0} {1} {2} {3}", + e2.Item1, e2.Item2, e2.Item3, e2.Item4); + + // Tuple (5) + var f = new Tuple("testf", 8, 8.8, true, 'f'); + Console.WriteLine("{0} {1} {2} {3} {4}", + f.Item1, f.Item2, f.Item3, f.Item4, f.Item5); + + var f2 = Tuple.Create("testf2", 8, 8.8, true, 'f'); + Console.WriteLine("{0} {1} {2} {3} {4}", + f2.Item1, f2.Item2, f2.Item3, f2.Item4, f2.Item5); + + // Tuple (6) + var g = new Tuple('g', 0, 1, 'a', 2, 3); + Console.WriteLine("{0} {1} {2} {3} {4} {5}", + g.Item1, g.Item2, g.Item3, g.Item4, g.Item5, g.Item6); + + var g2 = Tuple.Create('g', 0, 1, 'a', 2, 3); + Console.WriteLine("{0} {1} {2} {3} {4} {5}", + g2.Item1, g2.Item2, g2.Item3, g2.Item4, g2.Item5, g2.Item6); + + // Tuple (7) + var h = new Tuple(1, 2.2M, 3.3F, 1000000000000, 120, 30000, 4000000000); + Console.WriteLine("{0} {1} {2} {3} {4} {5} {6}", + h.Item1, h.Item2, h.Item3, h.Item4, h.Item5, h.Item6, h.Item7); + + var h2 = Tuple.Create(1, 2.2M, 3.3F, 1000000000000, 120, 30000, 4000000000); + Console.WriteLine("{0} {1} {2} {3} {4} {5} {6}", + h2.Item1, h2.Item2, h2.Item3, h2.Item4, h2.Item5, h2.Item6, h2.Item7); + + // Tuple (8) + var i = new Tuple>(18000000000000000000, 65000, "testi1", true, + '-', 100, 9.900009, new Tuple("testi2")); + Console.WriteLine("{0} {1} {2} {3} {4} {5} {6} {7}", + i.Item1, i.Item2, i.Item3, i.Item4, i.Item5, i.Item6, i.Item7, i.Rest.Item1); + + var item8 = Tuple.Create("testi22"); + var i2 = new Tuple>(18000000000000000000, 65000, "testi21", true, + '-', 100, 9.900009, item8); + Console.WriteLine("{0} {1} {2} {3} {4} {5} {6} {7}", + i2.Item1, i2.Item2, i2.Item3, i2.Item4, i2.Item5, i2.Item6, i2.Item7, i2.Rest.Item1); + + // Tuple (9) + var j = new Tuple>(1, 2, 3, 4, 5, 6, 7, new Tuple(8, 9)); + Console.WriteLine("{0} {1} {2} {3} {4} {5} {6} {7} {8}", + j.Item1, j.Item2, j.Item3, j.Item4, j.Item5, j.Item6, j.Item7, j.Rest.Item1, j.Rest.Item2); + + var items8_9 = Tuple.Create(8, 9); + var j2 = new Tuple>(1, 2, 3, 4, 5, 6, 7, items8_9); + Console.WriteLine("{0} {1} {2} {3} {4} {5} {6} {7} {8}", + j2.Item1, j2.Item2, j2.Item3, j2.Item4, j2.Item5, j2.Item6, j2.Item7, j2.Rest.Item1, j2.Rest.Item2); + + // Tuple (10) + var k = new Tuple>(1, 2, 3, 4, 5, 6, 7, new Tuple(8, 9, 10)); + Console.WriteLine("{0} {1} {2} {3} {4} {5} {6} {7} {8} {9}", + k.Item1, k.Item2, k.Item3, k.Item4, k.Item5, k.Item6, k.Item7, k.Rest.Item1, k.Rest.Item2, k.Rest.Item3); + + var items8_10 = Tuple.Create(8, 9, 10); + var k2 = new Tuple>(1, 2, 3, 4, 5, 6, 7, items8_10); + Console.WriteLine("{0} {1} {2} {3} {4} {5} {6} {7} {8} {9}", + k2.Item1, k2.Item2, k2.Item3, k2.Item4, k2.Item5, k2.Item6, k2.Item7, k2.Rest.Item1, k2.Rest.Item2, k2.Rest.Item3); + + // Tuple (20) + var l = new Tuple>>(1, 2, 3, 4, 5, 6, 7, + new Tuple>(8, 9, 10, 11, 12, 13, 14, + new Tuple(15, 16, 17, 18, 19, 20))); + Console.WriteLine("{0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10} {11} {12} {13} {14} {15} {16} {17} {18} {19}", + l.Item1, l.Item2, l.Item3, l.Item4, l.Item5, l.Item6, l.Item7, + l.Rest.Item1, l.Rest.Item2, l.Rest.Item3, l.Rest.Item4, l.Rest.Item5, l.Rest.Item6, l.Rest.Item7, + l.Rest.Rest.Item1, l.Rest.Rest.Item2, l.Rest.Rest.Item3, l.Rest.Rest.Item4, l.Rest.Rest.Item5, l.Rest.Rest.Item6); + + var items15_20 = Tuple.Create(15, 16, 17, 18, 19, 20); + var items8_20 = new Tuple>(8, 9, 10, 11, 12, 13, 14, items15_20); + var l2 = new Tuple>>(1, 2, 3, 4, 5, 6, 7, items8_20); + Console.WriteLine("{0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10} {11} {12} {13} {14} {15} {16} {17} {18} {19}", + l2.Item1, l2.Item2, l2.Item3, l2.Item4, l2.Item5, l2.Item6, l2.Item7, + l2.Rest.Item1, l2.Rest.Item2, l2.Rest.Item3, l2.Rest.Item4, l2.Rest.Item5, l2.Rest.Item6, l2.Rest.Item7, + l2.Rest.Rest.Item1, l2.Rest.Rest.Item2, l2.Rest.Rest.Item3, l2.Rest.Rest.Item4, l2.Rest.Rest.Item5, l2.Rest.Rest.Item6); + } +} \ No newline at end of file diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index 3a5f55f23..b381d88cb 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -294,6 +294,7 @@ +