| Index: test/intl/overrides/string.js
|
| diff --git a/src/extensions/i18n/collator.h b/test/intl/overrides/string.js
|
| similarity index 60%
|
| copy from src/extensions/i18n/collator.h
|
| copy to test/intl/overrides/string.js
|
| index a3991b9ed244afad996cf5d547c17e077010ac60..b9d31f931765449537ed9d2aa12a16792a631b89 100644
|
| --- a/src/extensions/i18n/collator.h
|
| +++ b/test/intl/overrides/string.js
|
| @@ -26,43 +26,45 @@
|
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| // limitations under the License.
|
|
|
| -#ifndef V8_EXTENSIONS_I18N_COLLATOR_H_
|
| -#define V8_EXTENSIONS_I18N_COLLATOR_H_
|
| +// Tests String.prototype.localeCompare method override.
|
|
|
| -#include "unicode/uversion.h"
|
| -#include "v8.h"
|
| -
|
| -namespace U_ICU_NAMESPACE {
|
| -class Collator;
|
| -class UnicodeString;
|
| -}
|
| +var testData = {
|
| + 'en': ['blood', 'bull', 'ascend', 'zed', 'down'],
|
| + 'sr': ['новине', 'ограда', 'жирафа', 'Никола', 'Андрија', 'Стара Планина',
|
| + 'џак', 'алав', 'ћук', 'чука'],
|
| + 'de': ['März', 'Fuße', 'FUSSE', 'Fluße', 'Flusse', 'flusse', 'fluße',
|
| + 'flüße', 'flüsse']
|
| +};
|
|
|
| -namespace v8_i18n {
|
|
|
| -class Collator {
|
| - public:
|
| - static void JSCreateCollator(const v8::FunctionCallbackInfo<v8::Value>& args);
|
| +function testArrays(locale) {
|
| + var data;
|
| + if (locale === undefined) {
|
| + data = testData['en'];
|
| + locale = [];
|
| + } else {
|
| + data = testData[locale];
|
| + }
|
|
|
| - // Helper methods for various bindings.
|
| + var collator = new Intl.Collator(locale, options);
|
| + var collatorResult = data.sort(collator.compare);
|
| + var localeCompareResult = data.sort(function(a, b) {
|
| + return a.localeCompare(b, locale, options)
|
| + });
|
| + assertEquals(collatorResult, localeCompareResult);
|
| +}
|
|
|
| - // Unpacks collator object from corresponding JavaScript object.
|
| - static icu::Collator* UnpackCollator(v8::Handle<v8::Object> obj);
|
|
|
| - // Release memory we allocated for the Collator once the JS object that
|
| - // holds the pointer gets garbage collected.
|
| - static void DeleteCollator(v8::Isolate* isolate,
|
| - v8::Persistent<v8::Object>* object,
|
| - void* param);
|
| +// Defaults
|
| +var options = undefined;
|
| +testArrays();
|
|
|
| - // Compare two strings and returns -1, 0 and 1 depending on
|
| - // whether string1 is smaller than, equal to or larger than string2.
|
| - static void JSInternalCompare(
|
| - const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
| - private:
|
| - Collator() {}
|
| -};
|
| +// Specify locale, keep default options.
|
| +options = undefined;
|
| +Object.keys(testData).forEach(testArrays);
|
|
|
| -} // namespace v8_i18n
|
|
|
| -#endif // V8_EXTENSIONS_I18N_COLLATOR_H_
|
| +// Specify locale and options.
|
| +options = {caseFirst: 'upper'};
|
| +Object.keys(testData).forEach(testArrays);
|
|
|