<commit_before>/// <reference path="../src/map.ts" />
/// <reference path="../d.ts/mocha.d.ts" />
/// <reference path="../d.ts/chai.d.ts" />

module Katana.Spec {

    describe('Map', () => {
        chai.should();

        describe('#constructor', () => {

            it('can initialize with key/value pairs', () => {
                var map = new Katana.Map('key1', 'value1',
                                         'key2', 'value2');

                map.get('key1').get().should.be.equal('value1');
                map.get('key2').get().should.be.equal('value2');
            });

            it('cannot initialize with invalid key/value paires', () => {
                var f = () => {
                    new Katana.Map('key1', 'value1',
                                   'key2');
                }
                f.should.throw('key2 has not value.');
            });

            it('can initialize with Object', () => {
                var map = new Katana.Map<string, string>({
                    'key1': 'value1',
                    'key2': 'value2'
                });

                map.get('key1').get().should.be.equal('value1');
                map.get('key2').get().should.be.equal('value2');
            });

            it('can initialize with any arugment', () => {
                var map = new Katana.Map<string, string>();
                (() => map.get('hoge').get()).should.throw('No such element.');   
            });
        });

        describe('when initialized three key/value pairs', () => {
 
            var map: Map<string, string>;
            beforeEach(() => {
                map = new Katana.Map('key1', 'value1',
                                     'key2', 'value2',
                                     'key3', 'value3');
            });

            describe('#get', () => {
                it('returns Some<V> if contains key', () => {
                    map.get('key1').should.be.instanceof(Katana.Some);
                    map.get('key1').get().should.equal('value1');
                });

                it('retruns None if not contains key', () => {
                    map.get('any').should.be.instanceof(Katana.None);
                });
            });


            describe('#getOrElse', () => {
                it('returns value if contains key', () => {
                    map.getOrElse('key1', () => 'a').should.equal('value1');
                });

                it('retruns defaultValue if not contains key', () => {
                    map.getOrElse('any', () => 'none').should.equal('none');
                });
            });

            describe('#foreach', () => {
                it('can iterate key/value pairs', () => {
                    var counter = 0;
                    map.foreach((k, v) => {
                        map.get(k).get().should.equal(v);
                        counter++;
                    });
                    counter.should.equal(3);
                });
            });

        });
    });
}
<commit_msg>Fix typo<commit_after>/// <reference path="../src/map.ts" />
/// <reference path="../d.ts/mocha.d.ts" />
/// <reference path="../d.ts/chai.d.ts" />

module Katana.Spec {

    describe('Map', () => {
        chai.should();

        describe('#constructor', () => {

            it('can initialize with key/value pairs', () => {
                var map = new Katana.Map('key1', 'value1',
                                         'key2', 'value2');

                map.get('key1').get().should.be.equal('value1');
                map.get('key2').get().should.be.equal('value2');
            });

            it('cannot initialize with invalid key/value paires', () => {
                var f = () => {
                    new Katana.Map('key1', 'value1',
                                   'key2');
                }
                f.should.throw('key2 has not value.');
            });

            it('can initialize with Object', () => {
                var map = new Katana.Map<string, string>({
                    'key1': 'value1',
                    'key2': 'value2'
                });

                map.get('key1').get().should.be.equal('value1');
                map.get('key2').get().should.be.equal('value2');
            });

            it('can initialize with any argument', () => {
                var map = new Katana.Map<string, string>();
                (() => map.get('hoge').get()).should.throw('No such element.');   
            });
        });

        describe('when initialized three key/value pairs', () => {
 
            var map: Map<string, string>;
            beforeEach(() => {
                map = new Katana.Map('key1', 'value1',
                                     'key2', 'value2',
                                     'key3', 'value3');
            });

            describe('#get', () => {
                it('returns Some<V> if contains key', () => {
                    map.get('key1').should.be.instanceof(Katana.Some);
                    map.get('key1').get().should.equal('value1');
                });

                it('retruns None if not contains key', () => {
                    map.get('any').should.be.instanceof(Katana.None);
                });
            });


            describe('#getOrElse', () => {
                it('returns value if contains key', () => {
                    map.getOrElse('key1', () => 'a').should.equal('value1');
                });

                it('retruns defaultValue if not contains key', () => {
                    map.getOrElse('any', () => 'none').should.equal('none');
                });
            });

            describe('#foreach', () => {
                it('can iterate key/value pairs', () => {
                    var counter = 0;
                    map.foreach((k, v) => {
                        map.get(k).get().should.equal(v);
                        counter++;
                    });
                    counter.should.equal(3);
                });
            });

        });
    });
}

{'fraction_non_alphanumeric': 0.1820593599734704, 'fraction_numerical': 0.010943458796219533, 'mean_word_length': 1.1542857142857144, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 59, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2297656', 'n_tokens_mistral': 1659, 'n_tokens_neox': 1526, 'n_words': 265}