a bunch of UI changes, some haxedoc work
This commit is contained in:
parent
4b1fb36789
commit
22c596b1f9
@ -18,13 +18,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div id="output"></div>
|
<div id="output"></div>
|
||||||
<div id="permanent-ignore" style="display: none">
|
<div id="permanent-ignore" style="display: none">
|
||||||
To permanently ignore tokens, do one of the following:
|
To permanently ignore tokens (and globally ignore modules), do one of the following:
|
||||||
<ul>
|
<ul>
|
||||||
<li>To ignore globally, place at the top of the file on its own line:
|
<li>To ignore globally, place at the top of the file on its own line:
|
||||||
<blockquote><code>//harmonious <span class="ignore-code-holder"></span></code></blockquote>
|
<blockquote><code>//harmonious <span id="ignore-code-holder-global"></span></code></blockquote>
|
||||||
</li>
|
</li>
|
||||||
<li>To ignore within a particular block of code, wrap the code in the following:
|
<li id="permanent-ignore-block">To ignore within a particular block of code, wrap the code in the following:
|
||||||
<blockquote><code>//harmonious <span class="ignore-code-holder"></span><br />
|
<blockquote><code>//harmonious <span id="ignore-code-holder-block"></span><br />
|
||||||
...your code...<br />
|
...your code...<br />
|
||||||
//harmonious_end</code></blockquote>
|
//harmonious_end</code></blockquote>
|
||||||
</li>
|
</li>
|
||||||
|
@ -23,7 +23,8 @@ div#loading {
|
|||||||
}
|
}
|
||||||
|
|
||||||
table {
|
table {
|
||||||
border-left: solid #aaa 1px
|
border-left: solid #aaa 1px;
|
||||||
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
td, th {
|
td, th {
|
||||||
@ -34,7 +35,8 @@ td {
|
|||||||
padding: 0 3px
|
padding: 0 3px
|
||||||
}
|
}
|
||||||
|
|
||||||
td.token {
|
td.token,
|
||||||
|
td.module {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-weight: bold
|
font-weight: bold
|
||||||
}
|
}
|
||||||
|
@ -178,12 +178,7 @@ class CodeVersionInformation {
|
|||||||
this.all_modules.push(source);
|
this.all_modules.push(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.all_modules.sort(function(a, b) {
|
this.all_modules.sort(CodeVersionInformation.module_name_sorter);
|
||||||
if (a == "PHP") { return -1; }
|
|
||||||
if (b == "PHP") { return -1; }
|
|
||||||
if (a == b) { return 0; }
|
|
||||||
return (a < b) ? -1 : 1;
|
|
||||||
});
|
|
||||||
|
|
||||||
for (source in start_maximum_versions.keys()) {
|
for (source in start_maximum_versions.keys()) {
|
||||||
this.maximum_versions.set(source, get_lowest_version(start_maximum_versions.get(source)));
|
this.maximum_versions.set(source, get_lowest_version(start_maximum_versions.get(source)));
|
||||||
@ -195,6 +190,10 @@ class CodeVersionInformation {
|
|||||||
this.final_versions.set("maximum", maximum_versions);
|
this.final_versions.set("maximum", maximum_versions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Return true if the minimum and maximum module versions within this
|
||||||
|
CodeVersionInformation object will produce runnable code.
|
||||||
|
**/
|
||||||
public function is_valid() {
|
public function is_valid() {
|
||||||
for (source in this.maximum_versions.keys()) {
|
for (source in this.maximum_versions.keys()) {
|
||||||
var versions = [ this.maximum_versions.get(source), this.minimum_versions.get(source) ];
|
var versions = [ this.maximum_versions.get(source), this.minimum_versions.get(source) ];
|
||||||
@ -205,4 +204,14 @@ class CodeVersionInformation {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sort module names, making sure PHP is first in the list.
|
||||||
|
**/
|
||||||
|
public static function module_name_sorter(a : String, b : String) : Int {
|
||||||
|
if (a.toLowerCase() == "php") { return -1; }
|
||||||
|
if (b.toLowerCase() == "php") { return 1; }
|
||||||
|
if (a == b) { return 0; }
|
||||||
|
return (a < b) ? -1 : 1;
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,8 +1,12 @@
|
|||||||
|
/**
|
||||||
|
The JavaScript functionality of Harmonious Code.
|
||||||
|
**/
|
||||||
class JavaScriptTarget {
|
class JavaScriptTarget {
|
||||||
static public var code_parser : CodeParser;
|
static public var code_parser : CodeParser;
|
||||||
static public var current_results : Array<Result>;
|
static public var current_results : Array<Result>;
|
||||||
static public var show_only_modules : Hash<Bool>;
|
static public var show_only_modules : Hash<Bool>;
|
||||||
static public var ignored_modules : Hash<Bool>;
|
static public var ignored_modules : Hash<Bool>;
|
||||||
|
static public var manually_ignored_modules : Hash<Bool>;
|
||||||
|
|
||||||
static public function main() {
|
static public function main() {
|
||||||
var function_token = new FunctionToken("a","a");
|
var function_token = new FunctionToken("a","a");
|
||||||
@ -12,6 +16,7 @@ class JavaScriptTarget {
|
|||||||
|
|
||||||
show_only_modules = new Hash<Bool>();
|
show_only_modules = new Hash<Bool>();
|
||||||
ignored_modules = new Hash<Bool>();
|
ignored_modules = new Hash<Bool>();
|
||||||
|
manually_ignored_modules = new Hash<Bool>();
|
||||||
|
|
||||||
#if js
|
#if js
|
||||||
var loading_div = js.Lib.document.getElementById("loading");
|
var loading_div = js.Lib.document.getElementById("loading");
|
||||||
@ -22,11 +27,18 @@ class JavaScriptTarget {
|
|||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Parse a String and get the token results and ignored modules.
|
||||||
|
**/
|
||||||
static public function get_results(s : String) {
|
static public function get_results(s : String) {
|
||||||
current_results = code_parser.parse(s);
|
current_results = code_parser.parse(s);
|
||||||
ignored_modules = code_parser.ignored_modules;
|
ignored_modules = code_parser.ignored_modules;
|
||||||
|
manually_ignored_modules = new Hash<Bool>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Enable/disable a particular Result from the version calculations.
|
||||||
|
**/
|
||||||
static public function change_result(index_id : Int, state : Bool) : Bool {
|
static public function change_result(index_id : Int, state : Bool) : Bool {
|
||||||
if (index_id < current_results.length) {
|
if (index_id < current_results.length) {
|
||||||
current_results[index_id].is_enabled = state;
|
current_results[index_id].is_enabled = state;
|
||||||
@ -35,6 +47,9 @@ class JavaScriptTarget {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Toggle the visibility of module functions.
|
||||||
|
**/
|
||||||
static public function toggle_module(module : String) {
|
static public function toggle_module(module : String) {
|
||||||
if (!show_only_modules.exists(module)) {
|
if (!show_only_modules.exists(module)) {
|
||||||
show_only_modules.set(module, false);
|
show_only_modules.set(module, false);
|
||||||
@ -42,15 +57,21 @@ class JavaScriptTarget {
|
|||||||
show_only_modules.set(module, !show_only_modules.get(module));
|
show_only_modules.set(module, !show_only_modules.get(module));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set the ignore state on a module.
|
||||||
|
**/
|
||||||
static public function change_module_ignore(module : String, state : Bool) {
|
static public function change_module_ignore(module : String, state : Bool) {
|
||||||
ignored_modules.set(module, state);
|
manually_ignored_modules.set(module, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function toggle_ignore_module(module: String) {
|
/**
|
||||||
if (!ignored_modules.exists(module)) {
|
Toggle ignoring a module.
|
||||||
ignored_modules.set(module, false);
|
**/
|
||||||
|
static public function toggle_ignore_module(module : String) {
|
||||||
|
if (!manually_ignored_modules.exists(module)) {
|
||||||
|
manually_ignored_modules.set(module, false);
|
||||||
}
|
}
|
||||||
ignored_modules.set(module, !ignored_modules.get(module));
|
manually_ignored_modules.set(module, !manually_ignored_modules.get(module));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if js
|
#if js
|
||||||
@ -75,11 +96,71 @@ class JavaScriptTarget {
|
|||||||
|
|
||||||
output += "<ul>";
|
output += "<ul>";
|
||||||
|
|
||||||
for (module in minimum.keys()) {
|
var all_modules_hash = new Hash<Bool>();
|
||||||
output += "<li>" + module + ": " + minimum.get(module) + "</li>";
|
|
||||||
|
for (module in minimum.keys()) { all_modules_hash.set(module, true); }
|
||||||
|
for (module in ignored_modules.keys()) { all_modules_hash.set(module, true); }
|
||||||
|
for (module in manually_ignored_modules.keys()) { all_modules_hash.set(module, true); }
|
||||||
|
|
||||||
|
var all_modules = new Array<String>();
|
||||||
|
|
||||||
|
for (module in all_modules_hash.keys()) { all_modules.push(module); }
|
||||||
|
|
||||||
|
all_modules.sort(CodeVersionInformation.module_name_sorter);
|
||||||
|
|
||||||
|
var ignored_tokens = new Array<String>();
|
||||||
|
var ignored_modules_array = new Array<String>();
|
||||||
|
for (module in manually_ignored_modules.keys()) {
|
||||||
|
if (manually_ignored_modules.get(module) == true) {
|
||||||
|
ignored_modules_array.push("@" + module);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
output += "</ul>";
|
output += "<table cellspacing=\"0\" id=\"modules\">";
|
||||||
|
output += "<tr><th>Module</th><th>Ignore?</th><th>Version</th></tr>";
|
||||||
|
|
||||||
|
for (module in all_modules) {
|
||||||
|
var is_ignored = false;
|
||||||
|
var is_ignored_in_source = false;
|
||||||
|
var show_checkbox = true;
|
||||||
|
var is_checked = false;
|
||||||
|
|
||||||
|
if (ignored_modules.exists(module) == true) {
|
||||||
|
is_ignored = true;
|
||||||
|
is_ignored_in_source = true;
|
||||||
|
show_checkbox = false;
|
||||||
|
}
|
||||||
|
if (manually_ignored_modules.get(module) == true) {
|
||||||
|
is_ignored = true;
|
||||||
|
is_checked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
output += "<tr class=\"" + (is_ignored ? "disabled" : "enabled") + "\"><td class=\"module\">" + module + "</td>";
|
||||||
|
|
||||||
|
if (show_checkbox && (module.toLowerCase() != "php")) {
|
||||||
|
output += "<td align=\"center\"><input type=\"checkbox\" name=\"ignore-module-" + module + "\" id=\"ignore-module-" + module + "\" onclick=\"JavaScriptTarget.toggle_ignore_module_and_redraw('" + module + "')\" " + (is_checked ? " checked" : "") + "/></td>";
|
||||||
|
} else {
|
||||||
|
output += "<td> </td>";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_ignored) {
|
||||||
|
if (is_ignored_in_source) {
|
||||||
|
output += "<td>(ignored in source)</td>";
|
||||||
|
} else {
|
||||||
|
output += "<td>(ignored)</td>";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (minimum.exists(module)) {
|
||||||
|
output += "<td>" + minimum.get(module) + "</td>";
|
||||||
|
} else {
|
||||||
|
output += "<td> </td>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
output += "</tr>";
|
||||||
|
}
|
||||||
|
|
||||||
|
output += "</table>";
|
||||||
|
|
||||||
var maximum = version_info.final_versions.get("maximum");
|
var maximum = version_info.final_versions.get("maximum");
|
||||||
var printed_message = false;
|
var printed_message = false;
|
||||||
@ -109,13 +190,14 @@ class JavaScriptTarget {
|
|||||||
classes.push("is-filtering");
|
classes.push("is-filtering");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (manually_ignored_modules.get(module) != true) {
|
||||||
output += "<th title=\"click to toggle filter\" class=\"" + classes.join(" ") + "\" onclick=\"JavaScriptTarget.toggle_module_and_redraw('" + module + "')\">" + module + "</th>";
|
output += "<th title=\"click to toggle filter\" class=\"" + classes.join(" ") + "\" onclick=\"JavaScriptTarget.toggle_module_and_redraw('" + module + "')\">" + module + "</th>";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
output += "</tr>";
|
output += "</tr>";
|
||||||
|
|
||||||
var ignored_tokens = new Array<String>();
|
|
||||||
|
|
||||||
var id_index = 0;
|
var id_index = 0;
|
||||||
for (result in current_results) {
|
for (result in current_results) {
|
||||||
var ok_to_show = true;
|
var ok_to_show = true;
|
||||||
@ -156,6 +238,7 @@ class JavaScriptTarget {
|
|||||||
+ ((!result.is_enabled) ? " checked" : "") + " /></td>";
|
+ ((!result.is_enabled) ? " checked" : "") + " /></td>";
|
||||||
|
|
||||||
for (module in version_info.all_modules) {
|
for (module in version_info.all_modules) {
|
||||||
|
if (manually_ignored_modules.get(module) != true) {
|
||||||
output += "<td>";
|
output += "<td>";
|
||||||
if (max_versions.exists(module)) {
|
if (max_versions.exists(module)) {
|
||||||
output += max_versions.get(module);
|
output += max_versions.get(module);
|
||||||
@ -164,23 +247,36 @@ class JavaScriptTarget {
|
|||||||
}
|
}
|
||||||
output += "</td>";
|
output += "</td>";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
output += "</tr>";
|
output += "</tr>";
|
||||||
id_index++;
|
|
||||||
}
|
}
|
||||||
|
id_index++;
|
||||||
}
|
}
|
||||||
output += "</table>";
|
output += "</table>";
|
||||||
|
|
||||||
output += "</form>";
|
output += "</form>";
|
||||||
|
|
||||||
var permanent_ignore_div = js.Lib.document.getElementById('permanent-ignore');
|
var permanent_ignore_div = js.Lib.document.getElementById("permanent-ignore");
|
||||||
|
|
||||||
|
if ((ignored_modules_array.length > 0) || (ignored_tokens.length > 0)) {
|
||||||
|
var ignored_modules_string = ignored_modules_array.join(" ");
|
||||||
|
var ignored_tokens_string = ignored_tokens.join(" ");
|
||||||
|
|
||||||
|
var global_span = js.Lib.document.getElementById("ignore-code-holder-global");
|
||||||
|
global_span.innerHTML = ignored_modules_string + " " + ignored_tokens_string;
|
||||||
|
|
||||||
|
var permanent_ignore_block_li = js.Lib.document.getElementById("permanent-ignore-block");
|
||||||
|
|
||||||
if (ignored_tokens.length > 0) {
|
if (ignored_tokens.length > 0) {
|
||||||
var spans = js.Lib.document.getElementsByTagName("span");
|
var block_span = js.Lib.document.getElementById("ignore-code-holder-block");
|
||||||
for (span_index in 0...spans.length) {
|
block_span.innerHTML = ignored_tokens_string;
|
||||||
if (spans[span_index].className == "ignore-code-holder") {
|
|
||||||
spans[span_index].innerHTML = ignored_tokens.join(" ");
|
permanent_ignore_block_li.style.display = "";
|
||||||
}
|
} else {
|
||||||
|
permanent_ignore_block_li.style.display = "none";
|
||||||
}
|
}
|
||||||
|
|
||||||
permanent_ignore_div.style.display = "";
|
permanent_ignore_div.style.display = "";
|
||||||
} else {
|
} else {
|
||||||
permanent_ignore_div.style.display = "none";
|
permanent_ignore_div.style.display = "none";
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
|
/**
|
||||||
|
Test the CodeVersionInformation object.
|
||||||
|
**/
|
||||||
class TestCodeVersionInformation extends haxe.unit.TestCase {
|
class TestCodeVersionInformation extends haxe.unit.TestCase {
|
||||||
function testIsInvalid() {
|
/**
|
||||||
|
Test is_invalid()
|
||||||
|
**/
|
||||||
|
function test_is_invalid() {
|
||||||
var valid_results = [
|
var valid_results = [
|
||||||
new Result(ResultType.Function, "one", "PHP 4, PHP 5"),
|
new Result(ResultType.Function, "one", "PHP 4, PHP 5"),
|
||||||
new Result(ResultType.Function, "two", "PHP 4 <= 4.2.0")
|
new Result(ResultType.Function, "two", "PHP 4 <= 4.2.0")
|
||||||
@ -17,7 +23,10 @@ class TestCodeVersionInformation extends haxe.unit.TestCase {
|
|||||||
assertFalse(code_version_info.is_valid());
|
assertFalse(code_version_info.is_valid());
|
||||||
}
|
}
|
||||||
|
|
||||||
function testBreakdownVersionString() {
|
/**
|
||||||
|
Test breakdown_version_string()
|
||||||
|
**/
|
||||||
|
function test_breakdown_version_string() {
|
||||||
assertEquals("[PHP, 4]", CodeVersionInformation.breakdown_php_version_string("PHP 4").toString());
|
assertEquals("[PHP, 4]", CodeVersionInformation.breakdown_php_version_string("PHP 4").toString());
|
||||||
assertEquals("[PHP, 5.2.0]", CodeVersionInformation.breakdown_php_version_string("PHP 5 >= 5.2.0").toString());
|
assertEquals("[PHP, 5.2.0]", CodeVersionInformation.breakdown_php_version_string("PHP 5 >= 5.2.0").toString());
|
||||||
assertEquals("[xmlwriter, 2.0.4]", CodeVersionInformation.breakdown_php_version_string("xmlwriter 2.0.4").toString());
|
assertEquals("[xmlwriter, 2.0.4]", CodeVersionInformation.breakdown_php_version_string("xmlwriter 2.0.4").toString());
|
||||||
@ -25,7 +34,10 @@ class TestCodeVersionInformation extends haxe.unit.TestCase {
|
|||||||
assertEquals("[xmlwriter, 0.1]", CodeVersionInformation.breakdown_php_version_string("xmlwriter 0.1-2.0.4").toString());
|
assertEquals("[xmlwriter, 0.1]", CodeVersionInformation.breakdown_php_version_string("xmlwriter 0.1-2.0.4").toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
function testVersionCompare() {
|
/**
|
||||||
|
Test version_compare()
|
||||||
|
**/
|
||||||
|
function test_version_compare() {
|
||||||
assertEquals(-1, CodeVersionInformation.version_compare("4", "5"));
|
assertEquals(-1, CodeVersionInformation.version_compare("4", "5"));
|
||||||
assertEquals(1, CodeVersionInformation.version_compare("5", "4"));
|
assertEquals(1, CodeVersionInformation.version_compare("5", "4"));
|
||||||
assertEquals(-1, CodeVersionInformation.version_compare("4", "4.5"));
|
assertEquals(-1, CodeVersionInformation.version_compare("4", "4.5"));
|
||||||
@ -34,26 +46,38 @@ class TestCodeVersionInformation extends haxe.unit.TestCase {
|
|||||||
assertEquals(-1, CodeVersionInformation.version_compare("4.5", "4.10"));
|
assertEquals(-1, CodeVersionInformation.version_compare("4.5", "4.10"));
|
||||||
}
|
}
|
||||||
|
|
||||||
function testGetHighestVersion() {
|
/**
|
||||||
|
Test get_highest_version()
|
||||||
|
**/
|
||||||
|
function test_get_highest_version() {
|
||||||
assertEquals("5.2.0", CodeVersionInformation.get_highest_version(["5.2.0"]));
|
assertEquals("5.2.0", CodeVersionInformation.get_highest_version(["5.2.0"]));
|
||||||
assertEquals("5.2.0", CodeVersionInformation.get_highest_version(["5.1.0", "5.2.0"]));
|
assertEquals("5.2.0", CodeVersionInformation.get_highest_version(["5.1.0", "5.2.0"]));
|
||||||
assertEquals("5", CodeVersionInformation.get_highest_version(["4", "4.1", "5"]));
|
assertEquals("5", CodeVersionInformation.get_highest_version(["4", "4.1", "5"]));
|
||||||
}
|
}
|
||||||
|
|
||||||
function testGetLowestVersion() {
|
/**
|
||||||
|
Test get_lowest_version()
|
||||||
|
**/
|
||||||
|
function test_get_lowest_version() {
|
||||||
assertEquals("5.2.0", CodeVersionInformation.get_lowest_version(["5.2.0"]));
|
assertEquals("5.2.0", CodeVersionInformation.get_lowest_version(["5.2.0"]));
|
||||||
assertEquals("5.1.0", CodeVersionInformation.get_lowest_version(["5.1.0", "5.2.0"]));
|
assertEquals("5.1.0", CodeVersionInformation.get_lowest_version(["5.1.0", "5.2.0"]));
|
||||||
assertEquals("4", CodeVersionInformation.get_lowest_version(["4", "4.1", "5"]));
|
assertEquals("4", CodeVersionInformation.get_lowest_version(["4", "4.1", "5"]));
|
||||||
assertEquals("4.0.6", CodeVersionInformation.get_lowest_version(["4.0.6", "5"]));
|
assertEquals("4.0.6", CodeVersionInformation.get_lowest_version(["4.0.6", "5"]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Test get_version_lower_than()
|
||||||
|
**/
|
||||||
function testGetVersionLowerThan() {
|
function testGetVersionLowerThan() {
|
||||||
assertEquals(null, CodeVersionInformation.get_version_lower_than("PHP 5"));
|
assertEquals(null, CodeVersionInformation.get_version_lower_than("PHP 5"));
|
||||||
assertEquals(null, CodeVersionInformation.get_version_lower_than("PHP 5 >= 5.2.0"));
|
assertEquals(null, CodeVersionInformation.get_version_lower_than("PHP 5 >= 5.2.0"));
|
||||||
assertEquals("4.0.4", CodeVersionInformation.get_version_lower_than("PHP 4 <= 4.0.4"));
|
assertEquals("4.0.4", CodeVersionInformation.get_version_lower_than("PHP 4 <= 4.0.4"));
|
||||||
}
|
}
|
||||||
|
|
||||||
function testCreate() {
|
/**
|
||||||
|
Test instantiating a CodeVersionInformation object
|
||||||
|
**/
|
||||||
|
function test_create() {
|
||||||
var valid_results = [
|
var valid_results = [
|
||||||
new Result(ResultType.Function, "one", "PHP 4, PHP 5"),
|
new Result(ResultType.Function, "one", "PHP 4, PHP 5"),
|
||||||
new Result(ResultType.Function, "two", "PHP 4 >= 4.0.6, PHP 5"),
|
new Result(ResultType.Function, "two", "PHP 4 >= 4.0.6, PHP 5"),
|
||||||
@ -68,13 +92,19 @@ class TestCodeVersionInformation extends haxe.unit.TestCase {
|
|||||||
assertEquals("4", v.minimum_versions.get("PHP"));
|
assertEquals("4", v.minimum_versions.get("PHP"));
|
||||||
}
|
}
|
||||||
|
|
||||||
function testGetVersionStringSplit() {
|
/**
|
||||||
|
Test split_version_string()
|
||||||
|
**/
|
||||||
|
function test_get_version_string_split() {
|
||||||
assertEquals("{xmlwriter => 2.0.4, PHP => 4}", CodeVersionInformation.split_version_string("PHP 4, xmlwriter 2.0.4").toString());
|
assertEquals("{xmlwriter => 2.0.4, PHP => 4}", CodeVersionInformation.split_version_string("PHP 4, xmlwriter 2.0.4").toString());
|
||||||
assertEquals("{xmlwriter => 2.0.4, PHP => 4.0.3}", CodeVersionInformation.split_version_string("PHP 4 >= 4.0.3, xmlwriter 2.0.4").toString());
|
assertEquals("{xmlwriter => 2.0.4, PHP => 4.0.3}", CodeVersionInformation.split_version_string("PHP 4 >= 4.0.3, xmlwriter 2.0.4").toString());
|
||||||
assertEquals("{PHP => 4}", CodeVersionInformation.split_version_string("PHP 5, PHP 4").toString());
|
assertEquals("{PHP => 4}", CodeVersionInformation.split_version_string("PHP 5, PHP 4").toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
function testGetModuleInformation() {
|
/**
|
||||||
|
Test getting module information
|
||||||
|
**/
|
||||||
|
function test_get_module_information() {
|
||||||
var valid_results = [
|
var valid_results = [
|
||||||
new Result(ResultType.Function, "one", "PHP 4, zmod 5"),
|
new Result(ResultType.Function, "one", "PHP 4, zmod 5"),
|
||||||
new Result(ResultType.Function, "two", "PHP 4 >= 4.0.6, xmod 5"),
|
new Result(ResultType.Function, "two", "PHP 4 >= 4.0.6, xmod 5"),
|
||||||
@ -84,7 +114,10 @@ class TestCodeVersionInformation extends haxe.unit.TestCase {
|
|||||||
assertEquals("[PHP, xmod, zmod]", v.all_modules.toString());
|
assertEquals("[PHP, xmod, zmod]", v.all_modules.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
function testIgnoreModules() {
|
/**
|
||||||
|
Test ignoring modules
|
||||||
|
**/
|
||||||
|
function test_ignore_modules() {
|
||||||
var valid_results = [
|
var valid_results = [
|
||||||
new Result(ResultType.Function, "one", "PHP 4, zmod 5"),
|
new Result(ResultType.Function, "one", "PHP 4, zmod 5"),
|
||||||
new Result(ResultType.Function, "two", "PHP 4 >= 4.0.6, xmod 5"),
|
new Result(ResultType.Function, "two", "PHP 4 >= 4.0.6, xmod 5"),
|
||||||
@ -96,4 +129,15 @@ class TestCodeVersionInformation extends haxe.unit.TestCase {
|
|||||||
|
|
||||||
assertEquals("[PHP, zmod]", v.all_modules.toString());
|
assertEquals("[PHP, zmod]", v.all_modules.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Test module name sorting
|
||||||
|
**/
|
||||||
|
function test_module_name_sorting() {
|
||||||
|
var module_names = [ "zmod", "xmod", "PHP" ];
|
||||||
|
|
||||||
|
module_names.sort(CodeVersionInformation.module_name_sorter);
|
||||||
|
|
||||||
|
assertEquals("[PHP, xmod, zmod]", module_names.toString());
|
||||||
|
}
|
||||||
}
|
}
|
@ -15,10 +15,10 @@ class TestJavaScriptTarget extends haxe.unit.TestCase {
|
|||||||
JavaScriptTarget.toggle_module("zip");
|
JavaScriptTarget.toggle_module("zip");
|
||||||
assertEquals("{zip => true}", JavaScriptTarget.show_only_modules.toString());
|
assertEquals("{zip => true}", JavaScriptTarget.show_only_modules.toString());
|
||||||
|
|
||||||
assertEquals("{}", JavaScriptTarget.ignored_modules.toString());
|
assertEquals("{}", JavaScriptTarget.manually_ignored_modules.toString());
|
||||||
JavaScriptTarget.change_module_ignore("zip", true);
|
JavaScriptTarget.change_module_ignore("zip", true);
|
||||||
assertEquals("{zip => true}", JavaScriptTarget.ignored_modules.toString());
|
assertEquals("{zip => true}", JavaScriptTarget.manually_ignored_modules.toString());
|
||||||
JavaScriptTarget.change_module_ignore("zip", false);
|
JavaScriptTarget.change_module_ignore("zip", false);
|
||||||
assertEquals("{zip => false}", JavaScriptTarget.ignored_modules.toString());
|
assertEquals("{zip => false}", JavaScriptTarget.manually_ignored_modules.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user