<commit_before>module("DeepModel");

function create() {
    var model = new Backbone.DeepModel({
        id: 123,
        user: {
            type: 'Spy',
            name: {
                first: 'Sterling',
                last: 'Archer'
            }
        }
    });
    
    return model;
}

test("get: Gets nested attribute values", function() {
    var model = create();
    
    deepEqual(model.get('id'), 123);
    
    deepEqual(model.get('user'), {
        type: 'Spy',
        name: {
            first: 'Sterling',
            last: 'Archer'
        }
    });
    
    deepEqual(model.get('user.type'), 'Spy');
    
    deepEqual(model.get('user.name'), {
        first: 'Sterling',
        last: 'Archer'
    });
    
    deepEqual(model.get('user.name.first'), 'Sterling');
});


test("set: Sets nested values given a path", function() {
    var model = create();
    
    model.set({ id: 456 });
    
    equal(model.attributes.id, 456);
    
    
    model.set({
        'user.name.first': 'Lana',<commit_msg>Add test for getting values in arrays<commit_after>module("DeepModel");

function create() {
    var model = new Backbone.DeepModel({
        id: 123,
        user: {
            type: 'Spy',
            name: {
                first: 'Sterling',
                last: 'Archer'
            }
        }
    });
    
    return model;
}

test("get: Gets nested attribute values", function() {
    var model = create();
    
    deepEqual(model.get('id'), 123);
    
    deepEqual(model.get('user'), {
        type: 'Spy',
        name: {
            first: 'Sterling',
            last: 'Archer'
        }
    });
    
    deepEqual(model.get('user.type'), 'Spy');
    
    deepEqual(model.get('user.name'), {
        first: 'Sterling',
        last: 'Archer'
    });
    
    deepEqual(model.get('user.name.first'), 'Sterling');
});


test("get: Gets nested attribute values from arrays", function() {
    var model = new Backbone.DeepModel({
        spies: [
            { name: 'Sterling' },
            { name: 'Lana' }
        ]
    });
    
    deepEqual(model.get('spies.0.name'), 'Sterling');
    
    deepEqual(model.get('spies.1.name'), 'Lana');
});


test("set: Sets nested values given a path", function() {
    var model = create();
    
    model.set({ id: 456 });
    
    equal(model.attributes.id, 456);
    
    
    model.set({
        'user.name.first': 'Lana',
{'fraction_non_alphanumeric': 0.16362126245847175, 'fraction_numerical': 0.01079734219269103, 'mean_word_length': 1.7657864523536166, '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': '3480088', 'n_tokens_mistral': 800, 'n_tokens_neox': 768, 'n_words': 158}