From 7382813788621074afcff52e436754c9eaeb5602 Mon Sep 17 00:00:00 2001 From: "Amir E. Aharoni" Date: Tue, 7 Aug 2012 00:28:06 +0300 Subject: [PATCH] Add a test for checking that all languages have autonyms DRAFT Some languages don't yet have autonyms, but probably all languages should have them. It currently fails, because there are many such languages and I am not aware of a nice way to skip it in QUnit (there is a proper skipping mechanism in Perl testing, for example). Also change orphanScripts() to return all scripts without groups. Change-Id: I21c13d7bba89f3b991bc340e6ff6e040c704beb8 --- tests/qunit/ext.uls.tests.js | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/tests/qunit/ext.uls.tests.js b/tests/qunit/ext.uls.tests.js index 84687dbb..bb1c51f2 100644 --- a/tests/qunit/ext.uls.tests.js +++ b/tests/qunit/ext.uls.tests.js @@ -26,15 +26,33 @@ module( "ext.uls", QUnit.newMwEnvironment() ); * Runs over all script codes mentioned in langdb and checks whether * they belong to the 'Other' group. */ -var orphanScript = function () { +var orphanScripts = function () { + var result = []; + for ( var language in $.uls.data.languages ) { var script = $.uls.data.script( language ); if ( $.uls.data.groupOfScript( script ) === 'Other' ) { - return script; + result.push( script ); } } - return ''; + return result; +}; + +/* + * Runs over all script codes mentioned in langdb and checks whether + * they have something that looks like an autonym. + */ +var languagesWithoutAutonym = function () { + var result = []; + + for ( var language in $.uls.data.languages ) { + if ( typeof $.uls.data.autonym( language ) !== 'string' ) { + result.push( language ); + } + } + + return result; }; test( "-- Initial check", function() { @@ -43,11 +61,13 @@ test( "-- Initial check", function() { } ); test( "-- $.uls.data testing", function() { - expect( 19 ); + expect( 20 ); // This test assumes that we don't want any scripts to be in the 'Other' // group. Actually, this may become wrong some day. - strictEqual( orphanScript(), '', 'No orphan scripts found.' ); + deepEqual( orphanScripts(), [], 'All scripts belong to script groups.' ); + deepEqual( languagesWithoutAutonym(), [], 'All languages have autonyms.' ); + strictEqual( $.uls.data.groupOfScript( 'Beng' ), 'SouthAsian',