<commit_before>describe("Rhino 1.5R4 quirks", function() {
  it("the jasmine.isSpy({}) method would not crash the js runtime", function() {
    /*
    in Rhino 1.5R4 the code 'undefined instanceof Object' crashes the runtime
    add the following code to isSpy():
    
    if (j$.util.isUndefined(putativeSpy.and) || j$.util.isUndefined(putativeSpy.calls)) {
      return false;
    }
    
    */
    var obj = {};
    expect(j$.isSpy(obj)).toBe(false);
  });
  
  it("the jasmine.matchersUtil.equals(undefined, anObject) method would not crash the js runtime", function() {
    /*
    in Rhino 1.5R4 the code 'undefined instanceof Object' crashes the runtime
    add the following code to eq():
    
    if (j$.util.isUndefined(putativeSpy.and) || j$.util.isUndefined(putativeSpy.calls)) {
      return false;
    }
    
    */
    var obj = {};
    var result = j$.matchersUtil.equals(undefined, obj);

    expect(result).toBe(false);
  });
  
  it("the expect().toThrowError() method would not crash the js runtime", function() {
    /*
    in Rhino 1.5R4 the code 'undefined instanceof Object' crashes the runtime.
    
    Change the following code in getJasmineRequireObj().toThrowError():
    
      if (!(thrown instanceof Error)) {
    
    replace with
    
      if ((typeof thrown === 'undefined') || !(thrown instanceof Error)) {
    
    */
    var foo = function() { throw undefined; };
    expect(foo).not.toThrowError();
  });
  
  it("spyStrategy.throwError() method would not crash the js runtime", function() {
    /*
    in Rhino 1.5R4 the code 'undefined instanceof Object' crashes the runtime.
    This causes a Jasmine spec to crash:
     - core/SpyStrategySpec.js
    
    Change the following code in getJasmineRequireObj().SpyStrategy().throwError():
    
      var error = (something instanceof Error) ? something : new Error(something);
    
    replace with
    
      var error = (typeof something !== 'undefined' && something instanceof Error)
        ? something : new Error(something);
    
    */
    var spy = jasmine.createSpy('spy'),
        spyStrategy = new jasmine.SpyStrategy({getSpy: spy});

    spyStrategy.throwError();
    expect(spy).toHaveBeenCalled();
  });
  
  it("MockDate.install() method would not crash the js runtime", function() {
    /*
    in Rhino 1.5R4 the code 'undefined instanceof Object' crashes the runtime.
    This causes a Jasmine spec to crash:
     - core/QueueRunnerSpec.js
    
    Define a global function __safe_instanceof(obj, type).
    
    Change the following code in MockDate.install():
    
      if (mockDate instanceof GlobalDate) {
    
    replace with
    
      if (__safe_instanceof(mockDate, GlobalDate)) {
    
    */
    var mockDate = new j$.MockDate({ Date: Date });
    mockDate.install();
    expect(true).toBe(true);
  });
  
  xit("an empty Array object evaluates to true - fix for 'processes a complicated tree with the root specified' spec in core/TreeProcessorSpec.js", function() {
    /*
    In Rhino 1.5R4 the code below wrongly evaluates to true.
    
    var arr = [];
    var result = (!arr);
    
    
    Replace the following code in processNode():
    
      if (!node.children) {
    
    replace with
    
      if (!(typeof node.children === 'object')) {
    
    */
    var arr = [];
    var result = (!arr);
    
    expect(result).toBe(false);
  });
  
  xit("an empty Array object evaluates to true - fix for 'runs a node with no children' spec in core/TreeProcessorSpec.js", function() {
    /*
    In Rhino 1.5R4 the code below wrongly evaluates to true.
    
    var arr = [];
    var result = (!arr);
    
    
    Replace the following code in executeNode():
    
      if (node.children) {
    
    replace with
    
      if (typeof node.children === 'object') {
    
    */
    var arr = [];
    var result = (!arr);
    
    expect(result).toBe(false);
  });
  
  xit("long is a valid varibale name - fix for 'should stringify long arrays with properties properly' spec in core/PrettyPrintSpec.js", function() {
    /*
    In Rhino 1.5R4 giving the name 'long' to a variable crashes the js runtime.

    Replace the following code in PrettyPrintSpec.js:
    
      var long = [1,2,3];
    
    replace with
    
      var longArray = [1,2,3];
      
    (and also rename all occurences of the 'long' local variable)
    
    */
    // this code has to be commented out to avoid a crash
    //var long = [1,2,3];
    //expect(long.length).toEqual(3);
  });
  
  it("The 'toThrowError' matcher correctly shows the typename of the thrown Error", function() {
    /*<commit_msg>fix for EnvSpec.js/toHaveFailedExpecationsForRunnable (left: 5 failures out of 522 specs)<commit_after>describe("Rhino 1.5R4 quirks", function() {
  it("the jasmine.isSpy({}) method would not crash the js runtime", function() {
    /*
    in Rhino 1.5R4 the code 'undefined instanceof Object' crashes the runtime
    add the following code to isSpy():
    
    if (j$.util.isUndefined(putativeSpy.and) || j$.util.isUndefined(putativeSpy.calls)) {
      return false;
    }
    
    */
    var obj = {};
    expect(j$.isSpy(obj)).toBe(false);
  });
  
  it("the jasmine.matchersUtil.equals(undefined, anObject) method would not crash the js runtime", function() {
    /*
    in Rhino 1.5R4 the code 'undefined instanceof Object' crashes the runtime
    add the following code to eq():
    
    if (j$.util.isUndefined(putativeSpy.and) || j$.util.isUndefined(putativeSpy.calls)) {
      return false;
    }
    
    */
    var obj = {};
    var result = j$.matchersUtil.equals(undefined, obj);

    expect(result).toBe(false);
  });
  
  it("the expect().toThrowError() method would not crash the js runtime", function() {
    /*
    in Rhino 1.5R4 the code 'undefined instanceof Object' crashes the runtime.
    
    Change the following code in getJasmineRequireObj().toThrowError():
    
      if (!(thrown instanceof Error)) {
    
    replace with
    
      if ((typeof thrown === 'undefined') || !(thrown instanceof Error)) {
    
    */
    var foo = function() { throw undefined; };
    expect(foo).not.toThrowError();
  });
  
  it("spyStrategy.throwError() method would not crash the js runtime", function() {
    /*
    in Rhino 1.5R4 the code 'undefined instanceof Object' crashes the runtime.
    This causes a Jasmine spec to crash:
     - core/SpyStrategySpec.js
    
    Change the following code in getJasmineRequireObj().SpyStrategy().throwError():
    
      var error = (something instanceof Error) ? something : new Error(something);
    
    replace with
    
      var error = (typeof something !== 'undefined' && something instanceof Error)
        ? something : new Error(something);
    
    */
    var spy = jasmine.createSpy('spy'),
        spyStrategy = new jasmine.SpyStrategy({getSpy: spy});

    spyStrategy.throwError();
    expect(spy).toHaveBeenCalled();
  });
  
  it("MockDate.install() method would not crash the js runtime", function() {
    /*
    in Rhino 1.5R4 the code 'undefined instanceof Object' crashes the runtime.
    This causes a Jasmine spec to crash:
     - core/QueueRunnerSpec.js
    
    Define a global function __safe_instanceof(obj, type).
    
    Change the following code in MockDate.install():
    
      if (mockDate instanceof GlobalDate) {
    
    replace with
    
      if (__safe_instanceof(mockDate, GlobalDate)) {
    
    */
    var mockDate = new j$.MockDate({ Date: Date });
    mockDate.install();
    expect(true).toBe(true);
  });
  
  xit("an empty Array object evaluates to true - fix for 'processes a complicated tree with the root specified' spec in core/TreeProcessorSpec.js", function() {
    /*
    In Rhino 1.5R4 the code below wrongly evaluates to true.
    
    var arr = [];
    var result = (!arr);
    
    
    Replace the following code in processNode():
    
      if (!node.children) {
    
    replace with
    
      if (!(typeof node.children === 'object')) {
    
    */
    var arr = [];
    var result = (!arr);
    
    expect(result).toBe(false);
  });
  
  xit("an empty Array object evaluates to true - fix for 'runs a node with no children' spec in core/TreeProcessorSpec.js", function() {
    /*
    In Rhino 1.5R4 the code below wrongly evaluates to true.
    
    var arr = [];
    var result = (!arr);
    
    
    Replace the following code in executeNode():
    
      if (node.children) {
    
    replace with
    
      if (typeof node.children === 'object') {
    
    */
    var arr = [];
    var result = (!arr);
    
    expect(result).toBe(false);
  });
  
  xit("long is a valid varibale name - fix for 'should stringify long arrays with properties properly' spec in core/PrettyPrintSpec.js", function() {
    /*
    In Rhino 1.5R4 giving the name 'long' to a variable crashes the js runtime.

    Replace the following code in PrettyPrintSpec.js:
    
      var long = [1,2,3];
    
    replace with
    
      var longArray = [1,2,3];
      
    (and also rename all occurences of the 'long' local variable)
    
    */
    // this code has to be commented out to avoid a crash
    //var long = [1,2,3];
    //expect(long.length).toEqual(3);
  });
  
  it("expected failure test handled RegExps correctly", function() {
    /*
    In ServiceNow Rhino 1.5R4 regexp literals have the type SNRegExp, not RegExp

    Replace the following code in EnvSpec.js:
    
      if (Object.prototype.toString.call(expectedFailure) === '[object RegExp]') {
    
    replace with
    
      if (expectedFailure instanceof RegExp) {
    
    */
    var re = /foo/;
    expect(re instanceof RegExp).toBeTruthy();
    
    var type = Object.prototype.toString.call(re);
    expect(type).toBe('[object SNRegExp]');
  });
  
  it("The 'toThrowError' matcher correctly shows the typename of the thrown Error", function() {
    /*
{'fraction_non_alphanumeric': 0.11574450772986168, 'fraction_numerical': 0.00823840520748576, 'mean_word_length': 2.554953000723066, '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': '779960', 'n_tokens_mistral': 2999, 'n_tokens_neox': 2914, 'n_words': 935}