From 4da16f858bac1a1d34c850f2681fbf6424a7b992 Mon Sep 17 00:00:00 2001 From: electricessence Date: Thu, 26 May 2016 19:54:19 -0700 Subject: [PATCH] Added another more broad test. --- tests/mocha/System/TypeValidator.js | 11 +++++++++++ tests/mocha/System/TypeValidator.js.map | 2 +- tests/mocha/System/TypeValidator.ts | 12 ++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/tests/mocha/System/TypeValidator.js b/tests/mocha/System/TypeValidator.js index 6553cbd7..973523f3 100644 --- a/tests/mocha/System/TypeValidator.js +++ b/tests/mocha/System/TypeValidator.js @@ -27,6 +27,17 @@ }); describe('.contains(descriptor)', function () { it('should detect a positive match', function () { + assert.ok(example.contains({ + a: Object, + b: String, + c: Number, + d: Boolean, + e: { + f: String, + g: Boolean, + h: Array + } + })); assert.ok(example.contains({ a: Object, b: String, diff --git a/tests/mocha/System/TypeValidator.js.map b/tests/mocha/System/TypeValidator.js.map index 1b09417f..a7692841 100644 --- a/tests/mocha/System/TypeValidator.js.map +++ b/tests/mocha/System/TypeValidator.js.map @@ -1 +1 @@ -{"version":3,"sources":["System/TypeValidator.ts"],"names":[],"mappings":";;;;;;;;;IAEA,8BAA4B,sCAAsC,CAAC,CAAA;IACnE,IAAI,MAAM,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC;IAE5D,IAAM,OAAO,GAAG,IAAI,6BAAa,CAAC;QACjC,CAAC,EAAC,EAAE;QACJ,CAAC,EAAC,OAAO;QACT,CAAC,EAAC,CAAC;QACH,CAAC,EAAC,IAAI;QACN,CAAC,EAAE;YACF,CAAC,EAAC,UAAU;YACZ,CAAC,EAAC,KAAK;YACP,CAAC,EAAC;gBACD,CAAC;gBACD,CAAC;gBACD,GAAG;aACH;SACD;QACD,CAAC,EAAC,OAAO;KACT,CAAC,CAAC;IAEH,QAAQ,CAAC,uBAAuB,EAAE;QAEjC,EAAE,CAAC,gCAAgC,EAAE;YAEpC,MAAM,CAAC,EAAE,CAAC,OAAO,CA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ACN;iBACD;aACD,CAAC,CAAC,CAAC;YAEJ,MAAM,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;gBAC3B,CAAC,EAAC,MAAM;gBACR,CAAC,EAAC,MAAM;gBACR,CAAC,EAAC,MAAM;gBACR,CAAC,EAAC,OAAO;gBACT,CAAC,EAAE;oBACF,CAAC,EAAC,MAAM;oBACR,CAAC,EAAC,OAAO;oBACT,CAAC,EAAC;wBACD,MAAM;qBACN;iBACD;aACD,CAAC,CAAC,CAAC;YAGJ,MAAM,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;gBAC3B,CAAC,EAAC,MAAM;gBACR,CAAC,EAAC,MAAM;gBACR,CAAC,EAAC,MAAM;gBACR,CAAC,EAAC,OAAO;gBACT,CAAC,EAAE;oBACF,CAAC,EAAC,MAAM;oBACR,CAAC,EAAC,OAAO;oBACT,CAAC,EAAC;wBACD,MAAM;qBACN;iBACD;gBACD,CAAC,EAAC,KAAK;aACP,CAAC,CAAC,CAAC;YAEJ,MAAM,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;gBAC3B,CAAC,EAAC,MAAM;gBACR,CAAC,EAAC,MAAM;gBACR,CAAC,EAAC,MAAM;gBACR,CAAC,EAAC,OAAO;gBACT,CAAC,EAAE;oBACF,CAAC,EAAC,MAAM;oBACR,CAAC,EAAC,OAAO;oBACT,CAAC,EAAC;wBACD,MAAM;qBACN;iBACD;gBACD,CAAC,EAAC,OAAO;aACT,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC","file":"System/TypeValidator.js","sourcesContent":["///\r\n\r\nimport {TypeValidator} from \"../../../source/System/TypeValidator\";\r\nvar assert = require('../../../node_modules/assert/assert');\r\n\r\nconst example = new TypeValidator({\r\n\ta:{},\r\n\tb:\"hello\",\r\n\tc:1,\r\n\td:true,\r\n\te: {\r\n\t\tf:\"whatever\",\r\n\t\tg:false,\r\n\t\th:[\r\n\t\t\t0,\r\n\t\t\t1,\r\n\t\t\t\"2\"\r\n\t\t]\r\n\t},\r\n\ti:\"noise\"\r\n});\r\n\r\ndescribe('.contains(descriptor)', ()=>\r\n{\r\n\tit('should detect a positive match', ()=>\r\n\t{\r\n\t\tassert.ok(example.contains({\r\n\t\t\ta:Object,\r\n\t\t\tb:String,\r\n\t\t\tc:Number,\r\n\t\t\td:Boolean,\r\n\t\t\te: {\r\n\t\t\t\tf:String,\r\n\t\t\t\tg:Boolean,\r\n\t\t\t\th:[\r\n\t\t\t\t\tNumber,\r\n\t\t\t\t\tNumber,\r\n\t\t\t\t\tString\r\n\t\t\t\t]\r\n\t\t\t}\r\n\t\t}));\r\n\r\n\t\tassert.ok(example.contains({\r\n\t\t\ta:Object,\r\n\t\t\tb:String,\r\n\t\t\tc:Number,\r\n\t\t\td:Boolean,\r\n\t\t\te: {\r\n\t\t\t\tf:String,\r\n\t\t\t\tg:Boolean,\r\n\t\t\t\th:[\r\n\t\t\t\t\tNumber,\r\n\t\t\t\t\tNumber,\r\n\t\t\t\t\tString\r\n\t\t\t\t]\r\n\t\t\t},\r\n\t\t\ti:\"noise\"\r\n\t\t}));\r\n\r\n\t\tassert.ok(example.contains({\r\n\t\t\ta:Object,\r\n\t\t\tb:String,\r\n\t\t\tc:Number,\r\n\t\t\td:Boolean,\r\n\t\t\te: {\r\n\t\t\t\tf:String,\r\n\t\t\t\tg:Boolean,\r\n\t\t\t\th:[\r\n\t\t\t\t\tNumber\r\n\t\t\t\t]\r\n\t\t\t}\r\n\t\t}))\r\n\t});\r\n\r\n\tit('should detect a negative match', ()=>\r\n\t{\r\n\t\tassert.ok(!example.contains({\r\n\t\t\ta:Object,\r\n\t\t\tb:String,\r\n\t\t\tc:Number,\r\n\t\t\td:Boolean,\r\n\t\t\te: {\r\n\t\t\t\tf:String,\r\n\t\t\t\tg:Boolean,\r\n\t\t\t\th:[\r\n\t\t\t\t\tNumber,\r\n\t\t\t\t\tBoolean,\r\n\t\t\t\t\tString\r\n\t\t\t\t]\r\n\t\t\t}\r\n\t\t}));\r\n\r\n\t\tassert.ok(!example.contains({\r\n\t\t\ta:Object,\r\n\t\t\tb:String,\r\n\t\t\tc:Number,\r\n\t\t\td:Boolean,\r\n\t\t\te: {\r\n\t\t\t\tf:String,\r\n\t\t\t\tg:Boolean,\r\n\t\t\t\th:[\r\n\t\t\t\t\tString\r\n\t\t\t\t]\r\n\t\t\t}\r\n\t\t}));\r\n\r\n\r\n\t\tassert.ok(!example.contains({\r\n\t\t\ta:Object,\r\n\t\t\tb:String,\r\n\t\t\tc:Number,\r\n\t\t\td:Boolean,\r\n\t\t\te: {\r\n\t\t\t\tf:String,\r\n\t\t\t\tg:Boolean,\r\n\t\t\t\th:[\r\n\t\t\t\t\tNumber\r\n\t\t\t\t]\r\n\t\t\t},\r\n\t\t\ti:\"goo\"\r\n\t\t}));\r\n\r\n\t\tassert.ok(!example.contains({\r\n\t\t\ta:Object,\r\n\t\t\tb:String,\r\n\t\t\tc:Number,\r\n\t\t\td:Boolean,\r\n\t\t\te: {\r\n\t\t\t\tf:String,\r\n\t\t\t\tg:Boolean,\r\n\t\t\t\th:[\r\n\t\t\t\t\tNumber\r\n\t\t\t\t]\r\n\t\t\t},\r\n\t\t\ti:Boolean\r\n\t\t}));\r\n\t});\r\n});\r\n"]} \ No newline at end of file +{"version":3,"sources":["System/TypeValidator.ts"],"names":[],"mappings":";;;;;;;;;IAEA,8BAA4B,sCAAsC,CAAC,CAAA;IACnE,IAAI,MAAM,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC;IAE5D,IAAM,OAAO,GAAG,IAAI,6BAAa,CAAC;QACjC,CAAC,EAAC,EAAE;QACJ,CAAC,EAAC,OAAO;QACT,CAAC,EAAC,CAAC;QACH,CAAC,EAAC,IAAI;QACN,CAAC,EAAE;YACF,CAAC,EAAC,UAAU;YACZ,CAAC,EAAC,KAAK;YACP,CAAC,EAAC;gBACD,CAAC;gBACD,CAAC;gBACD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C,OAAO;gBACT,CAAC,EAAE;oBACF,CAAC,EAAC,MAAM;oBACR,CAAC,EAAC,OAAO;oBACT,CAAC,EAAC;wBACD,MAAM;qBACN;iBACD;gBACD,CAAC,EAAC,OAAO;aACT,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC","file":"System/TypeValidator.js","sourcesContent":["///\r\n\r\nimport {TypeValidator} from \"../../../source/System/TypeValidator\";\r\nvar assert = require('../../../node_modules/assert/assert');\r\n\r\nconst example = new TypeValidator({\r\n\ta:{},\r\n\tb:\"hello\",\r\n\tc:1,\r\n\td:true,\r\n\te: {\r\n\t\tf:\"whatever\",\r\n\t\tg:false,\r\n\t\th:[\r\n\t\t\t0,\r\n\t\t\t1,\r\n\t\t\t\"2\"\r\n\t\t]\r\n\t},\r\n\ti:\"noise\"\r\n});\r\n\r\ndescribe('.contains(descriptor)', ()=>\r\n{\r\n\tit('should detect a positive match', ()=>\r\n\t{\r\n\t\tassert.ok(example.contains({\r\n\t\t\ta:Object,\r\n\t\t\tb:String,\r\n\t\t\tc:Number,\r\n\t\t\td:Boolean,\r\n\t\t\te: {\r\n\t\t\t\tf:String,\r\n\t\t\t\tg:Boolean,\r\n\t\t\t\th:Array\r\n\t\t\t}\r\n\t\t}));\r\n\r\n\t\tassert.ok(example.contains({\r\n\t\t\ta:Object,\r\n\t\t\tb:String,\r\n\t\t\tc:Number,\r\n\t\t\td:Boolean,\r\n\t\t\te: {\r\n\t\t\t\tf:String,\r\n\t\t\t\tg:Boolean,\r\n\t\t\t\th:[\r\n\t\t\t\t\tNumber,\r\n\t\t\t\t\tNumber,\r\n\t\t\t\t\tString\r\n\t\t\t\t]\r\n\t\t\t}\r\n\t\t}));\r\n\r\n\t\tassert.ok(example.contains({\r\n\t\t\ta:Object,\r\n\t\t\tb:String,\r\n\t\t\tc:Number,\r\n\t\t\td:Boolean,\r\n\t\t\te: {\r\n\t\t\t\tf:String,\r\n\t\t\t\tg:Boolean,\r\n\t\t\t\th:[\r\n\t\t\t\t\tNumber,\r\n\t\t\t\t\tNumber,\r\n\t\t\t\t\tString\r\n\t\t\t\t]\r\n\t\t\t},\r\n\t\t\ti:\"noise\"\r\n\t\t}));\r\n\r\n\t\tassert.ok(example.contains({\r\n\t\t\ta:Object,\r\n\t\t\tb:String,\r\n\t\t\tc:Number,\r\n\t\t\td:Boolean,\r\n\t\t\te: {\r\n\t\t\t\tf:String,\r\n\t\t\t\tg:Boolean,\r\n\t\t\t\th:[\r\n\t\t\t\t\tNumber\r\n\t\t\t\t]\r\n\t\t\t}\r\n\t\t}))\r\n\t});\r\n\r\n\tit('should detect a negative match', ()=>\r\n\t{\r\n\t\tassert.ok(!example.contains({\r\n\t\t\ta:Object,\r\n\t\t\tb:String,\r\n\t\t\tc:Number,\r\n\t\t\td:Boolean,\r\n\t\t\te: {\r\n\t\t\t\tf:String,\r\n\t\t\t\tg:Boolean,\r\n\t\t\t\th:[\r\n\t\t\t\t\tNumber,\r\n\t\t\t\t\tBoolean,\r\n\t\t\t\t\tString\r\n\t\t\t\t]\r\n\t\t\t}\r\n\t\t}));\r\n\r\n\t\tassert.ok(!example.contains({\r\n\t\t\ta:Object,\r\n\t\t\tb:String,\r\n\t\t\tc:Number,\r\n\t\t\td:Boolean,\r\n\t\t\te: {\r\n\t\t\t\tf:String,\r\n\t\t\t\tg:Boolean,\r\n\t\t\t\th:[\r\n\t\t\t\t\tString\r\n\t\t\t\t]\r\n\t\t\t}\r\n\t\t}));\r\n\r\n\r\n\t\tassert.ok(!example.contains({\r\n\t\t\ta:Object,\r\n\t\t\tb:String,\r\n\t\t\tc:Number,\r\n\t\t\td:Boolean,\r\n\t\t\te: {\r\n\t\t\t\tf:String,\r\n\t\t\t\tg:Boolean,\r\n\t\t\t\th:[\r\n\t\t\t\t\tNumber\r\n\t\t\t\t]\r\n\t\t\t},\r\n\t\t\ti:\"goo\"\r\n\t\t}));\r\n\r\n\t\tassert.ok(!example.contains({\r\n\t\t\ta:Object,\r\n\t\t\tb:String,\r\n\t\t\tc:Number,\r\n\t\t\td:Boolean,\r\n\t\t\te: {\r\n\t\t\t\tf:String,\r\n\t\t\t\tg:Boolean,\r\n\t\t\t\th:[\r\n\t\t\t\t\tNumber\r\n\t\t\t\t]\r\n\t\t\t},\r\n\t\t\ti:Boolean\r\n\t\t}));\r\n\t});\r\n});\r\n"]} \ No newline at end of file diff --git a/tests/mocha/System/TypeValidator.ts b/tests/mocha/System/TypeValidator.ts index e8b7cf85..e66b0940 100644 --- a/tests/mocha/System/TypeValidator.ts +++ b/tests/mocha/System/TypeValidator.ts @@ -24,6 +24,18 @@ describe('.contains(descriptor)', ()=> { it('should detect a positive match', ()=> { + assert.ok(example.contains({ + a:Object, + b:String, + c:Number, + d:Boolean, + e: { + f:String, + g:Boolean, + h:Array + } + })); + assert.ok(example.contains({ a:Object, b:String,