<commit_before>
var corePromise = GLOBAL.loadCoreTo('core/mm.js');
var beforeEachTest = function(callback) {
  return beforeEach(function(done) {
    corePromise.then(function() {
      callback();
      done();
    });
  });
};


describe('Untyped Property', function() {
  var t;

  beforeEachTest(function() {
    // NOTE: globals are not defined until corePromise is run by beforeEachTest()
    foam.CLASS({
      name: 'PropTest',
      properties: [
        {
          name: 'b'
        },
      ]
    });
    t = /*X.*/PropTest.create({});
  });
  afterEach(function() {
    t = null;
  });

  it('creates a Property by default', function() {
    expect(PropTest.B.cls_.name).toEqual('Property');
  });

});


describe('AbstractClass.getAxioms', function() {

  beforeEachTest(function() {
  });
  afterEach(function() {
  });

  it('coverage', function() {
    /*X.*/Property.getAxioms();
    /*X.*/Property.getAxioms(); // previous results cached
  });

});

describe('AbstractClass.toString', function() {

  beforeEachTest(function() {
  });
  afterEach(function() {
  });

  it('coverage', function() {
    /*X.*/Property.toString();
  });

});


describe('Property Getter and Setter', function() {
  var t;
  var p;

  beforeEachTest(function() {
    // NOTE: globals are not defined until corePromise is run by beforeEachTest()
    foam.CLASS({
      name: 'GetterSetterTest',
      properties: [
        {
          name: 'b',
          adapt: function(old, nu) {
            p += 'adapt'+nu;
            return nu;
          },
          preSet: function(old, nu) {
            p += 'preSet'+nu;
            return nu;
          },
          postSet: function(old, nu) {
            p += 'postSet'+nu;
          },
        },
        {
          name: 'a',
          getter: function()  { return this.b; },
          setter: function(a) { this.b = a; }
        }
      ]
    });
    t = /*X.*/GetterSetterTest.create({});
    p = "";
  });
  afterEach(function() {
    t = null;
    p = "";
  });

  it('sets a value and gets it back', function() {
    t.a = 42;
    expect(t.a).toEqual(42);
  });
  it('sets values repeatedly and gets them back', function() {
    t.a = 42;
    expect(t.a).toEqual(42);
    t.a = 'hello';
    expect(t.a).toEqual('hello');
    t.a = -3;
    expect(t.a).toEqual(-3);
  });
  it('gets undefined when not yet set', function() {
    expect(t.a).toBeUndefined();
  });
  it('Hits defined adapt/pre/postSet', function() {
    t.b = 4;
    expect(p).toEqual('adapt4preSet4postSet4');
  });<commit_msg>Add test to verify custom setter/getter works, as it was broken.<commit_after>
var corePromise = GLOBAL.loadCoreTo('core/mm.js');
var beforeEachTest = function(callback) {
  return beforeEach(function(done) {
    corePromise.then(function() {
      callback();
      done();
    });
  });
};


describe('Untyped Property', function() {
  var t;

  beforeEachTest(function() {
    // NOTE: globals are not defined until corePromise is run by beforeEachTest()
    foam.CLASS({
      name: 'PropTest',
      properties: [
        {
          name: 'b'
        },
      ]
    });
    t = /*X.*/PropTest.create({});
  });
  afterEach(function() {
    t = null;
  });

  it('creates a Property by default', function() {
    expect(PropTest.B.cls_.name).toEqual('Property');
  });

});


describe('AbstractClass.getAxioms', function() {

  beforeEachTest(function() {
  });
  afterEach(function() {
  });

  it('coverage', function() {
    /*X.*/Property.getAxioms();
    /*X.*/Property.getAxioms(); // previous results cached
  });

});

describe('AbstractClass.toString', function() {

  beforeEachTest(function() {
  });
  afterEach(function() {
  });

  it('coverage', function() {
    /*X.*/Property.toString();
  });

});


describe('Property Getter and Setter', function() {
  var t;
  var p;

  beforeEachTest(function() {
    // NOTE: globals are not defined until corePromise is run by beforeEachTest()
    foam.CLASS({
      name: 'GetterSetterTest',
      properties: [
        {
          name: 'b',
          adapt: function(old, nu) {
            p += 'adapt'+nu;
            return nu;
          },
          preSet: function(old, nu) {
            p += 'preSet'+nu;
            return nu;
          },
          postSet: function(old, nu) {
            p += 'postSet'+nu;
          },
        },
        {
          name: 'a',
          getter: function()  { return this.b; },
          setter: function(a) { this.b = a; }
        }
      ]
    });
    t = /*X.*/GetterSetterTest.create({});
    p = "";
  });
  afterEach(function() {
    t = null;
    p = "";
  });

  it('sets a value and gets it back', function() {
    t.a = 42;
    expect(t.a).toEqual(42);
  });
  it('sets a value via custom setter', function() {
    t.a = 42;
    expect(t.b).toEqual(42);
  })
  it('reads a value via custom getter', function() {
    t.b = 42;
    expect(t.a).toEqual(42);
  })
  it('sets values repeatedly and gets them back', function() {
    t.a = 42;
    expect(t.a).toEqual(42);
    t.a = 'hello';
    expect(t.a).toEqual('hello');
    t.a = -3;
    expect(t.a).toEqual(-3);
  });
  it('gets undefined when not yet set', function() {
    expect(t.a).toBeUndefined();
  });
  it('Hits defined adapt/pre/postSet', function() {
    t.b = 4;
    expect(p).toEqual('adapt4preSet4postSet4');
  });
{'fraction_non_alphanumeric': 0.18026956196181207, 'fraction_numerical': 0.0067390490453013855, 'mean_word_length': 2.2480243161094227, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6674792', 'n_tokens_mistral': 1815, 'n_tokens_neox': 1777, 'n_words': 372}