Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion UnicodeJsps/src/main/java/org/unicode/jsp/UcdLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static synchronized VersionInfo getOldestLoadedUcd() {
return oldestLoadedUcd;
}

private static synchronized void setOldestLoadedUcd(VersionInfo v) {
public static synchronized void setOldestLoadedUcd(VersionInfo v) {
if (v.compareTo(oldestLoadedUcd) < 0) {
oldestLoadedUcd = v;
}
Expand Down
35 changes: 19 additions & 16 deletions UnicodeJsps/src/main/java/org/unicode/jsp/UnicodeSetUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.ibm.icu.util.ULocale;
import com.ibm.icu.util.VersionInfo;
import java.text.ParsePosition;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -221,15 +222,15 @@ public boolean applyPropertyAlias(
return status;
}

private static String[][] COARSE_GENERAL_CATEGORIES = {
{"Other", "C", "Cc", "Cf", "Cn", "Co", "Cs"},
{"Letter", "L", "Ll", "Lm", "Lo", "Lt", "Lu"},
{"Cased_Letter", "LC", "Ll", "Lt", "Lu"},
{"Mark", "M", "Mc", "Me", "Mn"},
{"Number", "N", "Nd", "Nl", "No"},
{"Punctuation", "P", "Pc", "Pd", "Pe", "Pf", "Pi", "Po", "Ps"},
{"Symbol", "S", "Sc", "Sk", "Sm", "So"},
{"Separator", "Z", "Zl", "Zp", "Zs"},
private static String[][][] COARSE_GENERAL_CATEGORIES = {
{{"Other", "C"}, {"Cc", "Cf", "Cn", "Co", "Cs"}},
{{"Letter", "L"}, {"Ll", "Lm", "Lo", "Lt", "Lu"}},
{{"Cased_Letter", "LC"}, {"Ll", "Lt", "Lu"}},
{{"Mark", "M", "Combining_Mark"}, {"Mc", "Me", "Mn"}},
{{"Number", "N"}, {"Nd", "Nl", "No"}},
{{"Punctuation", "P"}, {"Pc", "Pd", "Pe", "Pf", "Pi", "Po", "Ps"}},
{{"Symbol", "S"}, {"Sc", "Sk", "Sm", "So"}},
{{"Separator", "Z"}, {"Zl", "Zp", "Zs"}},
};

// TODO(eggrobin): I think this function only ever returns true; might as well make it void.
Expand Down Expand Up @@ -314,13 +315,15 @@ private boolean applyPropertyAlias0(
UnicodePropertySymbolTable::parseVersionInfoOrMax));
} else {
if (prop.getName().equals("General_Category")) {
for (String[] coarseValue : COARSE_GENERAL_CATEGORIES) {
final String longName = coarseValue[0];
final String shortName = coarseValue[1];
if (UnicodeProperty.equalNames(propertyValue, longName)
|| UnicodeProperty.equalNames(propertyValue, shortName)) {
for (int i = 2; i < coarseValue.length; ++i) {
prop.getSet(coarseValue[i], result);
for (String[][] coarseValue : COARSE_GENERAL_CATEGORIES) {
final String[] aliases = coarseValue[0];
if (Arrays.stream(aliases)
.anyMatch(
a ->
UnicodeProperty.equalNames(
propertyValue, a))) {
for (var value : coarseValue[1]) {
prop.getSet(value, result);
}
return true;
}
Expand Down
22 changes: 22 additions & 0 deletions UnicodeJsps/src/test/java/org/unicode/jsptest/TestUnicodeSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,21 @@
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIf;
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.opentest4j.TestAbortedException;
import org.unicode.jsp.CharEncoder;
import org.unicode.jsp.Common;
import org.unicode.jsp.UcdLoader;
import org.unicode.jsp.UnicodeJsp;
import org.unicode.jsp.UnicodeSetUtilities;
import org.unicode.jsp.UnicodeUtilities;
import org.unicode.jsp.XPropertyFactory;
import org.unicode.props.IndexUnicodeProperties;
import org.unicode.props.UnicodeProperty;
import org.unicode.text.utility.Settings;

public class TestUnicodeSet extends TestFmwk2 {

Expand Down Expand Up @@ -141,6 +145,24 @@ public void TestPretty() {
logln(derived);
}

@Test
@EnabledIfSystemProperty(
named = "UNICODETOOLS_TEST_WITH_INCREMENTAL_PROPERTIES",
matches = ".*",
disabledReason = "Tests with incremental properties must be run separately")
public void TestGeneralCategoryGroupingsWithIncrementalProperties() {
IndexUnicodeProperties.useIncrementalProperties();
UcdLoader.setOldestLoadedUcd(VersionInfo.UNICODE_10_0);
checkSetsEqual("[\\p{U10:Lu}\\p{U10:Ll}\\p{U10:Lm}\\p{U10:Lt}\\p{U10:Lo}]", "\\p{U10:L}");
UcdLoader.setOldestLoadedUcd(Settings.LAST_VERSION_INFO);
}

@Test
public void TestGeneralCategoryGroupings() {
checkSetsEqual("[\\p{Lu}\\p{Ll}\\p{Lm}\\p{Lt}\\p{Lo}]", "\\p{L}");
checkSetsEqual("[\\p{Mc}\\p{Me}\\p{Mn}]", "\\p{gc=Combining_Mark}");
}

@Test
public void TestInteriorlyNegatedComparison() {
checkProperties("\\p{Uppercase≠@Changes_When_Lowercased@}", "[𝕬-𝖅]");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -795,14 +795,16 @@ public UnicodeSet getSet(PatternMatcher matcher, UnicodeSet result) {
return super.getSet(matcher, result);
}
final long start = System.currentTimeMillis();
final UnicodeSet baseSet =
baseVersionProperties.getProperty(prop).getSet(matcher, result);
final UnicodeSet baseSet = baseVersionProperties.getProperty(prop).getSet(matcher);
final UnicodeSet matchingInThisVersion =
super.getSet(matcher, null).retainAll(getDiffSet());
result =
baseSet.addAll(matchingInThisVersion)
.removeAll(
getDiffSet().cloneAsThawed().removeAll(matchingInThisVersion));
baseSet.addAll(matchingInThisVersion)
.removeAll(getDiffSet().cloneAsThawed().removeAll(matchingInThisVersion));
if (result == null) {
result = baseSet;
} else {
result.addAll(baseSet);
}
final long stop = System.currentTimeMillis();
final long Δt_in_ms = stop - start;
if (Δt_in_ms > 100) {
Expand Down
Loading