<commit_before>describe("interpreter.symbol(makeInstruction)" + 
".call(thisBinding, code)", function() {
  var CodePointer;
  var interpreter;

  beforeEach(function() {
    interpreter = Interpreter();
    interpreter.CodePointer = jasmine.createSpy("interpreter.CodePointer").and
    .returnValue(StubCodePointer(""));
    CodePointer = jasmine.createSpy("CodePointer").and
    .returnValue(StubCodePointer(""));
  });
  
  it("calls CodePointer with code", function() {
    interpreter.method = interpreter.symbol(function() {
      return function() {};
    });
    
    interpreter.method("code");
    expect(interpreter.CodePointer).toHaveBeenCalledWith("code");
  });
  
  it("calls makeInstruction with the result of " + 
  "CodePointer(code)", function() {
    var codePointer = {getUnparsed() {return "";}};
    interpreter.CodePointer = function() {
      return codePointer;
    };
    
    var makeInstruction = jasmine.createSpy("makeInstruction").and
    .returnValue(function(){});
    interpreter.method = interpreter.symbol(makeInstruction);
    interpreter.method();
    expect(makeInstruction)
    .toHaveBeenCalledWith(codePointer);
  });
  
  it("throws an error if !makeInstruction(codePointer)", function() {
    var makeInstruction = function() {
      return null;
    };
    
    interpreter.method = interpreter.symbol(makeInstruction);
    
    expect(interpreter.method.bind(interpreter)).toThrow();
  });
  
  it("throws an error if codePointer.getUnparsed() !== ''", function() {
    interpreter.CodePointer = function() {
      return {
        getUnparsed() {
          return "trailing code";
        },
      };
    };
    
    interpreter.method = interpreter.symbol(function() {
      return function() {};
    });
    
    expect(interpreter.method.bind(interpreter)).toThrow();
  });
  
  it("calls the result of makeInstruction and returns the result", function() {
    var instruction = jasmine.createSpy("instruction").and
    .returnValue("result");
    var makeInstruction = function() {
      return instruction;
    };
    
    interpreter.method = interpreter.symbol(makeInstruction);
    
    expect(interpreter.method()).toEqual("result");
    expect(instruction).toHaveBeenCalled();
  });
  
  it("calls the result of makeInstruction with this bound to thisBinding", 
  function() {
    var thisBinding = {};
    var stolenThis;
    var thisThief = function() {
      stolenThis = this;
    };
    
    var makeInstruction = function() {
      return thisThief;
    };
    
    thisBinding.method = interpreter.symbol(makeInstruction);
    
    thisBinding.method();
    expect(stolenThis).toBe(thisBinding);
  });
  
});<commit_msg>makeInstruction => instructionMaker because function not method.<commit_after>describe("interpreter.symbol(instructionMaker)" + 
".call(thisBinding, code)", function() {
  var CodePointer;
  var interpreter;

  beforeEach(function() {
    interpreter = Interpreter();
    interpreter.CodePointer = jasmine.createSpy("interpreter.CodePointer").and
    .returnValue(StubCodePointer(""));
    CodePointer = jasmine.createSpy("CodePointer").and
    .returnValue(StubCodePointer(""));
  });
  
  it("calls CodePointer with code", function() {
    interpreter.method = interpreter.symbol(function() {
      return function() {};
    });
    
    interpreter.method("code");
    expect(interpreter.CodePointer).toHaveBeenCalledWith("code");
  });
  
  it("calls instructionMaker with the result of " + 
  "CodePointer(code)", function() {
    var codePointer = {getUnparsed() {return "";}};
    interpreter.CodePointer = function() {
      return codePointer;
    };
    
    var instructionMaker = jasmine.createSpy("instructionMaker").and
    .returnValue(function(){});
    interpreter.method = interpreter.symbol(instructionMaker);
    interpreter.method();
    expect(instructionMaker)
    .toHaveBeenCalledWith(codePointer);
  });
  
  it("throws an error if !instructionMaker(codePointer)", function() {
    var instructionMaker = function() {
      return null;
    };
    
    interpreter.method = interpreter.symbol(instructionMaker);
    
    expect(interpreter.method.bind(interpreter)).toThrow();
  });
  
  it("throws an error if codePointer.getUnparsed() !== ''", function() {
    interpreter.CodePointer = function() {
      return {
        getUnparsed() {
          return "trailing code";
        },
      };
    };
    
    interpreter.method = interpreter.symbol(function() {
      return function() {};
    });
    
    expect(interpreter.method.bind(interpreter)).toThrow();
  });
  
  it("calls the result of instructionMaker and returns the result", function() {
    var instruction = jasmine.createSpy("instruction").and
    .returnValue("result");
    var instructionMaker = function() {
      return instruction;
    };
    
    interpreter.method = interpreter.symbol(instructionMaker);
    
    expect(interpreter.method()).toEqual("result");
    expect(instruction).toHaveBeenCalled();
  });
  
  it("calls the result of instructionMaker with this bound to thisBinding", 
  function() {
    var thisBinding = {};
    var stolenThis;
    var thisThief = function() {
      stolenThis = this;
    };
    
    var instructionMaker = function() {
      return thisThief;
    };
    
    thisBinding.method = interpreter.symbol(instructionMaker);
    
    thisBinding.method();
    expect(stolenThis).toBe(thisBinding);
  });
  
});
{'fraction_non_alphanumeric': 0.13631346578366446, 'fraction_numerical': 0.0, 'mean_word_length': 3.384677419354839, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '4999795', 'n_tokens_mistral': 1541, 'n_tokens_neox': 1582, 'n_words': 279}