[Swfdec] Branch 'as' - test/trace

Benjamin Otte company at kemper.freedesktop.org
Sun Jun 17 03:57:52 PDT 2007


 test/trace/Makefile.am |    1 
 test/trace/values.as   |   63 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 64 insertions(+)

New commits:
diff-tree aaca94203d8a0ccb8feb32c0d57df3401fca0350 (from 987074e275ac77f8799e5fdf41890e8ef126b291)
Author: Benjamin Otte <otte at gnome.org>
Date:   Sun Jun 17 12:56:42 2007 +0200

    add values.as which provides some default values for lots of tests

diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 9c66cbc..d223906 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -441,6 +441,7 @@ EXTRA_DIST = \
 	unescape2-6.swf.trace \
 	unescape2-7.swf \
 	unescape2-7.swf.trace \
+	values.as \
 	video.flv \
 	with-delete.as \
 	with-delete-5.swf \
diff --git a/test/trace/values.as b/test/trace/values.as
new file mode 100644
index 0000000..25afaea
--- /dev/null
+++ b/test/trace/values.as
@@ -0,0 +1,63 @@
+// This ActionScript file defines a list of values that are considered 
+// important for checking various ActionScript operations.
+// It defines 2 variables:
+// - "values": The array of values to be checked
+// - "names": The array of corresponding string representations for values.
+//            It's suggested to use these instead of using values directly to
+//            avoid spurious toString and valueOf calls.
+
+printall = new Object ();
+printall.valueOf = function () {
+  trace ("valueOf called");
+  return this;
+};
+printall.toString = function () {
+  trace ("toString called");
+  return this;
+};
+
+tostring = new Object ();
+tostring.toString = function () {
+  trace ("toString called with " + arguments);
+  return this;
+};
+
+valueof = new Object ();
+valueof.valueOf = function () {
+  trace ("valueOf called with " + arguments);
+  return this;
+};
+
+nothing = new Object ();
+nothing.__proto__ = undefined;
+values = [ 
+  undefined, 
+  null, 
+  true, false, 
+  0, 1, 0.5, -1, -0.5, Infinity, -Infinity, NaN,
+  "", "0", "-0", "0.0", "1", "Hello World!", "true", "_level0",
+  this, new Object (), Function, printall, tostring, valueof, nothing ];
+
+var l = values.length;
+var v = function () {
+  trace (this.nr + ": valueOf!");
+  return this.v;
+};
+var s = function () {
+  trace (this.nr + ": toString!");
+  return this.v;
+};
+for (i = 0; i < l; i++) {
+  var o = new Object ();
+  o.nr = i;
+  o.valueOf = v;
+  o.toString = s;
+  o.v = values[i];
+  values.push (o);
+};
+
+
+names = [];
+for (i = 0; i < values.length; i++) {
+  names[i] = "(" + i + ") " + values[i] + " (" + typeof (values[i]) + ")";
+};


More information about the Swfdec mailing list