[Laszlo-checkins] r10354 - in openlaszlo/trunk: WEB-INF/lps/lfc WEB-INF/lps/lfc/compiler WEB-INF/lps/lfc/debugger WEB-INF/lps/lfc/kernel/swf9 WEB-INF/lps/server/src/org/openlaszlo/compiler lps/components/lzunit test/lfc/data
hqm@openlaszlo.org
hqm at openlaszlo.org
Mon Jul 14 14:31:46 PDT 2008
Author: hqm
Date: 2008-07-14 14:31:40 -0700 (Mon, 14 Jul 2008)
New Revision: 10354
Added:
openlaszlo/trunk/WEB-INF/lps/lfc/compiler/LzMessage.lzs
Modified:
openlaszlo/trunk/WEB-INF/lps/lfc/LaszloLibrary.lzs
openlaszlo/trunk/WEB-INF/lps/lfc/compiler/Library.lzs
openlaszlo/trunk/WEB-INF/lps/lfc/compiler/LzFormatter.lzs
openlaszlo/trunk/WEB-INF/lps/lfc/debugger/swf9stubs.lzs
openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzHTTPLoader.as
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/DebugCompiler.java
openlaszlo/trunk/lps/components/lzunit/lzunit.lzx
openlaszlo/trunk/test/lfc/data/datanode.lzx
Log:
Change 20080714-hqm-i by hqm at badtzmaru.home on 2008-07-14 11:48:42 EDT
in /Users/hqm/openlaszlo/trunk4
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: get lzunit running in swf9
New Features:
Bugs Fixed:
Technical Reviewer: ptw
QA Reviewer: max
Doc Reviewer: (pending)
Documentation:
Release Notes:
Details:
+ NOTE: the $debug flag is currently set to false unconditionally by
the script compiler when compiling for swf9.
+ modified lzunit to use ...args instead of "arguments" for varargs
+ updated lzunit to not mess with toString method (comment in code said this
was a swf6 workaround)
+ made stub versions of LzMessage, LzSourceMessage, etc, for swf9,
just enough to print out properly in the lzunit display area. These
live in debugger/swf9stubs, which is always loaded for swf9
compilation (regardless of $debug flag)
+ made LzHTTPLoader have a load/error/timeout handlers, so it doesn't
get a runtime error if the handlers aren't set.
+ moved debugger to load AFTER the class system has loaded. This
doesn't really change anything now, but this will support future work to
declare the debugger as a real base class (LzDebugServiceCommon) with
platform-specific subclasses.
Tests:
smokecheck still works in swf8,dhtml
test/lfc/data/alldata.lzx compiles and runs in swf9 (but has test failures)
ant runlzunit
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/LaszloLibrary.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/LaszloLibrary.lzs 2008-07-14 21:30:05 UTC (rev 10353)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/LaszloLibrary.lzs 2008-07-14 21:31:40 UTC (rev 10354)
@@ -15,18 +15,6 @@
// Compiler runtime support first
#include "compiler/Library.lzs"
-if ($debug) {
- if ($swf9) {
- } else {
- // Must be loaded second
- #include "debugger/Library.lzs"
- }
-} else {
- if ($dhtml) {
- #include "debugger/stubs.lzs"
- }
-}
-
if ($profile) {
if ($swf9) {
} else {
@@ -40,6 +28,22 @@
}
#include "core/Library.lzs"
+
+// NOTE: [hqm 2008-07] moved debugger to load after the class system, so we can
+// implement debugger as classes
+if ($debug) {
+ if ($swf9) {
+
+ } else {
+ #include "debugger/Library.lzs"
+ }
+} else {
+ if ($dhtml) {
+ #include "debugger/stubs.lzs"
+ }
+}
+
+
#include "events/Library.lzs"
#include "kernel/Library.lzs"
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/compiler/Library.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/compiler/Library.lzs 2008-07-14 21:30:05 UTC (rev 10353)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/compiler/Library.lzs 2008-07-14 21:31:40 UTC (rev 10354)
@@ -24,4 +24,8 @@
}
// Debugger requires this, so must be loaded very early
+if ($swf9) {
+} else {
+ #include "compiler/LzMessage.lzs"
+}
#include "compiler/LzFormatter.lzs"
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/compiler/LzFormatter.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/compiler/LzFormatter.lzs 2008-07-14 21:30:05 UTC (rev 10353)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/compiler/LzFormatter.lzs 2008-07-14 21:31:40 UTC (rev 10354)
@@ -7,56 +7,8 @@
* Use is subject to license terms.
*/
-/**
- * This will be replaced by a more complete definition if the debugger
- * is included
- *
- * @access private
- */
-class LzMessage {
- var message = '';
- var length = 0;
- function LzMessage (message = null) {
- if (message != null) {
- this.appendInternal('' + message, message);
- }
- }
- function appendInternal (str, obj = null) {
- this.message += str;
- this.length = this.message.length;
- }
-
- function append (str) {
- var len = arguments.length;
- for (var i = 0; i < len; i++) {
- this.appendInternal(String(arguments[i]));
- }
- }
-
- // TODO: [2005-05-08 ptw] (LPP-5394) When toString is declared
- // public, remove the swf9 special-case
- if ($swf9) {
- prototype.toString = function () { return this.message; }
- } else {
- function toString () {
- return this.message;
- }
- }
-
- function toHTML () {
- // TODO: [2005-05-08 ptw] (LPP-5394) When toString is declared
- // public, remove the swf9 special-case
- if ($swf9) {
- return this['toString']();
- } else {
- return this.toString();
- }
- }
-}
-
-
/**
* Formatted output support
*
Added: openlaszlo/trunk/WEB-INF/lps/lfc/compiler/LzMessage.lzs
Property changes on: openlaszlo/trunk/WEB-INF/lps/lfc/compiler/LzMessage.lzs
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/debugger/swf9stubs.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/debugger/swf9stubs.lzs 2008-07-14 21:30:05 UTC (rev 10353)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/debugger/swf9stubs.lzs 2008-07-14 21:31:40 UTC (rev 10354)
@@ -36,8 +36,86 @@
write.apply(Debug, args);
}
- public function __String (thing, pretty=null, limit=null, unique=null):String { return new String( thing ); }
+ public function __String (thing, pretty=null, limit=null, unique=null):String { return ""+ thing ; }
}
var Debug = new LzDebugService();
lz.DebugService = LzDebugService; // publish
+
+
+class LzMessage {
+ var message = "";
+ function LzMessage (...args) {
+ if (typeof (args[0]) == "string") {
+ this.message = args[0];
+ }
+ }
+
+ function append (...args) {
+ this.message += args[0];
+ }
+
+ function appendInternal (...args) {
+ this.message += args[0];
+ }
+
+ function toString () {
+ return message;
+ }
+
+}
+
+class LzSourceMessage extends LzMessage {
+ var file;
+ var line
+
+function LzSourceMessage (file:String=null, line:Number=0, message:String='') {
+ // Append a backtrace if there is one -- skip back to the
+ // $reportSourceWarning or warnInternal frames.
+ this.file = file;
+ this.line = line;
+ if (message instanceof LzMessage) {
+ this.message = message;
+ } else {
+ this.message = new LzMessage(message);
+ }
+}
+
+}
+
+/**
+ * A Warning is a sourceMessage with the tag 'WARN'
+ * @access private
+ */
+class LzWarning extends LzSourceMessage {
+ function LzWarning (file, line, message) {
+ super(file, line, message);
+ }
+}
+
+
+class LzError extends LzSourceMessage {
+ function LzError (file, line, message) {
+ super(file, line, message);
+ }
+}
+
+class LzDebug extends LzSourceMessage {
+ function LzDebug (file, line, message) {
+ super(file, line, message);
+ }
+}
+
+class LzInfo extends LzSourceMessage {
+ function LzInfo (file, line, message) {
+ super(file, line, message);
+ }
+}
+
+
+var $reportSourceWarning = function (...ignore) { };
+var $reportUndefinedObjectProperty = function (...ignore) { };
+var $reportUndefinedProperty = function (...ignore) { };
+var $reportUndefinedVariable = function (...ignore) { };
+var $reportNotFunction = function (...ignore) { };
+var $reportUndefinedMethod = function (...ignore) { };
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzHTTPLoader.as
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzHTTPLoader.as 2008-07-14 21:30:05 UTC (rev 10353)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzHTTPLoader.as 2008-07-14 21:31:40 UTC (rev 10354)
@@ -58,9 +58,9 @@
}
// Default callback handlers
- public var loadSuccess:Function;
- public var loadError:Function;
- public var loadTimeout:Function;
+ public var loadSuccess:Function = function (...data) { trace('loadSuccess callback not defined on', this); }
+ public var loadError:Function = function (...data) { trace('loadError callback not defined on', this); };
+ public var loadTimeout:Function = function (...data) { trace('loadTimeout callback not defined on', this); };
/* Returns the response as a string */
public function getResponse () :String {
Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/DebugCompiler.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/DebugCompiler.java 2008-07-14 21:30:05 UTC (rev 10353)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/DebugCompiler.java 2008-07-14 21:31:40 UTC (rev 10354)
@@ -3,7 +3,7 @@
* ****************************************************************************/
/* J_LZ_COPYRIGHT_BEGIN *******************************************************
-* Copyright 2001-2007 Laszlo Systems, Inc. All Rights Reserved. *
+* Copyright 2001-2008 Laszlo Systems, Inc. All Rights Reserved. *
* Use is subject to license terms. *
* J_LZ_COPYRIGHT_END *********************************************************/
@@ -41,6 +41,9 @@
// return now.
if (!mEnv.getBooleanProperty(mEnv.DEBUG_PROPERTY)
|| mEnv.getBooleanProperty(mEnv.USER_DEBUG_WINDOW)
+ // TODO [hqm 2008 08] remove this clause when we define a SWF9 LzDebugWindow.
+ // There is no SWF9 debugger window component yet (LzDebugWindow), so don't try to instantiate one
+ || mEnv.getRuntime().equals("swf9")
// No debug window in DHTML -- it is in its own iframe.
|| mEnv.isDHTML()) {
return;
Modified: openlaszlo/trunk/lps/components/lzunit/lzunit.lzx
===================================================================
--- openlaszlo/trunk/lps/components/lzunit/lzunit.lzx 2008-07-14 21:30:05 UTC (rev 10353)
+++ openlaszlo/trunk/lps/components/lzunit/lzunit.lzx 2008-07-14 21:31:40 UTC (rev 10354)
@@ -264,8 +264,7 @@
var e = args[i];
if (typeof(e) == "string") {
s += e;
- }
- else {
+ } else {
s += Debug.__String(e);
}
}
@@ -383,15 +382,15 @@
@param message: the reason for the failure
-->
- <method name="fail" args="message">
+ <method name="fail" args="message"> <![CDATA[
var suite = this.parent;
suite.ontestfail.sendEvent(message);
if (this.result) {
- this.result.addFailure(message);
+ this.result.addFailure(message.toString());
} else {
Debug.debug('result is null on fail call: "' + message + '"');
}
- if ($debug) {
+ if ($debug && !$swf9) {
var file = null, line = null;
// Find the failing test, which is four frames up
var bt = Debug.backtrace(4);
@@ -404,6 +403,7 @@
// create an error, which will include a backtrace, if applicable
Debug.__write(new LzError(file, line, message));
}
+ ]]>
</method>
<!---
@@ -411,7 +411,7 @@
@param message: the reason for the error
-->
- <method name="error" args="...args">
+ <method name="error" args="...args"> <![CDATA[
var message = args[0];
var suite = this.parent;
suite.ontestfail.sendEvent(message);
@@ -420,11 +420,12 @@
} else {
Debug.debug('result is null on error call: "' + message + '"');
}
- if ($debug) {
+ if ($debug && !$swf9) {
Debug.freshLine();
// create an error, which will include a backtrace, if applicable
Debug.__write(new LzError(null, null, message));
}
+ ]]>
</method>
<!---
@@ -452,16 +453,17 @@
@param ...:* Any number of parameters will be formatted using
LzFormatter.formatToString and output to the display
-->
- <method name="displayMessage">
- var message = this.formatToString.apply(this, arguments);
+ <method name="displayMessage" args="...args"> <![CDATA[
+ var message = this.formatToString.apply(this, args);
if (this.result) {
this.result.addMessage(message);
}
- if ($debug ) {
+ if ($debug && !$swf9) {
Debug.freshLine();
// create an error, which will include a backtrace, if applicable
Debug.__write(new LzInfo(null, null, message));
}
+ ]]>
</method>
<!---
@@ -475,8 +477,9 @@
@param condition: the condition to be tested
@param assertion: (optional) the assertion the condition represents
-->
- <method name="assertTrue" args="condition, ...assertion">
- if (assertion) assertion = assertion[0];
+ <method name="assertTrue" args="condition, ...assertions">
+ var assertion;
+ if (assertions) assertion = assertions[0];
if (! semanticsTrue(condition)) {
this.fail(tformat(jsTrue(assertion) ? assertion : "True", true, condition));
}
@@ -495,8 +498,9 @@
@param condition: the condition to be tested
@param assertion: (optional) the assertion the condition represents
-->
- <method name="assertFalse" args="condition, ...assertion">
- if (assertion) assertion = assertion[0];
+ <method name="assertFalse" args="condition, ...assertions">
+ var assertion;
+ if (assertions) assertion = assertions[0];
if (!! semanticsTrue(condition)) {
this.fail(tformat(jsTrue(assertion) ? assertion : "False", false, condition));
}
@@ -510,8 +514,9 @@
@param actual: the actual value
@param message: (optional) the failure message
-->
- <method name="assertEquals" args="expected, actual, ...message">
- if (message) message = message[0];
+ <method name="assertEquals" args="expected, actual, ...messages">
+ var message;
+ if (messages) message = messages[0];
<!-- note NaN compares are always false -->
if (! (expected == actual)) {
this.fail(tformat(jsTrue(message) ? message : "Equals", expected, actual));
@@ -527,9 +532,10 @@
@param delta: the tolerance
@param message: (optional) the failure message
-->
- <method name="assertWithin" args="expected, actual, delta, ...message">
+ <method name="assertWithin" args="expected, actual, delta, ...messages">
<![CDATA[
- if (message) message = message[0];
+ var message;
+ if (messages) message = messages[0];
// handle infinite expected
if (expected == actual) return;
@@ -549,8 +555,9 @@
@param object: the value to be tested
@param message: (optional) the failure message
-->
- <method name="assertNull" args="object, ...message">
- if (message) message = message[0];
+ <method name="assertNull" args="object, ...messages">
+ var message;
+ if (messages) message = messages[0];
if (object !== null) {
this.fail(tformat(jsTrue(message) ? message : "Null",
null, object));
@@ -564,8 +571,9 @@
@param object: the value to be tested
@param message: (optional) the failure message
-->
- <method name="assertNotNull" args="object, ...message">
- if (message) message = message[0];
+ <method name="assertNotNull" args="object, ...messages">
+ var message;
+ if (messages) message = messages[0];
if (object === null) {
this.fail(tformat(jsTrue(message) ? message : "NotNull",
"non-null value", object));
@@ -579,8 +587,9 @@
@param object: the value to be tested
@param message: (optional) the failure message
-->
- <method name="assertUndefined" args="object, ...message">
- if (message) message = message[0];
+ <method name="assertUndefined" args="object, ...messages">
+ var message;
+ if (messages) message = messages[0];
if (typeof(object) != "undefined") {
this.fail(tformat(jsTrue(message) ? message : "Undefined",
"undefined value", object));
@@ -594,8 +603,9 @@
@param object: the value to be tested
@param message: (optional) the failure message
-->
- <method name="assertNotUndefined" args="object, ...message">
- if (message) message = message[0];
+ <method name="assertNotUndefined" args="object, ...messages">
+ var message;
+ if (messages) message = messages[0];
if (typeof(object) == "undefined") {
this.fail(tformat(jsTrue(message) ? message : "NotUndefined",
"defined value", object));
@@ -611,9 +621,10 @@
@param actual: the actual value
@param message: (optional) the failure message
-->
- <method name="assertSame" args="expected, actual, ...message">
+ <method name="assertSame" args="expected, actual, ...messages">
<![CDATA[
- if (message) message = message[0];
+ var message;
+ if (messages) message = messages[0];
// Use typeof to compare undefined without warnings
if (typeof(expected) == "undefined" &&
typeof(actual) == "undefined") {
@@ -635,8 +646,9 @@
@param actual: the actual value
@param message: (optional) the failure message
-->
- <method name="assertNotSame" args="expected, actual, ...message">
- if (message) message = message[0];
+ <method name="assertNotSame" args="expected, actual, ...messages">
+ var message;
+ if (messages) message = messages[0];
if (expected === actual) {
// In-line Test.tformat so we can invert the sense
var msg = LzFormatter.prototype.formatToString(
@@ -706,16 +718,16 @@
@param theTestName: (optional) the test to run, if not supplied
the test with the name of the TestCase is run
-->
- <method name="run" args="theTestResult, theTestName">
+ <method name="run" args="theTestResult, theTestName"> <![CDATA[
dw("TestCase.run(", theTestName, ")");
setResult(theTestResult);
var dn = this._dbg_name instanceof Function ? this._dbg_name() : this._dbg_name;
- var tn = this._dbg_typename instanceof Function ? this._dbg_typename() : this._dbg_typename;
+ var tn = this._dbg_typename instanceof Function ? this._dbg_typename() : this._dbg_typename;
var prefix = (dn != tn) ? dn + ' >>> ' : ''
this.result.startTest(prefix + theTestName);
setUp();
- <!-- capture source warnings as errors around test -->
- <!-- TODO: [2002-11-16 ptw] try/finally -->
+ //<!-- capture source warnings as errors around test -->
+ //<!-- TODO: [2002-11-16 ptw] try/finally -->
var wrapper = function (fn, ln, msg) {
with(arguments.callee.env) {
if (! inrsw) {
@@ -727,8 +739,8 @@
}
}
}
- <!-- hand-crafted closure -->
- if ($debug) {
+ //<!-- hand-crafted closure -->
+ if ($debug && !$swf9) {
wrapper.env = {inrsw: false, rsw: $reportSourceWarning, testcase: this};
var savedrsw = $reportSourceWarning;
if (catchErrors) {
@@ -736,14 +748,15 @@
}
}
runTest(theTestName);
- if ($debug) {
+ if ($debug && !$swf9) {
if (catchErrors) {
$reportSourceWarning = savedrsw;
}
}
- <!-- end capture source warnings -->
+ //<!-- end capture source warnings -->
tearDown();
return this.result;
+ ]]>
</method>
<!---
@@ -995,12 +1008,12 @@
@keywords private
@param ...:* format args
-->
- <method name="addMessage">
- messages.push(readout.formatToString.apply(readout, arguments));
+ <method name="addMessage" args="...args">
+ messages.push(readout.formatToString.apply(readout, args));
update();
</method>
- <method name="myToString">
+ <method name="toString">
var s = "Tests: " + this.totalTests +
" Failures: " + failedTests +
" Errors: " + erroredTests;
@@ -1075,12 +1088,6 @@
</class>
-
-<script>
- // TODO [2004-08-10 ptw] Workaround for SWF6 toString default bug
- lz.TestResult.prototype.toString = lz.TestResult.prototype.myToString;
-</script>
-
<!--
A TestSuite is a view with any number of children. The children
that are TestCases will have all their test... methods run when the
Modified: openlaszlo/trunk/test/lfc/data/datanode.lzx
===================================================================
--- openlaszlo/trunk/test/lfc/data/datanode.lzx 2008-07-14 21:30:05 UTC (rev 10353)
+++ openlaszlo/trunk/test/lfc/data/datanode.lzx 2008-07-14 21:31:40 UTC (rev 10354)
@@ -69,7 +69,6 @@
zdat.removeChild( zdat.getLastChild() );
assertTrue(xmlstringequals( '<foo z="77" x="33"><aa/>some text<bb/>more text</foo>' , zdat.serialize() ));
-
zdat.getFirstChild().setChildNodes( [ new LzDataElement( 'first' ),
new LzDataText( 'second' ) ] );
assertTrue(xmlstringequals( '<foo z="77" x="33"><aa><first/>second</aa>some text<bb/>more text</foo>' , zdat.serialize() ));
@@ -86,8 +85,10 @@
var arr = zdat.getElementsByTagName ( 'aa' ) ;
assertEquals( "<aa><first/>second</aa>" , arr[ 0 ].serialize());
- assertEquals( '<aa r="22" p="

	"/>', arr[ 1 ].serialize());
+ assertTrue(xmlstringequals('<aa r="22" p="

	"/>', arr[ 1 ].serialize()));
+
+
//zdat.setAttrNS (namespaceURI, qualifiedName, ;
//zdat.getAttrNS ( "local" , "foo") ;
More information about the Laszlo-checkins
mailing list