diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /devtools/client/shared/test/unit/test_attribute-parsing-01.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/client/shared/test/unit/test_attribute-parsing-01.js')
-rw-r--r-- | devtools/client/shared/test/unit/test_attribute-parsing-01.js | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/devtools/client/shared/test/unit/test_attribute-parsing-01.js b/devtools/client/shared/test/unit/test_attribute-parsing-01.js new file mode 100644 index 000000000..b6b1a301d --- /dev/null +++ b/devtools/client/shared/test/unit/test_attribute-parsing-01.js @@ -0,0 +1,73 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Test splitBy from node-attribute-parser.js + +const {require} = Components.utils.import("resource://devtools/shared/Loader.jsm", {}); +const {splitBy} = require("devtools/client/shared/node-attribute-parser"); + +const TEST_DATA = [{ + value: "this is a test", + splitChar: " ", + expected: [ + {value: "this"}, + {value: " ", type: "string"}, + {value: "is"}, + {value: " ", type: "string"}, + {value: "a"}, + {value: " ", type: "string"}, + {value: "test"} + ] +}, { + value: "/path/to/handler", + splitChar: " ", + expected: [ + {value: "/path/to/handler"} + ] +}, { + value: "test", + splitChar: " ", + expected: [ + {value: "test"} + ] +}, { + value: " test ", + splitChar: " ", + expected: [ + {value: " ", type: "string"}, + {value: "test"}, + {value: " ", type: "string"} + ] +}, { + value: "", + splitChar: " ", + expected: [] +}, { + value: " ", + splitChar: " ", + expected: [ + {value: " ", type: "string"}, + {value: " ", type: "string"}, + {value: " ", type: "string"} + ] +}]; + +function run_test() { + for (let {value, splitChar, expected} of TEST_DATA) { + do_print("Splitting string: " + value); + let tokens = splitBy(value, splitChar); + + do_print("Checking that the number of parsed tokens is correct"); + do_check_eq(tokens.length, expected.length); + + for (let i = 0; i < tokens.length; i++) { + do_print("Checking the data in token " + i); + do_check_eq(tokens[i].value, expected[i].value); + if (expected[i].type) { + do_check_eq(tokens[i].type, expected[i].type); + } + } + } +} |