updated spec with media fragment extension
This commit is contained in:
parent
8d3c92dbed
commit
774f7fc7ed
3 changed files with 38 additions and 22 deletions
20
src/Test.hx
20
src/Test.hx
|
|
@ -15,10 +15,10 @@ class Test {
|
|||
static var errors:Int = 0;
|
||||
|
||||
static public function main():Void {
|
||||
test( "url.json", Spec.load("src/spec/url.json") );
|
||||
test( "pos.json", Spec.load("src/spec/pos.json") );
|
||||
//test( "url.json", Spec.load("src/spec/url.json") );
|
||||
//test( "pos.json", Spec.load("src/spec/pos.json") );
|
||||
test( "t.json", Spec.load("src/spec/t.json") );
|
||||
test( "filter.selectors.json", Spec.load("src/spec/filter.selectors.json") );
|
||||
//test( "filter.selectors.json", Spec.load("src/spec/filter.selectors.json") );
|
||||
//test( Spec.load("src/spec/tmp.json") );
|
||||
if( errors > 1 ) trace("\n-----\n[ ❌] "+errors+" errors :/");
|
||||
}
|
||||
|
|
@ -46,6 +46,8 @@ class Test {
|
|||
if( item.expect.fn == "equal.x" ) valid = equalX(res,item);
|
||||
if( item.expect.fn == "equal.xy" ) valid = equalXY(res,item);
|
||||
if( item.expect.fn == "equal.xyz" ) valid = equalXYZ(res,item);
|
||||
if( item.expect.fn == "equal.mediafragment" ) valid = equalMediaFragment(res,item);
|
||||
if( item.expect.fn == "equal.mediafragmentSpd") valid = equalMediaFragmentSpd(res,item);
|
||||
if( item.expect.fn == "testFilterRoot" ) valid = res.exists(item.expect.input[0]) && res.get(item.expect.input[0]).filter.get().root == item.expect.out;
|
||||
if( item.expect.fn == "testFilterDeep" ) valid = res.exists(item.expect.input[0]) && res.get(item.expect.input[0]).filter.get().deep == item.expect.out;
|
||||
var ok:String = valid ? "[ ✔ ] " : "[ ❌] ";
|
||||
|
|
@ -69,6 +71,18 @@ class Test {
|
|||
else return res.get(item.expect.input) && item.expect.out == (Std.string(res.get(item.expect.input).x) +","+ Std.string(res.get(item.expect.input).y)+","+ Std.string(res.get(item.expect.input).z));
|
||||
}
|
||||
|
||||
static public function equalMediaFragment(res:haxe.DynamicAccess<Dynamic>, item:Dynamic):Bool {
|
||||
if( !item.expect.out && !res.get(item.expect.input) ) return true;
|
||||
else return res.get('t').floats[ Std.parseInt(item.expect.input) ] == Std.parseInt(item.expect.out);
|
||||
}
|
||||
|
||||
static public function equalMediaFragmentSpd(res:haxe.DynamicAccess<Dynamic>, item:Dynamic):Bool {
|
||||
if( !item.expect.out && !res.get(item.expect.input) ) return true;
|
||||
else{
|
||||
return res.get('t').speed[ Std.parseInt(item.expect.input) ] == Std.parseFloat(item.expect.out);
|
||||
}
|
||||
}
|
||||
|
||||
static public function testUrl():Void {
|
||||
var Uri = xrfragment.URI;
|
||||
var url:String = "http://foo.com?foo=1#bar=flop&a=1,2&b=c|d|1,2,3";
|
||||
|
|
|
|||
|
|
@ -6,5 +6,7 @@
|
|||
{"fn":"url","data":"http://foo.com?foo=1#t=1,2,3", "expect":{ "fn":"equal.xyz", "input":"t","out":"1,2,3"},"label":"a equal.xyz"},
|
||||
{"fn":"url","data":"http://foo.com?foo=1#t=1,-2,3", "expect":{ "fn":"equal.xyz", "input":"t","out":"1,-2,3"},"label":"a equal.xyz"},
|
||||
{"fn":"url","data":"http://foo.com?foo=1#t=1,100", "expect":{ "fn":"equal.xy", "input":"t","out":"1,100"},"label":"a equal.xy"},
|
||||
{"fn":"url","data":"http://foo.com?foo=1#t=2,500", "expect":{ "fn":"testBrowserOverride", "input":"t","out":true},"label":"browser URI can override t (defined in asset)"}
|
||||
{"fn":"url","data":"http://foo.com?foo=1#t=2,500", "expect":{ "fn":"testBrowserOverride", "input":"t","out":true},"label":"browser URI can override t (defined in asset)"},
|
||||
{"fn":"url","data":"http://foo.com?foo=1#t=1,100,400,500*1.2,2.3", "expect":{ "fn":"equal.mediafragment", "input":"3","out":"500"},"label":"a equal.mediafragment"},
|
||||
{"fn":"url","data":"http://foo.com?foo=1#t=1,100,400,500*1.2,2.3", "expect":{ "fn":"equal.mediafragmentSpd", "input":"1","out":"2.3"},"label":"a equal.mediafragmentSpeed"}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -120,8 +120,8 @@ class XRF {
|
|||
if( isMediaFrag.match(str) ){
|
||||
var speed:Array<String> = str.split("*");
|
||||
v.speed = new Array<Float>();
|
||||
if( speed.length > 0 ){
|
||||
var values:Array<String> = str.split(",");
|
||||
if( speed.length > 1 ){
|
||||
var values:Array<String> = speed[1].split(",");
|
||||
for( i in 0...values.length ){
|
||||
v.speed.push( Std.parseFloat(values[i]) );
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue