hegel icon indicating copy to clipboard operation
hegel copied to clipboard

Add test-262 framework

Open mohsen1 opened this issue 5 years ago • 2 comments
trafficstars

I suggested this in #298 but now that I've brought in all those test cases I don't know what to do with it?!

Since Babel is parsing the code into AST, I'm not sure those untyped examples would be useful to test against. We can still sanity test the type checker with all those untyped example ASTs. However I'm not sure if that's exactly useful. Please advise.

mohsen1 avatar Aug 19 '20 15:08 mohsen1

Oh, it's a complicated question. Because test262 test the latest syntax of ECMAScript specification, and Hegel supports the same syntax as babel, the valid syntax evidence of valid program. A simple example:

const a: number = "2" + "4";

So, I don't know, actually, do we need test262 for Hegel or not(

JSMonk avatar Aug 21 '20 00:08 JSMonk

Yes, these tests are gonna be all unyped vanilla JavaScript. However there could be cases in this test suite that breaks Hegel's type checking for some reason. For instance you might not considered JavaScript like this to be able to pass type checking (event thought there is no type information):

@Decorartor()
class Foo extends Bar {
  #bar = #{what: "is this even JS"} ?? #{}
  constructor(@ArgDecorator() foo = throw new Error("No way")) {
    this.#bar ??= foo;
  }
}

So it is a good idea to keep testing the type checker against whatever is coming up to JavaScript

mohsen1 avatar Aug 21 '20 03:08 mohsen1