<commit_before>declare var window: any;
import TestRunner from '../TestRunner';
import {observable, array} from '../../../scripts/modules/Cascade';

class ViewModel {
    runs: number = 0;
    @array a = [1, 2, 3];
    @observable get loop() {
        var a = this.a;
        var total = 0;
        for (var index = 0, length = a.length; index < length; index++) {
            total += a[index];
        }
        return total;
    }
}

TestRunner.test({
    name: 'Changes to Arrays are observed.',
    test: function(input, callback) {
        var viewModel: any = new ViewModel();
        window.viewModel = viewModel;
        var complete = false;
        viewModel._graph.subscribe('loop', function(value) {
            viewModel.runs++;
            if (complete) {
                callback({
                    value: value,
                    runs: viewModel.runs
                });
            }
        });
        viewModel.a.push(4);
        complete = true;
    },
    assert: function(result, callback) {
        console.log(result);
        if (result.value == 10 && result.runs == 2) {
            callback(true);
        } else {
            callback(false);
        }
    }
});<commit_msg>Cleaned Graph test10.<commit_after>import TestRunner from '../TestRunner';
import {observable, array} from '../../../scripts/modules/Cascade';

class ViewModel {
    runs: number = 0;
    @array a = [1, 2, 3];
    @observable get loop() {
        var a = this.a;
        var total = 0;
        for (var index = 0, length = a.length; index < length; index++) {
            total += a[index];
        }
        return total;
    }
}

TestRunner.test({
    name: 'Changes to Arrays are observed.',
    test: function(input, callback) {
        var viewModel: any = new ViewModel();
        var complete = false;
        viewModel._graph.subscribe('loop', function(value) {
            viewModel.runs++;
            if (complete) {
                callback({
                    value: value,
                    runs: viewModel.runs
                });
            }
        });
        viewModel.a.push(4);
        complete = true;
    },
    assert: function(result, callback) {
        if (result.value == 10 && result.runs == 2) {
            callback(true);
        } else {
            callback(false);
        }
    }
});
{'fraction_non_alphanumeric': 0.13624678663239073, 'fraction_numerical': 0.009425878320479864, 'mean_word_length': 1.5886917960088691, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2823310', 'n_tokens_mistral': 678, 'n_tokens_neox': 657, 'n_words': 175}