<commit_before>Studio = require('../../compiled/core/studio');
clone = require('../../compiled/core/util/clone');

describe("A message", function() {
  var SENDER_ID = 'sender_message',
    RECEIVER_ID = 'receiver_message';
  var sender = new Studio.Actor({
    id: SENDER_ID,
    process: function(message, headers) {}
  });
  new Studio.Actor({
    id: RECEIVER_ID,
    process: function(message, headers) {
      message.hello = 'copy';
      message.inner.content = 'new';
      delete message.toDelete;
      return message;
    }
  });
  it("should be immutable", function(done) {
    var message = {
      hello: 'hello',
      inner: {
        content: 'content'
      },
      toDelete: 'delete'
    };
    sender.send(RECEIVER_ID, message).then(function(result) {
      expect(result.hello).toBeDefined();
      expect(result.hello).toBe(message.hello);
      expect(result.inner).toBeDefined();
      expect(result.inner.content).toBe(message.inner.content);
      expect(result.toDelete).toBeDefined();
      expect(message.toDelete).toBeDefined();
      done();
    });
  });
  function MyModel(options){
    options = options || {};
    this.id=+options.id;
  }
  it("should be clonable",function(){
    var message = {
      hello: 'hello',
      inner: {
        content: 'content',
        num:new MyModel({id:33}),
        nul:null
      },
      toDelete: 'delete',
      num:1
    };
    var cloned = clone(message);
    expect(2).toBe(clone(2));
    expect(message.hello).toBe(cloned.hello);
    expect(message.inner.content).toBe(cloned.inner.content);
    expect(message.inner.num.id).toBe(cloned.inner.num.id);
    expect(message.inner.nul).toBe(cloned.inner.nul);
    expect(message.toDelete).toBe(cloned.toDelete);
    expect(message.num).toBe(cloned.num);
  });
});
<commit_msg>tests<commit_after>Studio = require('../../compiled/core/studio');
clone = require('../../compiled/core/util/clone');

describe("A message", function() {
  var SENDER_ID = 'sender_message',
    RECEIVER_ID = 'receiver_message';
  var sender = new Studio.Actor({
    id: SENDER_ID,
    process: function(message, headers) {}
  });
  new Studio.Actor({
    id: RECEIVER_ID,
    process: function(message, headers) {
      message.hello = 'copy';
      message.inner.content = 'new';
      delete message.toDelete;
      return message;
    }
  });
  it("should be immutable", function(done) {
    var message = {
      hello: 'hello',
      inner: {
        content: 'content'
      },
      toDelete: 'delete'
    };
    sender.send(RECEIVER_ID, message).then(function(result) {
      expect(result.hello).toBeDefined();
      expect(result.hello).toBe(message.hello);
      expect(result.inner).toBeDefined();
      expect(result.inner.content).toBe(message.inner.content);
      expect(result.toDelete).toBeDefined();
      expect(message.toDelete).toBeDefined();
      done();
    });
  });
  function MyModel(options){
    options = options || {};
    this.id=+options.id;
  }
  it("should be clonable",function(){
    var message = {
      hello: 'hello',
      inner: {
        content: 'content',
        num:new MyModel({id:33}),
        nul:null
      },
      toDelete: 'delete',
      num:1
    };
    var cloned = clone(message);
    expect(2).toBe(clone(2));
    cloned.hello='dasdsa';
    cloned.inner.nul=3;
    cloned.inner.num.id=10;
    expect(message.hello).toBe(cloned.hello);
    expect(message.inner.content).toBe(cloned.inner.content);
    expect(message.inner.num.id).toBe(cloned.inner.num.id);
    expect(message.inner.nul).toBe(cloned.inner.nul);
    expect(message.toDelete).toBe(cloned.toDelete);
    expect(message.num).toBe(cloned.num);
  });
});

{'fraction_non_alphanumeric': 0.16897582178755774, 'fraction_numerical': 0.0035316490084216245, 'mean_word_length': 2.942184154175589, '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': '1529533', 'n_tokens_mistral': 1212, 'n_tokens_neox': 1192, 'n_words': 181}