diff options
author | Jesper K. Pedersen <jesper.pedersen@kdab.com> | 2013-05-16 19:26:02 +0200 |
---|---|---|
committer | Jesper K. Pedersen <jesper.pedersen@kdab.com> | 2013-05-21 10:14:46 +0200 |
commit | 13ad623fdff541d028a74705ddf0a94f47092a56 (patch) | |
tree | c859be3b1683bccb235cc05ff7ce43a1bfcb8f24 /tests/qfileinfo/qfileinfo.qs | |
parent | d3880a67b1e9f6fa6a511498abe4fb79628235c9 (diff) |
implement a QFileInfo prototype so it can be used from scripts
Change-Id: I84755a64207d71451768981b725c1ce3bdeb0907
Reviewed-by: Nicolas Arnaud-Cormos <nicolas@kdab.com>
Diffstat (limited to 'tests/qfileinfo/qfileinfo.qs')
-rw-r--r-- | tests/qfileinfo/qfileinfo.qs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/qfileinfo/qfileinfo.qs b/tests/qfileinfo/qfileinfo.qs new file mode 100644 index 0000000..e061d2c --- /dev/null +++ b/tests/qfileinfo/qfileinfo.qs @@ -0,0 +1,36 @@ +include("../test.js") + +var absolute = new QFileInfo(utils.currentScripRoot + "/test.cpp") +var relative = new QFileInfo("relative") + +compare(absolute.exists, true) +compare(relative.exists, false) + +compare(relative.filePath, "relative") +assert(endsWith(absolute.filePath, "test.cpp"), "filePath for absolute files") + +assert(startsWith(relative.absoluteFilePath,"/")) +compare(absolute.fileName, "test.cpp") + +compare(absolute.isRelative, false) +compare(relative.isRelative, true) +compare(absolute.size, 61) + +assert(absolute.created.getFullYear() > 2012) + +var gotIt = false +try { + new QFileInfo() +} +catch(message) { + gotIt = true +} +assert(gotIt, "We should throw an error when constructing a QFileInfo without a file") + +function endsWith(str,pattern) { + return str.substr(str.length-pattern.length,pattern.length) == pattern +} + +function startsWith(str,pattern) { + return str.substr(0,pattern.length) == pattern +} |