#!/usr/bin/env python2.7 # -*- coding: UTF-8 -*- from __future__ import print_function from __future__ import unicode_literals import re import regex import sys import os if not (("PYTHONIOENCODING" in os.environ) and re.search("^utf-?8$", os.environ["PYTHONIOENCODING"], re.I)): sys.stderr.write(sys.argv[0] + ": Please set your PYTHONIOENCODING envariable to utf8\n") sys.exit(1) import unicodedata if unicodedata.unidata_version < "6.0.0": print("WARNING: Your old UCD is out of date, expected 6.0.0 but got", unicodedata.unidata_version) wide_enough = (sys.maxunicode > 65536) if not wide_enough: print("WARNING: Narrow build detected, your Python lacks full Unicode support!!") data_rows = [ [ "\u0527", "\u0527", "\u0526", "\u0526" ], [ "\u0526", "\u0527", "\u0526", "\u0526" ], [ "𐐼𐐯𐑅𐐨𐑉𐐯𐐻", "𐐼𐐯𐑅𐐨𐑉𐐯𐐻", "𐐔𐐯𐑅𐐨𐑉𐐯𐐻", "𐐔𐐇𐐝𐐀𐐑𐐇𐐓" ], [ "𐐔𐐯𐑅𐐨𐑉𐐯𐐻", "𐐼𐐯𐑅𐐨𐑉𐐯𐐻", "𐐔𐐯𐑅𐐨𐑉𐐯𐐻", "𐐔𐐇𐐝𐐀𐐑𐐇𐐓" ], [ "𐐔𐐇𐐝𐐀𐐑𐐇𐐓", "𐐼𐐯𐑅𐐨𐑉𐐯𐐻", "𐐔𐐯𐑅𐐨𐑉𐐯𐐻", "𐐔𐐇𐐝𐐀𐐑𐐇𐐓" ], ] total, bad = 0, 0 for orig, lower_want, title_want, upper_want in data_rows: total = total + 1 lower_have = orig.lower() title_have = orig.title() upper_have = orig.upper() if lower_want != lower_have: print("FAIL test", total, "lowercase of <"+orig+"> should be <"+lower_want+"> not <"+lower_have+">") bad = bad + 1 if title_want != title_have: print("FAIL test", total, "titlecase of <"+orig+"> should be <"+title_want+"> not <"+title_have+">") bad = bad + 1 if upper_want != upper_have: print("FAIL test", total, "uppercase of <"+orig+"> should be <"+upper_want+"> not <"+upper_have+">") bad = bad + 1 print("") total = total * 3 print("failed", bad, "of", total, "tests") ######################################## # $ python2.7 casemaps.python # WARNING: Your old UCD is out of date, expected 6.0.0 but got 5.2.0 # WARNING: Narrow build detected, your Python lacks full Unicode support!! # # FAIL test 1 titlecase of <Τ§> should be <Τ¦> not <Τ§> # FAIL test 1 uppercase of <Τ§> should be <Τ¦> not <Τ§> # FAIL test 2 lowercase of <Τ¦> should be <Τ§> not <Τ¦> # FAIL test 3 titlecase of <𐐼𐐯𐑅𐐨𐑉𐐯𐐻> should be <𐐔𐐯𐑅𐐨𐑉𐐯𐐻> not <𐐼𐐯𐑅𐐨𐑉𐐯𐐻> # FAIL test 3 uppercase of <𐐼𐐯𐑅𐐨𐑉𐐯𐐻> should be <𐐔𐐇𐐝𐐀𐐑𐐇𐐓> not <𐐼𐐯𐑅𐐨𐑉𐐯𐐻> # FAIL test 4 lowercase of <𐐔𐐯𐑅𐐨𐑉𐐯𐐻> should be <𐐼𐐯𐑅𐐨𐑉𐐯𐐻> not <𐐔𐐯𐑅𐐨𐑉𐐯𐐻> # FAIL test 4 uppercase of <𐐔𐐯𐑅𐐨𐑉𐐯𐐻> should be <𐐔𐐇𐐝𐐀𐐑𐐇𐐓> not <𐐔𐐯𐑅𐐨𐑉𐐯𐐻> # FAIL test 5 lowercase of <𐐔𐐇𐐝𐐀𐐑𐐇𐐓> should be <𐐼𐐯𐑅𐐨𐑉𐐯𐐻> not <𐐔𐐇𐐝𐐀𐐑𐐇𐐓> # FAIL test 5 titlecase of <𐐔𐐇𐐝𐐀𐐑𐐇𐐓> should be <𐐔𐐯𐑅𐐨𐑉𐐯𐐻> not <𐐔𐐇𐐝𐐀𐐑𐐇𐐓> # # failed 9 of 15 tests ############################################################## # $ python3.2 casemaps.python # WARNING: Narrow build detected, your Python lacks full Unicode support!! # FAIL test 3 titlecase of <𐐼𐐯𐑅𐐨𐑉𐐯𐐻> should be <𐐔𐐯𐑅𐐨𐑉𐐯𐐻> not <𐐼𐐯𐑅𐐨𐑉𐐯𐐻> # FAIL test 3 uppercase of <𐐼𐐯𐑅𐐨𐑉𐐯𐐻> should be <𐐔𐐇𐐝𐐀𐐑𐐇𐐓> not <𐐼𐐯𐑅𐐨𐑉𐐯𐐻> # FAIL test 4 lowercase of <𐐔𐐯𐑅𐐨𐑉𐐯𐐻> should be <𐐼𐐯𐑅𐐨𐑉𐐯𐐻> not <𐐔𐐯𐑅𐐨𐑉𐐯𐐻> # FAIL test 4 uppercase of <𐐔𐐯𐑅𐐨𐑉𐐯𐐻> should be <𐐔𐐇𐐝𐐀𐐑𐐇𐐓> not <𐐔𐐯𐑅𐐨𐑉𐐯𐐻> # FAIL test 5 lowercase of <𐐔𐐇𐐝𐐀𐐑𐐇𐐓> should be <𐐼𐐯𐑅𐐨𐑉𐐯𐐻> not <𐐔𐐇𐐝𐐀𐐑𐐇𐐓> # FAIL test 5 titlecase of <𐐔𐐇𐐝𐐀𐐑𐐇𐐓> should be <𐐔𐐯𐑅𐐨𐑉𐐯𐐻> not <𐐔𐐇𐐝𐐀𐐑𐐇𐐓> # # failed 6 of 15 tests