-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds assignment to var statement, isFinite, parseInt & parseFloat
- Also cleans up casts, and adds handling for Object & Functions casting
- Loading branch information
1 parent
2042c00
commit bd5dcba
Showing
14 changed files
with
175 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
// test_assignment.js | ||
// ------------------ | ||
|
||
x = 0; | ||
var x = 0; | ||
|
||
x += 4; | ||
console.assert(x == 4); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
// test_calls.js | ||
// ------------- | ||
|
||
myObject = { | ||
var myObject = { | ||
myMethod: function() { | ||
return 42; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,41 @@ | ||
// test_functions.js | ||
// ----------------- | ||
|
||
assertEquals = function(a, b) { | ||
var assertEquals = function(a, b) { | ||
return console.assert(a == b); | ||
}; | ||
|
||
add = function(a, b) { | ||
var add = function(a, b) { | ||
return a + b; | ||
}; | ||
|
||
square = function(x) { | ||
var square = function(x) { | ||
return x * x; | ||
}; | ||
|
||
incrementSquare = function(x) { | ||
var incrementSquare = function(x) { | ||
return add(square(x), 1); | ||
}; | ||
|
||
recursive = function(x) { | ||
var recursive1 = function(x) { | ||
if (x < 10) { | ||
x = x + 1; | ||
return arguments.callee(x); | ||
} | ||
return x; | ||
}; | ||
|
||
var recursive2 = function(x) { | ||
if (x < 10) { | ||
x = x + 1; | ||
return recursive2(x); | ||
} | ||
return x; | ||
}; | ||
|
||
assertEquals(square(3), 9); | ||
assertEquals(add(2, 2), 4); | ||
assertEquals(incrementSquare(9), 82); | ||
assertEquals(incrementSquare(20), 401); | ||
assertEquals(recursive(1), 10); | ||
assertEquals(recursive1(1), 10); | ||
assertEquals(recursive2(1), 10); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// test_globals.js | ||
// --------------- | ||
// Test methods and properties on the global object. | ||
|
||
var assert = console.assert; | ||
|
||
assert(isFinite(42)); | ||
assert(!isFinite(undefined)); | ||
assert(!isFinite(NaN)); | ||
|
||
assert(isNaN(NaN)); | ||
assert(isNaN(undefined)); | ||
assert(!isNaN(12)); | ||
assert(!isNaN(null)); | ||
|
||
assert(undefined === undefined); | ||
|
||
assert(this); |
Oops, something went wrong.