<commit_before>/*
 * testcalendar.js - test the calendar routines
 * 
 * Copyright © 2012, JEDLSoft
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

function testCalendarFactoryDefault() {
    var cal = ilib.Cal.newInstance();
    assertNotUndefined(cal);
}

function testCalendarFactoryDefaultRightType() {
    var cal = ilib.Cal.newInstance();
    assertNotUndefined(cal);
    
    assertEquals("gregorian", cal.getType());
}

function testCalendarFactorySpecific() {
    var cal = ilib.Cal.newInstance({type: "julian"});
    assertNotUndefined(cal);
    
    assertEquals("julian", cal.getType());
}

function testCalendarFactoryUnknown() {
    var cal = ilib.Cal.newInstance({type: "asdf"});
    assertUndefined(cal);
}

function testCalendarFactoryDefaultForLocale() {
    var cal = ilib.Cal.newInstance({locale: "ar-AE"});
    assertNotUndefined(cal);
    
    assertEquals("gregorian", cal.getType());
}

function testCalendarFactoryDefaultForLocaleOther() {
    var cal = ilib.Cal.newInstance({locale: "th-TH"});
    assertNotUndefined(cal);
    
    assertEquals("buddhist", cal.getType());
}

function testCalendarFactoryOverrideLocale() {
    var cal = ilib.Cal.newInstance({locale: "ar-AE", type: "gregorian"});
    assertNotUndefined(cal);
    
    assertEquals("gregorian", cal.getType());
}

function testGetCalendars() {
    var expected = [
        "julian",
        "gregorian",
        "islamic",<commit_msg>Can't test the default calendar name for Thai until the Thai solar calendar is implemented.<commit_after>/*
 * testcalendar.js - test the calendar routines
 * 
 * Copyright © 2012, JEDLSoft
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

function testCalendarFactoryDefault() {
    var cal = ilib.Cal.newInstance();
    assertNotUndefined(cal);
}

function testCalendarFactoryDefaultRightType() {
    var cal = ilib.Cal.newInstance();
    assertNotUndefined(cal);
    
    assertEquals("gregorian", cal.getType());
}

function testCalendarFactorySpecific() {
    var cal = ilib.Cal.newInstance({type: "julian"});
    assertNotUndefined(cal);
    
    assertEquals("julian", cal.getType());
}

function testCalendarFactoryUnknown() {
    var cal = ilib.Cal.newInstance({type: "asdf"});
    assertUndefined(cal);
}

function testCalendarFactoryDefaultForLocale() {
    var cal = ilib.Cal.newInstance({locale: "ar-AE"});
    assertNotUndefined(cal);
    
    assertEquals("gregorian", cal.getType());
}

/*
can't test this until the calendar routines support the
Thai solar calendar.

function testCalendarFactoryDefaultForLocaleOther() {
    var cal = ilib.Cal.newInstance({locale: "th-TH"});
    assertNotUndefined(cal);
    
    assertEquals("buddhist", cal.getType());
}
*/

function testCalendarFactoryOverrideLocale() {
    var cal = ilib.Cal.newInstance({locale: "ar-AE", type: "gregorian"});
    assertNotUndefined(cal);
    
    assertEquals("gregorian", cal.getType());
}

function testGetCalendars() {
    var expected = [
        "julian",
        "gregorian",
        "islamic",
{'fraction_non_alphanumeric': 0.11703703703703704, 'fraction_numerical': 0.003950617283950617, 'mean_word_length': 3.952322738386308, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5143480', 'n_tokens_mistral': 1175, 'n_tokens_neox': 1143, 'n_words': 333}