1
0
Fork 0
Commit Graph

22 Commits (7dfb288ba74ac06a1ee9b2a0e661b5da016ab3d7)

Author SHA1 Message Date
Mike Gerwitz d3f1f0dee2 Add test to ensure multiple constructors cannot be defined 2015-09-16 00:02:02 -04:00
Mike Gerwitz ba2605f836 Alias `constructor` member to `__construct`
This allows ease.js classes to mimic the structure of ES6 classes, which use
`constructor` to denote the constructor.  This patch simply aliases it to
`__construct`, which ease.js handles as it would normally.

To that note, since the ES6 `class` keyword is purely syntatic sugar around
the prototype model, there is not much benefit to using it over ease.js if
benefits of ease.js are still desired, since the member definition syntax is
a feature of object literals:

```
// ease.js using ES6
let Person = Class(
{
    _name: '',

    // note that __construct still works as well
    constructor( name ) {
      this._name = ''+name;
    },

    sayHi() {
      return "Hi, I'm " + this.getName();
    },

    // keywords still work as expected
    'protected getName'() {
      return this._name;
    }
} );

// ES6 using `class` keyword
class Person
{
    // note that ES6 will _not_ make this private
    _name: '',

    constructor( name ) {
      this._name = ''+name;
    },

    sayHi() {
      return "Hi, I'm " + this.getName();
    }

    // keywords unsupported (you'd have to use Symbols)
    getName() {
      return this._name;
    }
}

// ES3/5 ease.js
var Person = Class(
{
    _name: '',

    __construct: function( name ) {
      this._name = ''+name;
    },

    sayHi: function() {
      return "Hi, I'm " + this._name;
    },

    'protected getName': function() {
      return this._name;
    }
} );
```

As you can see, the only change between writing ES6-style method definitions
is the syntax; all keywords and other features continue to work as expected.
2015-09-16 00:02:00 -04:00
Mike Gerwitz db3ade378a
[copyright] Copyright update 2015-05-28 01:01:51 -04:00
Mike Gerwitz 69e9828beb Object class masquerading 2015-05-27 23:23:47 -04:00
Mike Gerwitz 8b8a08b7dc Subtypes of prototype subtypes now work correctly 2014-04-29 10:47:12 -04:00
Mike Gerwitz fa177922b4 Class#asPrototype support
This is an interop feature: allows using ease.js classes as part of a
prototype chain.
2014-04-29 02:03:51 -04:00
Mike Gerwitz 1fe9aa2c0c Test case to protect agaist retval regressions when extending prototypes 2014-04-29 02:03:51 -04:00
Mike Gerwitz 34d84412e1 Prototype supertype property proxy fix
This was a nasty bug that I discovered when working on a project at work
probably over a year ago. I had worked around it, but ease.js was largely
stalled at the time; with it revitalized by GNU, it's finally getting fixed.

See test case comments for more information.
2014-04-29 02:03:40 -04:00
Mike Gerwitz 7f3e7fba35 Overriding vanilla prototype methods no longer errors
This is something that I've been aware of for quite some time, but never got
around to fixing; ease.js had stalled until it was revitalized by becoming a
GNU project.
2014-04-28 15:09:52 -04:00
Mike Gerwitz 82a02c0081 [copyright] Copyright assignment to the FSF
Thanks to Donald Robertson III for his help and guidance during this
process.
2014-04-09 19:05:07 -04:00
Mike Gerwitz 513bd1a733 Added test case for visibility escalation internally
For completeness, since this is how I originally observed the issue fixed in
the previous commit.
2014-03-15 21:16:26 -04:00
Mike Gerwitz 7f8d265877
Corrected override of super-super methods
More generally, this was a problem with not recursing on *all* of the
visibility objects of the supertype's supertype; the public visibility
object was implicitly recursed upon through JavaScript's natural prototype
chain, so this only manifested itself with protected members.
2014-02-24 23:03:04 -05:00
Mike Gerwitz 89f00e0cdd [copyright] Copyright update 2014-01-20 22:55:29 -05:00
Mike Gerwitz aad013bd87 Moved test-class-abstract into suite as Class/AbstractTest 2014-01-20 22:14:42 -05:00
Mike Gerwitz 37d66b375d Moved test-class-gettersetter into suite as Class/GetterSetterTest 2014-01-20 22:14:42 -05:00
Mike Gerwitz 0b1bf31b8d Moved test-class-name into test suite as Class/NameTest 2014-01-20 22:14:42 -05:00
Mike Gerwitz ee886f2d37 Moved test-class-constructor into suite as Class/ConstructorTest
Also removed assertions that are performed elsewhere.

We broke onto the fifth line in the suite ;)
2014-01-20 22:14:42 -05:00
Mike Gerwitz d0bc34a7f3 Moved test-class-parent into test suite as Class/ParentTest 2014-01-20 22:14:42 -05:00
Mike Gerwitz 2b5bcaf02d Moved test-class-extend into suite as Class/{Extend,InstanceSafety}Test
More refactoring to come for ExtendTest at some point
2014-01-20 22:14:42 -05:00
Mike Gerwitz ae367964a3 Moved test-class into suite as Class/GeneralTest
This guy had some old tests indeed; it wasn't even in the second incarnation
of the test formats! Flasback to the beginning of ease.js.
2014-01-20 22:14:42 -05:00
Mike Gerwitz d8243707ad Moved test-class-visibility into suite as Class/VisibilityTest 2014-01-20 22:14:41 -05:00
Mike Gerwitz 85a201558d Moved ClassImplementTest into Class subdirectory in preparation for other test cases 2014-01-20 22:14:41 -05:00