Skip to content

Commit

Permalink
remove Utf interface
Browse files Browse the repository at this point in the history
  • Loading branch information
mandel59 committed Jun 4, 2015
1 parent 4bf3363 commit 6e272ca
Show file tree
Hide file tree
Showing 14 changed files with 105 additions and 390 deletions.
2 changes: 1 addition & 1 deletion haxelib.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "MIT",
"tags": ["cross", "unicode", "string"],
"description": "Library for Unicode string support",
"version": "0.2.0",
"version": "0.3.0",
"releasenote": "support python target",
"contributors": ["mandel59"],
"dependencies": {}
Expand Down
2 changes: 0 additions & 2 deletions test/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ class Main {
r.add(new TestUtf32());
r.add(new TestInternalEncoding());
r.add(new TestInternalEncodingIter());
r.add(new TestUtfIter());
r.add(new TestCodePoint());
r.run();
}

}

11 changes: 1 addition & 10 deletions test/TestUnifill.hx
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,9 @@ class TestUnifill extends haxe.unit.TestCase {
assertEquals(false, itr.hasNext());
}

public function test_uCompare() {
assertTrue("𩸽あëa".uCompare("𩸽あëa") == 0);
assertTrue("𩸽あëaa".uCompare("𩸽あëa") > 0);
assertTrue("𩸽あëa".uCompare("𩸽あëaa") < 0);
assertTrue("𩸽あëa".uCompare("𩸽あëb") < 0);
assertTrue("𩸽あëb".uCompare("𩸽あëa") > 0);
assertTrue("𩸽".uCompare("") > 0);
}

public function test_uToString() {
assertEquals("𩸽あëa", [cast 0x29E3D, cast 0x03042, cast 0x000EB, cast 0x00061].uToString());
assertEquals("𩸽あëa", {iterator: "𩸽あëa".uIterator}.uToString());
}

}
}
15 changes: 0 additions & 15 deletions test/TestUtf16.hx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package test;
import unifill.Exception;
import unifill.Unicode;
import unifill.Utf16;
using unifill.UtfTools;

class TestUtf16 extends haxe.unit.TestCase {

Expand Down Expand Up @@ -54,18 +53,4 @@ class TestUtf16 extends haxe.unit.TestCase {
assertFalse(isValid(Utf16.fromArray(a.slice(1))));
}

public function test_compare() {
var s0 = Utf16.fromString("𩸽あëa");
var s1 = Utf16.fromString("𩸽あëaa");
var s2 = Utf16.fromString("𩸽あëb");
var s3 = Utf16.fromString("𩸽");
var s4 = Utf16.fromString("");
assertTrue(s0.compare(s0) == 0);
assertTrue(s0.compare(s1) < 0);
assertTrue(s1.compare(s0) > 0);
assertTrue(s0.compare(s2) < 0);
assertTrue(s2.compare(s0) > 0);
assertTrue(s3.compare(s4) < 0);
}

}
57 changes: 1 addition & 56 deletions test/TestUtf32.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,13 @@ package test;

import unifill.CodePoint;
import unifill.Utf32;
using unifill.UtfTools;

class TestUtf32 extends haxe.unit.TestCase {

public function test_length() {
assertEquals(4, Utf32.fromString("𩸽あëa").length);
}

public function test_compare() {
var s0 = Utf32.fromString("𩸽あëa");
var s1 = Utf32.fromString("𩸽あëaa");
var s2 = Utf32.fromString("𩸽あëb");
var s3 = Utf32.fromString("𩸽");
var s4 = Utf32.fromString("");
assertTrue(s0.compare(s0) == 0);
assertTrue(s0.compare(s1) < 0);
assertTrue(s1.compare(s0) > 0);
assertTrue(s0.compare(s2) < 0);
assertTrue(s2.compare(s0) > 0);
assertTrue(s3.compare(s4) > 0);
}

#if false

public function test_concat() {
var s = Utf32.fromString("𩸽あëa");
assertEquals("𩸽あëa𩸽あëa", (s + s).toString());
Expand All @@ -40,48 +23,10 @@ class TestUtf32 extends haxe.unit.TestCase {
assertFalse(Utf32.fromString("𩸽") == Utf32.fromString(""));
}

public function test_lt() {
assertFalse(Utf32.fromString("𩸽あëa") < Utf32.fromString("𩸽あëa"));
assertFalse(Utf32.fromString("𩸽あëaa") < Utf32.fromString("𩸽あëa"));
assertTrue(Utf32.fromString("𩸽あëa") < Utf32.fromString("𩸽あëaa"));
assertTrue(Utf32.fromString("𩸽あëa") < Utf32.fromString("𩸽あëb"));
assertFalse(Utf32.fromString("𩸽あëb") < Utf32.fromString("𩸽あëa"));
assertFalse(Utf32.fromString("𩸽") < Utf32.fromString(""));
}

public function test_lte() {
assertTrue(Utf32.fromString("𩸽あëa") <= Utf32.fromString("𩸽あëa"));
assertFalse(Utf32.fromString("𩸽あëaa") <= Utf32.fromString("𩸽あëa"));
assertTrue(Utf32.fromString("𩸽あëa") <= Utf32.fromString("𩸽あëaa"));
assertTrue(Utf32.fromString("𩸽あëa") <= Utf32.fromString("𩸽あëb"));
assertFalse(Utf32.fromString("𩸽あëb") <= Utf32.fromString("𩸽あëa"));
assertFalse(Utf32.fromString("𩸽") <= Utf32.fromString(""));
}

public function test_gt() {
assertFalse(Utf32.fromString("𩸽あëa") > Utf32.fromString("𩸽あëa"));
assertTrue(Utf32.fromString("𩸽あëaa") > Utf32.fromString("𩸽あëa"));
assertFalse(Utf32.fromString("𩸽あëa") > Utf32.fromString("𩸽あëaa"));
assertFalse(Utf32.fromString("𩸽あëa") > Utf32.fromString("𩸽あëb"));
assertTrue(Utf32.fromString("𩸽あëb") > Utf32.fromString("𩸽あëa"));
assertTrue(Utf32.fromString("𩸽") > Utf32.fromString(""));
}

public function test_gte() {
assertTrue(Utf32.fromString("𩸽あëa") >= Utf32.fromString("𩸽あëa"));
assertTrue(Utf32.fromString("𩸽あëaa") >= Utf32.fromString("𩸽あëa"));
assertFalse(Utf32.fromString("𩸽あëa") >= Utf32.fromString("𩸽あëaa"));
assertFalse(Utf32.fromString("𩸽あëa") >= Utf32.fromString("𩸽あëb"));
assertTrue(Utf32.fromString("𩸽あëb") >= Utf32.fromString("𩸽あëa"));
assertTrue(Utf32.fromString("𩸽") >= Utf32.fromString(""));
}

public function test_cons_and_snoc() {
var c = new CodePoint(0x29E3D);
assertTrue(Utf32.fromString("𩸽あëa") == c + Utf32.fromString("あëa"));
assertTrue(Utf32.fromString("あëa𩸽") == Utf32.fromString("あëa") + c);
}

#end

}
}
15 changes: 0 additions & 15 deletions test/TestUtf8.hx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import haxe.io.Bytes;
import haxe.io.BytesBuffer;
import unifill.Exception;
import unifill.Utf8;
using unifill.UtfTools;

class TestUtf8 extends haxe.unit.TestCase {

Expand Down Expand Up @@ -71,18 +70,4 @@ class TestUtf8 extends haxe.unit.TestCase {
}
}

public function test_compare() {
var s0 = Utf8.fromString("𩸽あëa");
var s1 = Utf8.fromString("𩸽あëaa");
var s2 = Utf8.fromString("𩸽あëb");
var s3 = Utf8.fromString("𩸽");
var s4 = Utf8.fromString("");
assertTrue(s0.compare(s0) == 0);
assertTrue(s0.compare(s1) < 0);
assertTrue(s1.compare(s0) > 0);
assertTrue(s0.compare(s2) < 0);
assertTrue(s2.compare(s0) > 0);
assertTrue(s3.compare(s4) > 0);
}

}
34 changes: 0 additions & 34 deletions test/TestUtfIter.hx

This file was deleted.

27 changes: 9 additions & 18 deletions unifill/InternalEncoding.hx
Original file line number Diff line number Diff line change
Expand Up @@ -33,62 +33,55 @@ class InternalEncoding {
String `s`.
**/
public static inline function codeUnitAt(s : String, index : Int) : Int {
var u = UtfX.fromString(s);
return u.codeUnitAt(index);
return UtfX.fromString(s).codeUnitAt(index);
}

/**
Returns the Unicode code point at position `index` of
String `s`.
**/
public static inline function codePointAt(s : String, index : Int) : Int {
var u = UtfX.fromString(s);
return u.codePointAt(index);
return UtfX.fromString(s).codePointAt(index);
}

/**
Returns the character as a String at position `index` of
String `s`.
**/
public static inline function charAt(s : String, index : Int) : String {
var u = UtfX.fromString(s);
return u.charAt(index).toString();
return UtfX.fromString(s).charAt(index).toString();
}

/**
Returns the number of Unicode code points from `beginIndex`
to `endIndex` in String `s`.
**/
public static inline function codePointCount(s : String, beginIndex : Int, endIndex : Int) : Int {
var u = UtfX.fromString(s);
return u.codePointCount(beginIndex, endIndex);
return UtfX.fromString(s).codePointCount(beginIndex, endIndex);
}

/**
Returns the number of units of the code point at position
`index` of String `s`.
**/
public static inline function codePointWidthAt(s : String, index : Int) : Int {
var u = UtfX.fromString(s);
return u.codePointWidthAt(index);
return UtfX.fromString(s).codePointWidthAt(index);
}

/**
Returns the number of units of the code point before
position `index` of String `s`.
**/
public static inline function codePointWidthBefore(s : String, index : Int) : Int {
var u = UtfX.fromString(s);
return u.codePointWidthBefore(index);
return UtfX.fromString(s).codePointWidthBefore(index);
}

/**
Returns the index within String `s` that is offset from
position `index` by `codePointOffset` code points.
**/
public static inline function offsetByCodePoints(s : String, index : Int, codePointOffset : Int) : Int {
var u = UtfX.fromString(s);
return u.offsetByCodePoints(index, codePointOffset);
return UtfX.fromString(s).offsetByCodePoints(index, codePointOffset);
}

/**
Expand All @@ -97,8 +90,7 @@ class InternalEncoding {
backward.
**/
public static inline function backwardOffsetByCodePoints(s : String, index : Int, codePointOffset : Int) : Int {
var u = UtfX.fromString(s);
return u.offsetByCodePoints(index, -codePointOffset);
return UtfX.fromString(s).offsetByCodePoints(index, -codePointOffset);
}

/**
Expand All @@ -122,8 +114,7 @@ class InternalEncoding {
`Exception.InvalidCodeUnitSequence` is throwed.
**/
public static inline function validate(s : String) : Void {
var u = UtfX.fromString(s);
u.validate();
UtfX.fromString(s).validate();
}

/**
Expand Down
40 changes: 0 additions & 40 deletions unifill/Utf.hx

This file was deleted.

Loading

0 comments on commit 6e272ca

Please sign in to comment.