FuzzyMapTools.isFuzzy
This commit is contained in:
@@ -9,6 +9,7 @@ using hx.strings.Strings;
|
||||
abstract FuzzyMap<T>(StringMap<T>) from StringMap<T> to StringMap<T> {
|
||||
public inline function new(?m:StringMap<T>) {
|
||||
this = if (m != null) m else new StringMap<T>();
|
||||
FuzzyMapTools.fuzzyMaps[this] = true;
|
||||
}
|
||||
|
||||
@:from
|
||||
|
@@ -13,6 +13,13 @@ typedef MapInfo = {
|
||||
class FuzzyMapTools {
|
||||
static var serializingMaps = new Map<StringMap<Dynamic>, MapInfo>();
|
||||
|
||||
@:allow(kiss.FuzzyMap)
|
||||
static var fuzzyMaps:Map<FuzzyMap<Dynamic>,Bool> = [];
|
||||
|
||||
public static function isFuzzy(map:Map<String,Dynamic>) {
|
||||
return fuzzyMaps.exists(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* FuzzyMap is highly inefficient, so you may wish to memoize the matches that it makes before
|
||||
* releasing your project. FuzzyMapTools.serializeMatches() helps with this
|
||||
|
@@ -1,3 +1,6 @@
|
||||
{goop (cc)}
|
||||
{gloop (cc)}
|
||||
{(Assert.isTrue (FuzzyMapTools.isFuzzy fuzzyMap))(cc)}
|
||||
{(Assert.isFalse (FuzzyMapTools.isFuzzy nonFuzzyMap))(cc)}
|
||||
|
||||
{(set wholeScriptDone true) (cc)}
|
@@ -2,4 +2,6 @@
|
||||
(defReaderMacro "goop" [stream] `(Assert.isTrue true))
|
||||
(defReaderMacro "gloop" [stream] `(Assert.isFalse false))
|
||||
(prop &mut wholeScriptDone false)
|
||||
(prop Assert utest.Assert)
|
||||
(prop Assert utest.Assert)
|
||||
(prop :FuzzyMap<Bool> fuzzyMap (new FuzzyMap<Bool>))
|
||||
(prop :Map<String,Bool> nonFuzzyMap (new Map))
|
@@ -5,6 +5,8 @@ import utest.Assert;
|
||||
import kiss.EmbeddedScript;
|
||||
import kiss.AsyncEmbeddedScript;
|
||||
import kiss.Prelude;
|
||||
import kiss.FuzzyMap;
|
||||
import kiss.FuzzyMapTools;
|
||||
|
||||
class DSLTestCase extends Test {
|
||||
function testScript() {
|
||||
|
Reference in New Issue
Block a user