Skip to content

Commit

Permalink
Std.is to Std.isOfType
Browse files Browse the repository at this point in the history
  • Loading branch information
seiren-games committed Jun 20, 2021
1 parent 076bad3 commit 6131fba
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 23 deletions.
14 changes: 7 additions & 7 deletions src/thx/Assert.hx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class Assert {
#if !no_asserts
if (msg == null)
msg = 'expected type ${Types.anyValueToString(type)} but it is ${Types.valueTypeToString(value)}';
isTrue(Std.is(value, type), msg, pos);
isTrue(Std.isOfType(value, type), msg, pos);
#end
}

Expand Down Expand Up @@ -333,7 +333,7 @@ class Assert {
var name = Types.anyValueToString(type);
msgWrongType = 'expected throw of type $name but it is $ex';
}
isTrue(Std.is(ex, type), msgWrongType, pos);
isTrue(Std.isOfType(ex, type), msgWrongType, pos);
}
}
#end
Expand Down Expand Up @@ -471,7 +471,7 @@ class Assert {
return true;
case TClass(c):
// string
if (Std.is(expected, String)) {
if (Std.isOfType(expected, String)) {
if (expected == value) {
return true;
} else {
Expand All @@ -481,7 +481,7 @@ class Assert {
}

// arrays
if (Std.is(expected, Array)) {
if (Std.isOfType(expected, Array)) {
if (status.recursive || status.path == '') {
if (expected.length != value.length) {
status.error = withPath('expected ${expected.length} elements but they are ${value.length}');
Expand All @@ -500,7 +500,7 @@ class Assert {
}

// date
if (Std.is(expected, Date)) {
if (Std.isOfType(expected, Date)) {
if ((expected : Date).getTime() != (value : Date).getTime()) {
status.error = withPath('expected $expected but it is $value');
return false;
Expand All @@ -509,7 +509,7 @@ class Assert {
}

// bytes
if (Std.is(expected, Bytes)) {
if (Std.isOfType(expected, Bytes)) {
if (status.recursive || status.path == '') {
var ebytes:Bytes = expected, vbytes:Bytes = value;
if (ebytes.length != vbytes.length)
Expand All @@ -524,7 +524,7 @@ class Assert {
}

// hash, inthash
if (Std.is(expected, #if (haxe_ver >= 3.200) haxe.Constraints.IMap #else Map.IMap #end)) {
if (Std.isOfType(expected, #if (haxe_ver >= 3.200) haxe.Constraints.IMap #else Map.IMap #end)) {
if (status.recursive || status.path == '') {
var map = cast(expected, Map<Dynamic, Dynamic>),
vmap = cast(value, Map<Dynamic, Dynamic>),
Expand Down
2 changes: 1 addition & 1 deletion src/thx/Convert.hx
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class Convert {
public static function toArray<T>(value:Dynamic, convert:Dynamic->T):Array<T> {
if (null == value)
return [];
return Std.is(value, Array) ? (value : Array<Dynamic>).map(convert) : throw new Error('unable to convert $value to Array<T>');
return Std.isOfType(value, Array) ? (value : Array<Dynamic>).map(convert) : throw new Error('unable to convert $value to Array<T>');
}

public static function toMap<T>(value:Dynamic, convert:Dynamic->T):Map<String, T> {
Expand Down
2 changes: 1 addition & 1 deletion src/thx/DateTime.hx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ abstract DateTime(Array<Int64>) {
public static function is(v:Dynamic):Bool {
if (v == null)
return false;
if (!Std.is(v, Array))
if (!Std.isOfType(v, Array))
return false;
var vs:Array<Dynamic> = v;
if (vs.length != 2)
Expand Down
6 changes: 3 additions & 3 deletions src/thx/Dynamics.hx
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ class Dynamics {
return false;

// string
if (Std.is(a, String))
if (Std.isOfType(a, String))
return false;

// arrays
if (Std.is(a, Array)) {
if (Std.isOfType(a, Array)) {
var aa:Array<Dynamic> = cast a, ab:Array<Dynamic> = cast b;
if (aa.length != ab.length)
return false;
Expand All @@ -48,7 +48,7 @@ class Dynamics {
}

// date
if (Std.is(a, Date))
if (Std.isOfType(a, Date))
return untyped a.getTime() == b.getTime();

// map
Expand Down
2 changes: 1 addition & 1 deletion src/thx/Error.hx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Error #if js extends js.lib.Error #end {
If `err` is already an instance of `Error`, it is returned and nothing is created.
**/
public static function fromDynamic(err:Dynamic, ?pos:PosInfos):Error {
if (Std.is(err, Error))
if (Std.isOfType(err, Error))
return cast err;
return new ErrorWrapper("" + err, err, null, pos);
}
Expand Down
4 changes: 2 additions & 2 deletions src/thx/Maps.hx
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ class Maps {
return !map.iterator().hasNext();

/**
Returns true if a value is of any type of Map. Equivalent to `Std.is(v, IMap)`.
Returns true if a value is of any type of Map. Equivalent to `Std.isOfType(v, IMap)`.
**/
inline public static function isMap(v:Dynamic)
return Std.is(v, IMap);
return Std.isOfType(v, IMap);

public static function string<TKey, TValue>(m:IMap<TKey, TValue>):String {
return "[" + tuples(m).map(function(t:Tuple<TKey, TValue>):String {
Expand Down
4 changes: 2 additions & 2 deletions src/thx/Objects.hx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Objects {

public static function deflate(o:{}, ?flattenArrays:Bool = true):{} {
function f(v:Dynamic):Either<Dynamic, Map<String, Dynamic>> {
if (Std.is(v, Array)) {
if (Std.isOfType(v, Array)) {
if (flattenArrays) {
if (v.length == 0) {
return Left([]);
Expand Down Expand Up @@ -224,7 +224,7 @@ class Objects {
public static function string(o:{}):String {
return "{" + Reflect.fields(o).map(function(key) {
var v = Reflect.field(o, key);
var s = if (Std.is(v, String)) {
var s = if (Std.isOfType(v, String)) {
Strings.quote((v : String));
} else {
Dynamics.string(v);
Expand Down
2 changes: 1 addition & 1 deletion src/thx/QueryString.hx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ abstract QueryString(Map<String, QueryStringValue>) from Map<String, QueryString
if (!Reflect.isObject(o))
throw 'unable to convert $o to QueryString';
Objects.tuples(o).each(function(t) {
if (Std.is(t.right, Array)) {
if (Std.isOfType(t.right, Array)) {
qs.setMany(t.left, (cast t.right : Array<Dynamic>).map.fn('$_'));
} else {
qs.set(t.left, '${t.right}');
Expand Down
6 changes: 3 additions & 3 deletions src/thx/Types.hx
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ class Types {
Returns a string describing the type of any `value`.
**/
inline public static function anyValueToString(value:Dynamic) {
if (Std.is(value, Type.ValueType))
if (Std.isOfType(value, Type.ValueType))
return toString(value);
if (Std.is(value, Class))
if (Std.isOfType(value, Class))
return Type.getClassName(value);
if (Std.is(value, Enum))
if (Std.isOfType(value, Enum))
return Type.getEnumName(value);
return valueTypeToString(value);
}
Expand Down
4 changes: 2 additions & 2 deletions src/thx/macro/BuildResource.hx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class BuildResource {
var length = prefix.length;
o.tuples().map(function(t) {
if (t.left.startsWith(prefix)) {
if (!Std.is(t.right, String))
if (!Std.isOfType(t.right, String))
return;
var key = t.left.substring(length),
value:String = path.isEmpty() ? t.right : '$path/${t.right}',
Expand All @@ -59,7 +59,7 @@ class BuildResource {
.map(function(v) return v.params)
.flatten()
.map(function(p) return ExprTools.getValue(p));
if (values.length == 0 || !Std.is(values[0], String))
if (values.length == 0 || !Std.isOfType(values[0], String))
return prefixSymbol;
return values[0];
}
Expand Down

0 comments on commit 6131fba

Please sign in to comment.