Skip to content

Commit

Permalink
Another pass at de-linting tuneup
Browse files Browse the repository at this point in the history
This fixes the 'double-else' problem found in issue #37
from 16a0344. I also found a couple of other lint complaints
and fixed them up.
  • Loading branch information
radiantcapsule committed Oct 29, 2012
1 parent 16a0344 commit 0ba42d1
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
18 changes: 9 additions & 9 deletions assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function fail(message) {

/**
* Perform an assertion several times. If the assertion passes before the
* maximum number of iterations, the assertion passes. Otherwise the
* maximum number of iterations, the assertion passes. Otherwise the
* assertion fails
* @param f The function to perform (possibly) multiple times
* @param maxTries (optional) The maximum number of attempts
Expand Down Expand Up @@ -54,7 +54,7 @@ function assertTrue(expression, message) {
}

/**
* Asserts that the given regular expression matches the result of the
* Asserts that the given regular expression matches the result of the
* given message.
* @param pattern - the pattern to match
* @param expression - the expression to match against
Expand Down Expand Up @@ -86,7 +86,7 @@ function assertNotEquals(expected, received, message) {
}

/**
* Asserts that the given expression is false and otherwise throws an
* Asserts that the given expression is false and otherwise throws an
* exception with a default message, or the optional +message+ parameter
*/
function assertFalse(expression, message) {
Expand All @@ -100,7 +100,7 @@ function assertFalse(expression, message) {
* +message+ parameter.
*/
function assertNull(thingie, message) {
var defMessage = "Expected a null object, but received <" + thingie + ">";
var defMessage = "Expected a null object, but received <" + thingie + ">";
// TODO: string-matching on UIAElementNil makes my tummy feel bad. Fix it.
assertTrue(thingie === null || thingie.toString() == "[object UIAElementNil]",
message ? message + ": " + defMessage : defMessage);
Expand All @@ -113,7 +113,7 @@ function assertNull(thingie, message) {
*/
function assertNotNull(thingie, message) {
var defMessage = "Expected not null object";
assertTrue(thingie !== null && thingie.toString() != "[object UIAElementNil]",
assertTrue(thingie !== null && thingie.toString() != "[object UIAElementNil]",
message ? message + ": " + defMessage : defMessage);
}

Expand Down Expand Up @@ -174,7 +174,7 @@ function assertElementTree(element, definition) {
* PROPERTY MATCHERS For each property you wish to make an assertion about, you
* can specify a string, number regular expression or function. Strings and
* numbers are matches using the assertEquals() method. Regular expressions are
* matches using the assertMatch() method.
* matches using the assertMatch() method.
*
* If you specify 'null' for a property, it means you don't care to match.
* Typically this is done inside of arrays where you need to match the number
Expand Down Expand Up @@ -246,12 +246,12 @@ function assertWindow(window) {
application = target.frontMostApp();
mainWindow = application.mainWindow();

assertElementTree(mainWindow, window)
assertElementTree(mainWindow, window);
}

/**
* Asserts that the +expected+ object matches the +given+ object by making
* assertions appropriate based on the type of each property in the
* assertions appropriate based on the pe of each property in the
* +expected+ object. This method will recurse through the structure,
* applying assertions for each matching property path. See the description
* for +assertWindow+ for details on the matchers.
Expand Down Expand Up @@ -279,7 +279,7 @@ function assertPropertiesMatch(expected, given, level) {

if (typeof(givenProp) == "function") {
try {
// We have to use eval (shudder) because calling functions on
// We have to use eval (shudder) because calling functions on
// UIAutomation objects with () operator crashes
// See Radar bug 8496138
givenProp = eval("given." + propName + "()");
Expand Down
4 changes: 2 additions & 2 deletions lang-ext.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function extend(destination, source) {
destination[property] = source[property];
}
return destination;
};
}

/**
* Dump the properties out a String returned by the function.
Expand All @@ -15,7 +15,7 @@ function dumpProperties(obj) {
var dumpStr = "";
for (var propName in obj) {
if (obj.hasOwnProperty(propName)) {
if (dumpStr != "") {
if (dumpStr !== "") {
dumpStr += ", ";
}
dumpStr += (propName + "=" + obj[propName]);
Expand Down
2 changes: 1 addition & 1 deletion screen.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Screen = {
screens: new Object(),
screens: {},

add: function(name, definition) {
this.screens[name] = definition;
Expand Down
4 changes: 2 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* a +UIApplication+ object which it can use to exercise and validate your
* application.
*
* The +options+ parameter is an optional object/hash thingie that
* The +options+ parameter is an optional object/hash thingie that
* supports the following:
* logTree -- a boolean to log the element tree when the test fails (default 'true')
*
Expand All @@ -16,7 +16,7 @@
*
*/
function test(title, f, options) {
if (options == null) {
if (options === null) {
options = {
logTree: true
};
Expand Down
14 changes: 7 additions & 7 deletions uiautomation-ext.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ extend(UIATableView.prototype, {
extend(UIAElement.prototype, {
// Poll till the item becomes visible, up to a specified timeout
waitUntilVisible: function (timeoutInSeconds) {
timeoutInSeconds = timeoutInSeconds == null ? 5 : timeoutInSeconds;
timeoutInSeconds = timeoutInSeconds === null ? 5 : timeoutInSeconds;
var element = this;
var delay = 0.25;
retry(function() {
retry(function() {
if(!element.isVisible()) {
throw("Element (" + element + ") didn't become visible within " + timeoutInSeconds + " seconds.");
}
Expand Down Expand Up @@ -173,14 +173,14 @@ extend(UIAKeyboard.prototype,{
TODO: Character keyboard is super slow.
*/
var typeString = function(pstrString, pbClear) {
pstrString += ''; // convert number to string
pstrString += ''; // convert number to string
if (!this.hasKeyboardFocus()){
this.tap();
}

UIATarget.localTarget().delay(0.5);

if (pbClear || pstrString.length == 0) {
if (pbClear || pstrString.length === 0) {
this.clear();
}

Expand Down Expand Up @@ -219,9 +219,9 @@ var typeString = function(pstrString, pbClear) {
strChar = "9";
} else {
strChar = "10";
} else {
strChar = (parseInt(strChar) - 1).toString();
}
} else {
strChar = (parseInt(strChar, 10) - 1).toString();
}
keys[strChar].tap();
} else {
Expand All @@ -233,7 +233,7 @@ var typeString = function(pstrString, pbClear) {
};

extend(UIATextField.prototype,{
typeString: typeString,
typeString: typeString
});
extend(UIATextView.prototype,{
typeString: typeString
Expand Down

0 comments on commit 0ba42d1

Please sign in to comment.