<commit_before>/*
 Copyright 2016 - 2016 by <NAME>

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 */
module.exports = (function() {
  "use strict";

  var util = require("./../_private/util");

  var displayNamePrefix = "contract function ";

  /**
   * Abstract definition of a function Contract.
   *
   * A Contract consists of an optional array of preconditions, an optional array of nominal postconditions,
   * and an optional array of exceptional preconditions.
   *
   * The conditions are functions whose result is interpreted as a booleany value.
   * The conditions are called with the same `this` and arguments as the functional call in which they are
   * verified. When verifying nominal postconditions, the result of the function call is added as extra argument.
   * When verifying exceptional postconditions, the exception thrown by the function call is added as extra argument.
   * Finally, a version of the contract function bound to `this` is supplied as final parameter when verifying
   * nominal and exceptional postconditions. This function reference can be used in contracts that use recursion.
   *
   * Furthermore, an instance contains a `location` property, which is a line of text
   * that refers to the source code where the contract was created.
   */
  function Contract(pre, post, exception) {
    function abstract() {throw new Error(Contract.abstractMessage);}

    var location = util.firstLocationOutsideLibrary();
    util.setAndFreezeProperty(this, "_pre", pre ? pre.slice() : []);
    util.setAndFreezeProperty(this, "_post", post ? post.slice() : []);
    util.setAndFreezeProperty(this, "_exception", exception ? exception.slice() : []);
    util.setAndFreezeProperty(this, "location", location);
    util.setAndFreezeProperty(this, "abstract", abstract);
    // MUDO cannot freeze, to make extension (ImplementableContract) possible
    //Object.freeze(this);
    // MUDO requires this to be frozen
    //Contract.bless(abstract, this, abstract, location);
  }

  Contract.prototype = {
    constructor: Contract,
    _pre: null,
    _post: null,
    _exception: null,
    isImplementedBy: function(f) {
      return Contract.isAContractFunction(f) && f.contract === this;
    }
  };<commit_msg>No! The clue is a contract must not be frozen. Its properties must be, and that is so. And that is good enough. You can add any shit you like.<commit_after>/*
 Copyright 2016 - 2016 by <NAME>

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 */
module.exports = (function() {
  "use strict";

  var util = require("./../_private/util");

  var displayNamePrefix = "contract function ";

  /**
   * Abstract definition of a function Contract.
   *
   * A Contract consists of an optional array of preconditions, an optional array of nominal postconditions,
   * and an optional array of exceptional preconditions.
   *
   * The conditions are functions whose result is interpreted as a booleany value.
   * The conditions are called with the same `this` and arguments as the functional call in which they are
   * verified. When verifying nominal postconditions, the result of the function call is added as extra argument.
   * When verifying exceptional postconditions, the exception thrown by the function call is added as extra argument.
   * Finally, a version of the contract function bound to `this` is supplied as final parameter when verifying
   * nominal and exceptional postconditions. This function reference can be used in contracts that use recursion.
   *
   * Furthermore, an instance contains a `location` property, which is a line of text
   * that refers to the source code where the contract was created.
   */
  function Contract(pre, post, exception) {
    function abstract() {throw new Error(Contract.abstractMessage);}

    var location = util.firstLocationOutsideLibrary();
    util.setAndFreezeProperty(this, "_pre", pre ? pre.slice() : []);
    util.setAndFreezeProperty(this, "_post", post ? post.slice() : []);
    util.setAndFreezeProperty(this, "_exception", exception ? exception.slice() : []);
    util.setAndFreezeProperty(this, "location", location);
    util.setAndFreezeProperty(this, "abstract", abstract);
    // MUDO cannot freeze, to make extension (ImplementableContract) possible
    //Object.freeze(this);
    // MUDO requires this to be frozen
    //Contract.bless(abstract, this, abstract, location);
    // MUDO a Contract must NOT be frozen for it to have a sensible implementation: its properties pre, post, exception, location cannot be changed after creation anyway! Remove this requirement, invariant, postcondition in tests.
  }

  Contract.prototype = {
    constructor: Contract,
    _pre: null,
    _post: null,
    _exception: null,
    isImplementedBy: function(f) {
      return Contract.isAContractFunction(f) && f.contract === this;
    }
  };
{'fraction_non_alphanumeric': 0.0819277108433735, 'fraction_numerical': 0.004130808950086058, 'mean_word_length': 3.8790931989924435, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 1, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '870728', 'n_tokens_mistral': 1480, 'n_tokens_neox': 1433, 'n_words': 675}