Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class support #816

Merged
merged 30 commits into from
Jan 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
7e35f7a
enable class tests
lahma Jun 22, 2020
346c1c2
first steps
lahma Jun 22, 2020
0173395
ignore things not supported yet
lahma Dec 12, 2020
e0a2070
start super support, refactor
lahma Dec 13, 2020
58319d5
work work
lahma Dec 19, 2020
3438414
fix GlobalDeclarationInstantiation to check let override for varNames
lahma Dec 19, 2020
eb15971
bring closer to the spec
lahma Dec 20, 2020
f848268
tweaks
lahma Dec 20, 2020
c43d488
cleanup, better exceptions and errors, refactor
lahma Jan 1, 2021
41e302c
inherit class constructor from script function instance
lahma Jan 1, 2021
cd5d4cc
we don't need separate ArrowFunctionInstance
lahma Jan 1, 2021
455455c
fix Construct
lahma Jan 1, 2021
4263c44
refactor, get closer to spec
lahma Jan 1, 2021
c162375
fix some logic
lahma Jan 1, 2021
ea86660
fix fix fix
lahma Jan 1, 2021
24bcd97
generate missing constructor AST only once
lahma Jan 2, 2021
8d44bbe
fix constructors to use OrdinaryCreateFromConstructor
lahma Jan 2, 2021
d90d200
rely on MakeConstructor instead of always initializing function to ha…
lahma Jan 2, 2021
338f770
cleanup
lahma Jan 2, 2021
2a94e33
fix JintClassExpression
lahma Jan 2, 2021
d3c4f21
account for array iterator being configurable
lahma Jan 2, 2021
ad82593
cleanup
lahma Jan 2, 2021
ff9c704
fix some basic issues
lahma Jul 6, 2020
dab7f67
fix some iterator handling issues
lahma Aug 9, 2020
ce717f5
fix new expression logic ordering
lahma Aug 9, 2020
18cfa04
some object constructor and proxy fixes
lahma Aug 9, 2020
8c58b6e
fix
lahma Jan 2, 2021
87705fa
tweak IsConstructor logic
lahma Jan 2, 2021
745fcc7
fix bind issues
lahma Jan 2, 2021
d8d097b
tick the box and remove obsolete sub-classable built-int (classes han…
lahma Jan 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions Jint.Tests.Test262/Language/Expressions/ClassTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Xunit;

namespace Jint.Tests.Test262.Language.Expressions
{
public class ClassTests : Test262Test
{
[Theory(DisplayName = "language\\expressions\\class")]
[MemberData(nameof(SourceFiles), "language\\expressions\\class", false)]
[MemberData(nameof(SourceFiles), "language\\expressions\\class", true, Skip = "Skipped")]
protected void Class(SourceFile sourceFile)
{
RunTestInternal(sourceFile);
}
}
}
15 changes: 15 additions & 0 deletions Jint.Tests.Test262/Language/Statements/ClassTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Xunit;

namespace Jint.Tests.Test262.Language.Statements
{
public class ClassTests : Test262Test
{
[Theory(DisplayName = "language\\statements\\class")]
[MemberData(nameof(SourceFiles), "language\\statements\\class", false)]
[MemberData(nameof(SourceFiles), "language\\statements\\class", true, Skip = "Skipped")]
protected void Class(SourceFile sourceFile)
{
RunTestInternal(sourceFile);
}
}
}
69 changes: 60 additions & 9 deletions Jint.Tests.Test262/Test262Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ protected void RunTestCode(string code, bool strict)
.Strict(strict)
);

engine.Execute(Sources["sta.js"]);
engine.Execute(Sources["assert.js"]);
engine.Execute(Sources["sta.js"], CreateParserOptions("sta.js"));
engine.Execute(Sources["assert.js"], CreateParserOptions("assert.js"));
engine.SetValue("print", new ClrFunctionInstance(engine, "print", (thisObj, args) => TypeConverter.ToString(args.At(0))));

var o = engine.Object.Construct(Arguments.Empty);
Expand All @@ -112,13 +112,13 @@ protected void RunTestCode(string code, bool strict)
var files = includes.Groups[1].Captures[0].Value.Split(',');
foreach (var file in files)
{
engine.Execute(Sources[file.Trim()]);
engine.Execute(Sources[file.Trim()], CreateParserOptions(file.Trim()));
}
}

if (code.IndexOf("propertyHelper.js", StringComparison.OrdinalIgnoreCase) != -1)
{
engine.Execute(Sources["propertyHelper.js"]);
engine.Execute(Sources["propertyHelper.js"], CreateParserOptions("propertyHelper.js"));
}

string lastError = null;
Expand Down Expand Up @@ -210,10 +210,6 @@ public static IEnumerable<object[]> SourceFiles(string pathPrefix, bool skipped)
skip = true;
reason = "tail-calls not implemented";
break;
case "class":
skip = true;
reason = "class keyword not implemented";
break;
case "BigInt":
skip = true;
reason = "BigInt not implemented";
Expand All @@ -230,6 +226,11 @@ public static IEnumerable<object[]> SourceFiles(string pathPrefix, bool skipped)
skip = true;
reason = "async not implemented";
break;
case "class-fields-private":
case "class-fields-public":
skip = true;
reason = "private/public class fields not implemented in esprima";
lahma marked this conversation as resolved.
Show resolved Hide resolved
break;
case "new.target":
skip = true;
reason = "MetaProperty not implemented";
Expand Down Expand Up @@ -290,6 +291,48 @@ public static IEnumerable<object[]> SourceFiles(string pathPrefix, bool skipped)
reason = "Unicode support and its special cases need more work";
}

if (name.StartsWith("language/statements/class/subclass/builtin-objects/Promise"))
{
skip = true;
reason = "Promise not implemented";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WAT?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small PR and you can enable this... Just need to have the constructor logic use correct methods, like I mentioned 😉

}

if (name.StartsWith("language/statements/class/subclass/builtin-objects/TypedArray"))
{
skip = true;
reason = "TypedArray not implemented";
}

if (name.StartsWith("language/statements/class/subclass/builtin-objects/WeakMap"))
{
skip = true;
reason = "WeakMap not implemented";
}

if (name.StartsWith("language/statements/class/subclass/builtin-objects/WeakSet"))
{
skip = true;
reason = "WeakSet not implemented";
}

if (name.StartsWith("language/statements/class/subclass/builtin-objects/ArrayBuffer/"))
{
skip = true;
reason = "ArrayBuffer not implemented";
}

if (name.StartsWith("language/statements/class/subclass/builtin-objects/DataView"))
{
skip = true;
reason = "DataView not implemented";
}

if (name.StartsWith("language/statements/class/subclass/builtins.js"))
{
skip = true;
reason = "Uint8Array not implemented";
}

if (name.StartsWith("built-ins/RegExp/CharacterClassEscapes/"))
{
skip = true;
Expand Down Expand Up @@ -322,8 +365,16 @@ public static IEnumerable<object[]> SourceFiles(string pathPrefix, bool skipped)

return results;
}

private static ParserOptions CreateParserOptions(string fileName) =>
new ParserOptions(fileName)
{
AdaptRegexp = true,
Tolerant = true,
Loc = true
};
}

public class SourceFile : IXunitSerializable
{
public SourceFile()
Expand Down