Skip to content

Possible ES6 class support? #9

@ifell

Description

@ifell

I have been creating my Fitnesse Functions with the following syntax in JavaScript.

| import |
| logic |

|DT:logic|
|a|b|and?|
|0|0|0|
|0|1|0|
|1|0|0|
|1|1|1|

and in a JS file called logic.js

'use strict';

function logic() {}

logic.prototype.setA = function(a) {
  this.a = a;
};

logic.prototype.setB = function(b) {
  this.b = b;
};

logic.prototype.and = function() {
  return this.a & this.b;
};

module.exports.logic = logic;

I have been wanting to use ES6 classes for my fixures. Below is an attempt...

'use strict';

class logic {
  constructor() {
    //
  }

  setA(a) {
    this.a = a;
  }

  setB(b) {
    this.b = b;
  }

  and() {
    return this.a & this.b;
  }
}

module.exports.logic = logic;

However, I get the following errors

screenshot from 2016-02-02 09-06-26

I am a little confused because the 'class' keyword is just syntactic sugar. So, perhaps my syntax is wrong.

Has anyone been able to get ES6 classes to work? If so, what syntax are you using?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions