DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc
-test:
- cd tests ; ./run-tests.py
-
profile-reset:
find -name '*.gcda' -delete
-profile: profile-reset test
+profile: profile-reset check
cp libseed/*.c libseed/.libs/
if PROFILE_MODULES
SUBDIRS = javascript c
-EXTRA_DIST = \
- COPYING \
- run-tests.py \
- make-test.py
-
-## File created by the gnome-build tools
+EXTRA_DIST = COPYING
builtin-argument-length.js \
check-syntax.js \
closure-finalization.js \
- c-module.js \
compare.js \
constructor-args.js \
constructor-prototype.js \
json.js \
list-test.js \
modules.js \
+ modules-noasserts.js \
native-closure-exception.js \
native-closure.js \
object-info.js \
out-test.js \
- printf.js \
- print.js \
- printprint.js \
property-benchmark.js \
property-glib-exception.js \
- quit2.js \
quit.js \
- readline-bind.js \
- readline.js \
- spawn.js \
sqlite.js \
syntax-test.js \
- type-conversion.js
-
+ syntax-test-noasserts.js \
+ type-conversion.js \
+ testsuite.js
-## File created by the gnome-build tools
+TESTS = \
+ argv.js \
+ array-gtype.js \
+ builtin-argument-length.js \
+ check-syntax.js \
+ closure-finalization.js \
+ compare.js \
+ constructor-args.js \
+ constructor-prototype.js \
+ enum.js \
+ everything.js \
+ fork.js \
+ function-info.js \
+ gdk-event.js \
+ gerror.js \
+ gobject-scope.js \
+ gvalue-argument.js \
+ include.js \
+ include-syntax.js \
+ introspect.js \
+ json-constructor.js \
+ json.js \
+ list-test.js \
+ modules.js \
+ native-closure-exception.js \
+ native-closure.js \
+ object-info.js \
+ out-test.js \
+ property-benchmark.js \
+ property-glib-exception.js \
+ quit.js \
+ sqlite.js \
+ syntax-test.js \
+ type-conversion.js
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:seed
-// STDERR:
-print(Seed.argv[0]);
+imports.testsuite.assert(Seed.argv[0] == "seed")
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:
-// STDERR:
Gtk = imports.gi.Gtk;
GObject = imports.gi.GObject;
Gtk.init(Seed.argv);
-list = new Gtk.ListStore();
-list.set_column_types(2, [GObject.TYPE_STRING, GObject.TYPE_INT]);
+try
+{
+ list = new Gtk.ListStore();
+ list.set_column_types(2, [GObject.TYPE_STRING, GObject.TYPE_INT]);
+}
+catch(e)
+{
+ print(e)
+ imports.testsuite.unreachable()
+}
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:Seed\.spawn expected 1 argument\nFailed to execute child process "asihfieuhgieuhgw" \(No such file or directory\)\nSeed\.include expected 1 argument, got 0\nFile not found: 1\nFile not found: \nSeed\.include expected 1 argument, got 2\nSeed\.include expected 1 argument, got 2\nprint expected 1 argument, got 0\nprint expected 1 argument, got 2\nprint expected 1 argument, got 2\nprint expected 1 argument, got 3\nSeed\.introspect expected 1 argument, got 0\nSeed\.introspect expected 1 argument, got 2\nSeed\.check_syntax expected 1 argument, got 0\nSeed\.check_syntax expected 1 argument, got 2
-// STDERR:
-
-try{
-Seed.spawn();
-}catch(e){print(e.message);}
-try{
-Seed.spawn("asihfieuhgieuhgw");
-}catch(e){print(e.message);}
-
-try{
-Seed.include();
-}catch(e){print(e.message);}
-try{
-Seed.include(1);
-}catch(e){print(e.message);}
-try{
-Seed.include("");
-}catch(e){print(e.message);}
-try{
-Seed.include(1,2);
-}catch(e){print(e.message);}
-try{
-Seed.include("fail.js","another.js");
-}catch(e){print(e.message);}
-
-try{
-print();
-}catch(e){print(e.message);}
-try{
-print(1, 2);
-}catch(e){print(e.message);}
-try{
-print("asdf", 2);
-}catch(e){print(e.message);}
-try{
-print(1, 2, 3);
-}catch(e){print(e.message);}
-
-try{
-Seed.introspect();
-}catch(e){print(e.message);}
-try{
-Seed.introspect(Seed, 5.23);
-}catch(e){print(e.message);}
-
-try{
-Seed.check_syntax();
-}catch(e){print(e.message);}
-try{
-Seed.check_syntax("5+5", "asdf");
-}catch(e){print(e.message);}
-
-try{
-Seed.quit(1,2);
-}catch(e){print(e.message);}
-
-Seed.quit();
+
+testsuite = imports.testsuite
+
+function correctArgs(fs, a)
+{
+ try
+ {
+ eval(fs).apply(this, a)
+ }
+ catch(e)
+ {
+ if(e.name == "ArgumentError")
+ testsuite.unreachable(fs)
+ }
+}
+
+function wrongArgs(fs, a)
+{
+ try
+ {
+ eval(fs).apply(this, a)
+ testsuite.unreachable(fs)
+ }
+ catch(e)
+ {
+
+ }
+}
+
+wrongArgs("Seed.spawn", [])
+correctArgs("Seed.spawn", ["asdfasdfasdf"])
+
+wrongArgs("Seed.include", [])
+wrongArgs("Seed.include", [1])
+correctArgs("Seed.include", [""])
+wrongArgs("Seed.include", [1,2])
+wrongArgs("Seed.include", ["fail.js","another.js"])
+
+wrongArgs("print", [])
+wrongArgs("print", [1,2])
+wrongArgs("print", ["asdf",2])
+wrongArgs("print", [1,2,3])
+
+wrongArgs("Seed.introspect", [])
+correctArgs("Seed.introspect", [Seed])
+wrongArgs("Seed.introspect", [Seed, 5.23])
+
+wrongArgs("Seed.check_syntax", [])
+correctArgs("Seed.check_syntax", ["asdfasdf"])
+wrongArgs("Seed.check_syntax", ["5+5", "asdf"])
+
+++ /dev/null
-#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:Hello Seed Module World
-// STDERR:
-
-example = imports.example;
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:ONE\n\[null\]\nTWO\n\[null\]\nTHREE
-// STDERR:\n\*\* \(seed:[0-9]+\): CRITICAL \*\*: Line 1 in \[undefined\]: SyntaxError Parse error
-
-print("ONE");
-print(Seed.check_syntax("5+5;"));
-print("TWO");
-print(Seed.check_syntax("asdfasdf.jsdf()"));
-print("THREE");
-print(Seed.check_syntax("one[)"));
+
+testsuite = imports.testsuite
+
+try
+{
+ Seed.check_syntax("5+5;")
+}
+catch(e)
+{
+ testsuite.unreachable("5+5; is not a syntax error")
+}
+
+try
+{
+ Seed.check_syntax("asdfasdf.jsdf()")
+}
+catch(e)
+{
+ testsuite.unreachable("asdfasdf.jsdf() is not a syntax error")
+}
+
+try
+{
+ Seed.check_syntax("one[)")
+ testsuite.unreachable("one[) should be a syntax error")
+}
+catch(e)
+{
+ testsuite.assert(e instanceof SyntaxError)
+}
+
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:\[object GtkVBox\]
-// STDERR:
+testsuite = imports.testsuite;
Gtk = imports.gi.Gtk;
Gtk.init(Seed.argv);
// Closure will always be GCed at end of signal.
signal = function()
{
- w.foreach(function(widget){print(widget);});
+ widgets = []
+ w.foreach(function(widget){widgets.push(widget.toString())})
+ testsuite.assert(widgets[0] == ["[object GtkVBox]"])
+ testsuite.assert(widgets.length == 1)
};
vbox = new Gtk.VBox();
w.signal.show.connect(signal);
w.show_all();
+
+testsuite.checkAsserts(2)
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:0\n1
-// STDERR:
+testsuite = imports.testsuite
Gtk = imports.gi.Gtk;
+
Gtk.init(Seed.argv);
var a = new Gtk.Button();
var b = new Gtk.Button();
var c = a;
-print(a == b);
-print(c == a);
+testsuite.assert(a != b);
+testsuite.assert(c == a);
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:Constructor expects 1 argument, got 2\nConstructor expects object as argument
-// STDERR:
+testsuite = imports.testsuite
Gtk = imports.gi.Gtk;
Gtk.init(Seed.argv);
}
catch (e)
{
- print(e.message);
+ testsuite.unreachable()
}
try
{
w = new Gtk.Window(1, 2);
+ testsuite.unreachable()
}
catch (e)
{
- print(e.message);
+ testsuite.assert(e.name == "ArgumentError")
}
try
{
w = new Gtk.Window("safA");
+ testsuite.unreachable()
}
catch (e)
{
- print(e.message);
+ testsuite.assert(e.name == "ArgumentError")
}
+
+testsuite.checkAsserts(2)
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:Hello World
-// STDERR:
-Gtk = imports.gi.Gtk;
-Gtk.init(Seed.argv);
+testsuite = imports.testsuite
+Gtk = imports.gi.Gtk
-Gtk.Window.prototype.hello = "Hello World";
+Gtk.init(Seed.argv)
-a = new Gtk.Window();
-print(a.hello);
+Gtk.Window.prototype.hello = "Hello World"
+
+a = new Gtk.Window()
+
+testsuite.assert(a.hello == "Hello World")
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:2
-// STDERR:
+testsuite = imports.testsuite
Gtk = imports.gi.Gtk;
-Gtk.init(Seed.argv);
-b = new Gtk.Button();
-b.relief = Gtk.ReliefStyle.NONE;
+Gtk.init(Seed.argv);
-print(Gtk.ReliefStyle.NONE);
+b = new Gtk.Button()
+b.relief = Gtk.ReliefStyle.NONE
+testsuite.assert(Gtk.ReliefStyle.NONE == 2)
+testsuite.assert(b.relief == 2)
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:1\n-124\n129\n-1235\n1387\n-123435\n133487\n-16323375\n13873737\n-16325\n33737\n-16325\n33737\n12\n143\n-1853\.12329101562\n-134543853\.12334\n8\n\["åäö","\/etc\/fstab"\]\n\["1","2","3"\]\n\["1","2","3"\]\n\["1","2","3"\]\n\["1","2","3"\]\nthanks,for,all,the,fish\n5\n0\n123\n0\n1\n42\n1\n2\n4\n15\n120\n120\.2357\n42\n19
-// STDERR:
-Everything = imports.gi.Everything;
-GObject = imports.gi.GObject;
+testsuite = imports.testsuite
+Everything = imports.gi.Everything
+GObject = imports.gi.GObject
+JSON = imports.JSON
-JSON = imports.JSON;
+assert = testsuite.assert
with(Everything)
{
-print(test_boolean(true));
-print(test_int8(-124));
-print(test_uint8(129));
-print(test_int16(-1235));
-print(test_uint16(1387));
-print(test_int32(-123435));
-print(test_uint32(133487));
-print(test_int64(-16323375));
-print(test_uint64(13873737));
-print(test_int(-16325));
-print(test_uint(33737));
-print(test_long(-16325));
-print(test_ulong(33737));
-print(test_ssize(12));
-print(test_size(143));
-print(test_float(-1853.12334));
-print(test_double(-134543853.12334));
-//Need support for: print(test_timet(1853));
-print(test_gtype(8));
+assert(test_boolean(true) == true)
+assert(test_int8(-124) == -124)
+assert(test_uint8(129) == 129)
+assert(test_int16(-1235) == -1235)
+assert(test_uint16(1387) == 1387)
+assert(test_int32(-123435) == -123435)
+assert(test_uint32(133487) == 133487)
+assert(test_int64(-16323375) == -16323375)
+assert(test_uint64(13873737) == 13873737)
+assert(test_int(-16325) == -16325)
+assert(test_uint(33737) == 33737)
+assert(test_long(-16325) == -16325)
+assert(test_ulong(33737) == 33737)
+assert(test_ssize(12) == 12)
+assert(test_size(143) == 143)
+assert(test_float(-1853.12334) > (-1853.12334 - 0.001))
+assert(test_float(-1853.12334) < (-1853.12334 + 0.001))
+assert(test_double(-134543853.12334) > (-134543853.12334 - 0.001))
+assert(test_double(-134543853.12334) < (-134543853.12334 + 0.001))
+//assert(test_timet(1853) == 1853)
+assert(test_gtype(8) == 8)
-print(JSON.stringify(test_filename_return()));
-print(JSON.stringify(test_glist_nothing_return()));
-print(JSON.stringify(test_glist_nothing_return2()));
-print(JSON.stringify(test_glist_container_return()));
-print(JSON.stringify(test_glist_everything_return()));
+assert(test_filename_return()[0] == "åäö")
+assert(test_filename_return()[1] == "/etc/fstab")
+assert(test_glist_nothing_return()[0] == "1")
+assert(test_glist_nothing_return2()[1] == "2")
+assert(test_glist_container_return()[2] == "3")
+assert(test_glist_everything_return()[1] == "2")
-//test_glist_nothing_in([2, 3, 4]);
+//test_glist_nothing_in([2, 3, 4])
-print(test_strv_out());
+assert(test_strv_out().toString() == "thanks,for,all,the,fish")
-// These are broken... Robb's working on them:
-print(test_closure(function () { return [GObject.TYPE_INT, 5]; }));
-print(test_closure_one_arg(function (a) { return [GObject.TYPE_INT, a]; }));
+assert(test_closure(function () { return [GObject.TYPE_INT, 5] }) == 5)
+assert(test_closure_one_arg(function (a) { return [GObject.TYPE_INT, a] }) == 0)
-print(test_value_return(123).get_int());
+assert(test_value_return(123).get_int() == 123)
-print(TestEnum.VALUE1);
-print(TestEnum.VALUE2);
-print(TestEnum.VALUE3);
-print(TestFlags.FLAG1);
-print(TestFlags.FLAG2);
-print(TestFlags.FLAG3);
+assert(TestEnum.VALUE1 == 0)
+assert(TestEnum.VALUE2 == 1)
+assert(TestEnum.VALUE3 == 42)
+assert(TestFlags.FLAG1 == 1)
+assert(TestFlags.FLAG2 == 2)
+assert(TestFlags.FLAG3 == 4)
-TestStructA.some_int = 15;
-print(TestStructA.some_int);
-TestStructA.some_int8 = 120;
-print(TestStructA.some_int8);
-TestStructA.some_double = 120.2357;
-print(TestStructA.some_double);
-TestStructA.some_enum = TestEnum.VALUE3;
-print(TestStructA.some_enum);
+TestStructA.some_int = 15
+assert(TestStructA.some_int == 15)
+TestStructA.some_int8 = 120
+assert(TestStructA.some_int8 == 120)
+TestStructA.some_double = 120.2357
+assert(TestStructA.some_double > (120.2357 - 0.001))
+assert(TestStructA.some_double < (120.2357 + 0.001))
+TestStructA.some_enum = TestEnum.VALUE3
+assert(TestStructA.some_enum == 42)
-TestStructB.some_int8 = 19;
-print(TestStructB.some_int8);
-//TestStructB.nested_a.some_double = 134.3455;
-//print(TestStructB.nested_a.some_double);
+TestStructB.some_int8 = 19
+assert(TestStructB.some_int8 == 19)
+//TestStructB.nested_a.some_double = 134.3455
+//print(TestStructB.nested_a.some_double)
}
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:[AB]\n[AB]
-// STDERR:
-os = imports.os;
-var a = os.fork();
-if(a)
-{
- print("A");
-}
-else
-{
- print("B");
-}
+testsuite = imports.testsuite
+os = imports.os
+
+a = os.fork()
+
+testsuite.assert(a >= 0)
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:resize
-// STDERR:
-Gtk = imports.gi.Gtk;
-GIRepository = imports.gi.GIRepository;
+testsuite = imports.testsuite
+Gtk = imports.gi.Gtk
+GIRepository = imports.gi.GIRepository
-f = Gtk.Window.prototype.resize.info;
+f = Gtk.Window.prototype.resize.info
-print(GIRepository.base_info_get_name(f));
+testsuite.assert(GIRepository.base_info_get_name(f) == "resize")
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:\[object GdkWindow\]\n\[object GdkWindow\]\n1\n200
-// STDERR:
-Gtk = imports.gi.Gtk;
-Gdk = imports.gi.Gdk;
-Gtk.init(Seed.argv);
+testsuite = imports.testsuite
+Gtk = imports.gi.Gtk
+Gdk = imports.gi.Gdk
+Gtk.init(Seed.argv)
function paint(wdg, evt)
{
- print(evt.expose.window);
- print(wdg.window);
- print(evt.expose.window === wdg.window);
+ testsuite.assert(evt.expose.window instanceof Gdk.Window)
+ testsuite.assert(wdg.window instanceof Gdk.Window)
+ testsuite.assert(evt.expose.window == wdg.window)
+ testsuite.assert(evt.expose.area.width == 200)
- print(evt.expose.area.width);
+ Gtk.main_quit()
- Gtk.main_quit();
- return false;
+ return false
}
-var win = new Gtk.Window();
-win.signal.expose_event.connect(paint);
-win.resize(200,200);
-win.show();
+var win = new Gtk.Window()
+win.signal.expose_event.connect(paint)
+win.resize(200,200)
+win.show()
-Gtk.main();
+Gtk.main()
+
+testsuite.checkAsserts(4)
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:GIoError Error opening file .* Is a directory
-// STDERR:
-Gio = imports.gi.Gio;
+testsuite = imports.testsuite
+Gio = imports.gi.Gio
try
{
- Gio.simple_write(".", "test");
+ Gio.simple_write(".", "test")
+ testsuite.unreachable()
}
catch (e)
{
- print(e.name+" "+e.message);
+ testsuite.assert(e.name == "GIoError")
}
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:
-// STDERR:
-Gtk = imports.gi.Gtk;
+// TODO: this test doesn't actually test anything...
-Gtk.init(Seed.argv);
+Gtk = imports.gi.Gtk
+
+Gtk.init(Seed.argv)
for(var i = 0; i < 100; i++)
{
- var button = new Gtk.Button({label: "Test!"});
+ var button = new Gtk.Button({label: "Test!"})
}
EXTRA_DIST = \
+ gtype-class-init-exception.js \
+ gtype-property.js \
+ gtype-typerror.js \
+ gtype.js \
+ gtype-gtype.js \
+ gtype-signal-args.js \
+ gtype-property-construct.js \
+ gtype-property-nice.js \
+ gtype-self.js \
+ gtype-extraprop.js \
+ gtype-gtype-class-init.js \
+ gtype-signal.js \
+ testsuite.js
+
+TESTS = \
gtype-class-init-exception.js \
gtype-property.js \
gtype-typerror.js \
// STDOUT:
// STDERR:\n\*\* \(seed:[0-9]+\): WARNING \*\*: Exception in class init closure\. Line 14 in .*\/gtype-class-init-exception\.js: ReferenceError Can't find variable: notAVariable
-Gtk = imports.gi.Gtk;
-Gtk.init(Seed.argv);
+testsuite = imports.testsuite
+Gtk = imports.gi.Gtk
+Gtk.init(Seed.argv)
HelloWindowType = {
parent: Gtk.Window.type,
name: "HelloWindow",
class_init: function(klass, prototype)
{
- prototype = notAVariable.notAProperty;
+ prototype = notAVariable.notAProperty
},
init: function(klass)
{
- }};
+ }
+}
-HelloWindow = new GType(HelloWindowType);
-w = new HelloWindow();
+try
+{
+ HelloWindow = new GType(HelloWindowType)
+ w = new HelloWindow()
+}
+catch(e)
+{
+ testsuite.assert(e instanceof ReferenceError)
+ // TODO: THIS TEST DOESN'T WORK EITHER!
+ // what's going on with chained exception stuff
+}
+//testsuite.checkAsserts(1)
+
+print("This test doesn't work yet...")
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:1
-// STDERR:
-Gtk = imports.gi.Gtk;
-Gtk.init(Seed.argv);
+testsuite = imports.testsuite
+Gtk = imports.gi.Gtk
-HelloWindowType = {
+Gtk.init(Seed.argv)
+
+HelloWindow = new GType({
parent: Gtk.Window.type,
name: "HelloWindow",
- init: function(self){
- print(self.test);
- }};
-
-HelloWindow = new GType(HelloWindowType);
-w = new HelloWindow({test: 1});
+ init: function(self)
+ {
+ testsuite.assert(self.test == 2)
+ testsuite.assert(self.testAgain == "arst")
+ }
+})
-w.show();
+w = new HelloWindow({test: 2, testAgain: "arst"})
+testsuite.checkAsserts(2)
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:Class init
-// STDERR:
-Gtk = imports.gi.Gtk;
-Gtk.init(Seed.argv);
-HelloWindowType = {
- parent: Gtk.Window.type,
- name: "HelloWindow",
- init: function(){
- }
-};
+testsuite = imports.testsuite
+Gtk = imports.gi.Gtk
+Gtk.init(Seed.argv)
-HelloWindow = new GType(HelloWindowType);
-w = new HelloWindow();
+HelloWindow = new GType({
+ parent: Gtk.Window.type,
+ name: "HelloWindow",
+ init: function()
+ {
+ }
+})
-InheritedWindowType = {
- parent: HelloWindow.type,
- name: "InheritedWindow",
- class_init: function(klass, prototype) {print("Class init")},
- init: function(){
- }
-};
+w = new HelloWindow()
-InheritedWindow = new GType(InheritedWindowType);
-
-b = new InheritedWindow();
+InheritedWindow = new GType({
+ parent: HelloWindow.type,
+ name: "InheritedWindow",
+ class_init: function(klass, prototype)
+ {
+ testsuite.assert(1)
+ },
+ init: function()
+ {
+ }
+})
+b = new InheritedWindow()
+testsuite.checkAsserts(1)
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:Hi\nHi\nbye
-// STDERR:
-Gtk = imports.gi.Gtk;
-Gtk.init(Seed.argv);
-HelloWindowType = {
- parent: Gtk.Window.type,
- name: "HelloWindow",
- init: function(){
- print("Hi");
- }
-};
+testsuite = imports.testsuite
+Gtk = imports.gi.Gtk
+Gtk.init(Seed.argv)
-HelloWindow = new GType(HelloWindowType);
-w = new HelloWindow();
+HelloWindow = new GType({
+ parent: Gtk.Window.type,
+ name: "HelloWindow",
+ init: function(self)
+ {
+ self.id = 5
+ }
+})
-InheritedWindowType = {
- parent: HelloWindow.type,
- name: "InheritedWindow",
- init: function(){
- print("bye");
- }
-};
+InheritedWindow = new GType({
+ parent: HelloWindow.type,
+ name: "InheritedWindow",
+ init: function(self)
+ {
+ self.id = 10
+ }
+})
-InheritedWindow = new GType(InheritedWindowType);
-
-b = new InheritedWindow();
+w = new HelloWindow()
+b = new InheritedWindow()
+testsuite.assert(w.id == 5)
+testsuite.assert(b.id == 10)
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:1
-// STDERR:
-Gtk = imports.gi.Gtk;
-GObject = imports.gi.GObject;
-Gtk.init(Seed.argv);
+testsuite = imports.testsuite
+Gtk = imports.gi.Gtk
+GObject = imports.gi.GObject
+Gtk.init(Seed.argv)
-HelloWindowType = {
-parent: Gtk.Window.type,
-name: "HelloWindow",
-class_init: function(klass, prototype)
-{
- klass.c_install_property(GObject.param_spec_boolean("test",
- "test property",
- "A test property!",
- false,
- GObject.ParamFlags.CONSTRUCT | GObject.ParamFlags.READABLE | GObject.ParamFlags.WRITABLE));
-},
-init: function()
-{
- print(this.test);
-}};
+HelloWindow = new GType({
+ parent: Gtk.Window.type,
+ name: "HelloWindow",
+ class_init: function(klass, prototype)
+ {
+ klass.c_install_property(GObject.param_spec_boolean(
+ "test",
+ "test property",
+ "A test property!",
+ false,
+ GObject.ParamFlags.CONSTRUCT |
+ GObject.ParamFlags.READABLE |
+ GObject.ParamFlags.WRITABLE))
+ },
+ init: function()
+ {
+ testsuite.assert(this.test == true)
+ }
+})
+
+w = new HelloWindow({test: true})
-HelloWindow = new GType(HelloWindowType);
-w = new HelloWindow({test: true});
+testsuite.assert(w.test == true)
+try
+{
+ w.test = "arst"
+}
+catch(e)
+{
+ testsuite.assert(e.name == "ConversionError")
+}
+testsuite.checkAsserts(3)
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:1\n1\n0
-// STDERR:
-GObject = imports.gi.GObject;
-Gtk = imports.gi.Gtk;
-Gtk.init(Seed.argv);
+testsuite = imports.testsuite
+GObject = imports.gi.GObject
+Gtk = imports.gi.Gtk
+Gtk.init(Seed.argv)
-HelloWindowType = {
+HelloWindow = new GType({
parent: Gtk.Window.type,
name: "HelloWindow",
- properties: [{name: "randomproperty",
- type: GObject.TYPE_BOOLEAN,
- nick: "randomproperty",
- blurb: "longer blurb about property",
- default_value: true,
- flags: (GObject.ParamFlags.CONSTRUCT | GObject.ParamFlags.READABLE | GObject.ParamFlags.WRITABLE)}],
+ properties: [{
+ name: "randomproperty",
+ type: GObject.TYPE_BOOLEAN,
+ nick: "randomproperty",
+ blurb: "longer blurb about property",
+ default_value: true,
+ flags: (GObject.ParamFlags.CONSTRUCT | GObject.ParamFlags.READABLE | GObject.ParamFlags.WRITABLE)}],
init: function(klass)
{
- }};
+ }
+})
-HelloWindow = new GType(HelloWindowType);
-w = new HelloWindow();
+w = new HelloWindow()
-print(w.randomproperty);
-w.randomproperty = 5;
-print(w.randomproperty);
-w.randomproperty = 0;
-print(w.randomproperty);
+testsuite.assert(w.randomproperty == 1)
+w.randomproperty = 5
+testsuite.assert(w.randomproperty == 1)
+w.randomproperty = 0
+testsuite.assert(w.randomproperty == 0)
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:1\n0
-// STDERR:
-Gtk = imports.gi.Gtk;
-GObject = imports.gi.GObject;
-Gtk.init(Seed.argv);
+testsuite = imports.testsuite
+Gtk = imports.gi.Gtk
+GObject = imports.gi.GObject
+Gtk.init(Seed.argv)
-HelloWindowType = {
-parent: Gtk.Window.type,
-name: "HelloWindow",
-class_init: function(klass, prototype)
-{
- klass.c_install_property(GObject.param_spec_boolean("test",
- "test property",
- "A test property!",
- false,
- GObject.ParamFlags.READABLE | GObject.ParamFlags.WRITABLE));
-},
-init: function()
-{
-}};
+HelloWindow = new GType({
+ parent: Gtk.Window.type,
+ name: "HelloWindow",
+ class_init: function(klass, prototype)
+ {
+ klass.c_install_property(GObject.param_spec_boolean(
+ "test",
+ "test property",
+ "A test property!",
+ false,
+ GObject.ParamFlags.READABLE |
+ GObject.ParamFlags.WRITABLE))
+ },
+ init: function()
+ {
+ }
+})
-HelloWindow = new GType(HelloWindowType);
-w = new HelloWindow({test: true});
-print(w.test);
-w = new HelloWindow();
-print(w.test);
+w = new HelloWindow({test: true})
+testsuite.assert(w.test == true)
+w = new HelloWindow()
+testsuite.assert(w.test == false)
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:1
-// STDERR:
-Gtk = imports.gi.Gtk;
-Gtk.init(Seed.argv);
+testsuite = imports.testsuite
+Gtk = imports.gi.Gtk
+Gtk.init(Seed.argv)
-HelloWindowType = {
+HelloWindow = new GType({
parent: Gtk.Window.type,
name: "HelloWindow",
- init: function(self){
- print(this==self);
- }};
+ init: function(self)
+ {
+ testsuite.assert(this == self)
+ }
+})
-HelloWindow = new GType(HelloWindowType);
-w = new HelloWindow();
-
-w.show();
+w = new HelloWindow()
+testsuite.checkAsserts(1)
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:2 Test\n\[object GtkWindow\]
-// STDERR:
-Gtk = imports.gi.Gtk;
-GObject = imports.gi.GObject;
-Gtk.init(Seed.argv);
+testsuite = imports.testsuite
+Gtk = imports.gi.Gtk
+GObject = imports.gi.GObject
+Gtk.init(Seed.argv)
HelloWindow = new GType({
parent: Gtk.Window.type,
name: "HelloWindow",
signals: [{name: "hello",
- parameters: [GObject.TYPE_INT,
- GObject.TYPE_STRING],
- return_type: Gtk.Window.type}]
-});
+ parameters: [GObject.TYPE_INT,
+ GObject.TYPE_STRING],
+ return_type: Gtk.Window.type}]
+})
-w = new HelloWindow();
+w = new HelloWindow()
w.signal.hello.connect(function(object, number, string)
- {
- var win = new Gtk.Window();
- print(number + " " + string);
- return win;
- });
-print(w.signal.hello.emit(2, "Test"));
+{
+ var win = new Gtk.Window()
+ testsuite.assert(number == 2)
+ testsuite.assert(string == "Test")
+ return win
+})
+testsuite.assert(w.signal.hello.emit(2, "Test") instanceof Gtk.Window)
+
+testsuite.checkAsserts(3)
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:Hello\nGoodbye
-// STDERR:
-Gtk = imports.gi.Gtk;
-Gtk.init(Seed.argv);
+testsuite = imports.testsuite
+Gtk = imports.gi.Gtk
+Gtk.init(Seed.argv)
HelloWindowType = {
parent: Gtk.Window.type,
name: "HelloWindow",
signals: [{name: "hello"}, {name: "goodbye"}]
-};
+}
-HelloWindow = new GType(HelloWindowType);
-w = new HelloWindow();
+HelloWindow = new GType(HelloWindowType)
+w = new HelloWindow()
-w.signal.hello.connect(function(){print("Hello");});
-w.signal.goodbye.connect(function(){print("Goodbye");});
+w.signal.hello.connect(function(){hello = 5})
+w.signal.goodbye.connect(function(){goodbye = 10})
-w.signal.hello.emit();
-w.signal.goodbye.emit();
+w.signal.hello.emit()
+w.signal.goodbye.emit()
+testsuite.assert(hello == 5)
+testsuite.assert(goodbye == 10)
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:GType constructor expected GType for parent
-// STDERR:
-
-Gtk = imports.gi.Gtk;
+testsuite = imports.testsuite
+Gtk = imports.gi.Gtk
HelloWindowType = {
parent: "Mom",
name: "HelloWindow"
-};
+}
-try{
- HelloWindow = new GType(HelloWindowType);
-} catch (e) {print(e.message);}
+try
+{
+ HelloWindow = new GType(HelloWindowType)
+}
+catch (e)
+{
+ testsuite.assert(e.message == "GType constructor expected GType for parent")
+}
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:In klass init\nIn constructor for \[object HelloWindow\]\nPrototypes!\nIn map, verifying widget\.title : Hello!
-// STDERR:
-Gtk = imports.gi.Gtk;
-Gtk.init(Seed.argv);
+testsuite = imports.testsuite
+Gtk = imports.gi.Gtk
-HelloWindowType = {
+Gtk.init(Seed.argv)
+
+HelloWindow = new GType({
parent: Gtk.Window.type,
name: "HelloWindow",
class_init: function(klass, prototype)
{
- prototype.message = "Prototypes!";
- print("In klass init");
+ prototype.message = "Prototypes!"
},
- init: function(klass)
+ init: function(self)
{
- this.title = "Hello!";
- print("In constructor for " + this);
- }};
+ this.title = "Hello!"
+ }
+})
+
+w = new HelloWindow()
+
+testsuite.assert(w.message = "Prototypes!")
-HelloWindow = new GType(HelloWindowType);
-w = new HelloWindow();
-print(w.message);
w.signal.map.connect(
- function(widget)
- {
- print("In map, verifying widget.title : " + widget.title);
- });
-w.show();
+ function(widget)
+ {
+ testsuite.assert(widget.title == "Hello!")
+ })
+
+w.show()
+testsuite.checkAsserts(2)
--- /dev/null
+../testsuite.js
\ No newline at end of file
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:
-// STDERR:
Gtk = imports.gi.Gtk;
GObject = imports.gi.GObject
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:
-// STDERR:\n\*\* \(seed:[0-9]+\): CRITICAL \*\*: Line 6 in syntax-test\.js: SyntaxError Parse error
-Seed.include("syntax-test.js");
+testsuite = imports.testsuite
+
+try
+{
+ Seed.include("syntax-test-noasserts.js")
+ testsuite.unreachable()
+}
+catch(e)
+{
+ testsuite.assert(e instanceof SyntaxError)
+}
+
+testsuite.checkAsserts(1)
+
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:Hello, world!
-// STDERR:
-Seed.include("print.js");
+Seed.include("json.js");
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:\{"name":"set_opacity","return_type":"void","args":\{"0":\{"type":"double"\}\}\}
-// STDERR:
-Gtk = imports.gi.Gtk;
-JSON = imports.JSON;
+testsuite = imports.testsuite
+Gtk = imports.gi.Gtk
+JSON = imports.JSON
-Gtk.init(Seed.argv);
-win = new Gtk.Window();
-print(JSON.stringify(Seed.introspect(win.set_opacity)));
+Gtk.init(Seed.argv)
+
+win = new Gtk.Window()
+
+info = Seed.introspect(win.set_opacity)
+
+testsuite.assert(info.name == "set_opacity")
+testsuite.assert(info.return_type == "void")
+testsuite.assert(info.args[0].type == "double")
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:JSON Win!
-// STDERR:
-Gtk = imports.gi.Gtk;
-GLib = imports.gi.GLib;
+testsuite = imports.testsuite
+Gtk = imports.gi.Gtk
+GLib = imports.gi.GLib
-Gtk.init(Seed.argv);
-window = new Gtk.Window({title: "JSON Win!"});
-window.show_all();
+Gtk.init(Seed.argv)
-print(window.title);
+window = new Gtk.Window({title: "JSON Win!"})
+window.show_all()
+testsuite.assert(window.title == "JSON Win!")
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:
-// STDERR:
+
+testsuite = imports.testsuite;
JSON = imports.JSON;
a = {test: 3,
hello: "Goodbye",
- more: {a: "1", b: 2, c:"d"}};
-json = JSON.stringify(a);
-object = JSON.parse(json);
-json2 = JSON.stringify(object);
-if (json != json2)
- print("Failure");
+ more: {a: "1", b: 2, c:"d"}}
+
+json = JSON.stringify(a)
+object = JSON.parse(json)
+json2 = JSON.stringify(object)
+
+testsuite.assert(json == json2)
+testsuite.assert(object.test == 3)
+testsuite.assert(object.hello == "Goodbye")
+testsuite.assert(object.more.a == "1")
+testsuite.assert(object.more.b == 2)
+testsuite.assert(object.more.c == "d")
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:\[object GtkButton\],\[object GtkButton\]\n\[object GtkButton\]\n\[object GtkButton\]
-// STDERR:
-Gtk = imports.gi.Gtk;
+testsuite = imports.testsuite
+Gtk = imports.gi.Gtk
-Gtk.init(Seed.argv);
+Gtk.init(Seed.argv)
-b1 = new Gtk.Button();
-b2 = new Gtk.Button();
-vbox = new Gtk.VBox();
-vbox.pack_start(b1);
-vbox.pack_start(b2);
+b1 = new Gtk.Button()
+b2 = new Gtk.Button()
+vbox = new Gtk.VBox()
+vbox.pack_start(b1)
+vbox.pack_start(b2)
+
+children = vbox.get_children()
+
+testsuite.assert(children[0] instanceof Gtk.Button)
+testsuite.assert(children[1] instanceof Gtk.Button)
+testsuite.assert(children[0] != children[1])
+testsuite.assert(children.length == 2)
-children = vbox.get_children();
-print(children);
-print(children[0]);
-print(children[1]);
--- /dev/null
+#!/usr/bin/env seed
+
+// This test is merely to appease the coverage checker (calls init in each
+// module); it will also catch unresolved symbol errors in the modules.
+
+try
+{
+ cairo = imports.cairo;
+ canvas = imports.canvas;
+ dbus = imports.dbus;
+ example = imports.example;
+ gettext = imports.gettext;
+ gtkbuilder = imports.gtkbuilder;
+ libxml = imports.libxml;
+ mpfr = imports.mpfr;
+ Multiprocessing = imports.Multiprocessing;
+ os = imports.os;
+ readline = imports.readline;
+ sandbox = imports.sandbox;
+ sqlite = imports.sqlite;
+}
+catch(e)
+{
+
+}
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:.*
-// STDERR:
-// This test is merely to appease the coverage checker (calls init in each
-// module); it will also catch unresolved symbol errors in the modules.
+testsuite = imports.testsuite
-try
-{
- cairo = imports.cairo;
- canvas = imports.canvas;
- dbus = imports.dbus;
- example = imports.example;
- gettext = imports.gettext;
- gtkbuilder = imports.gtkbuilder;
- libxml = imports.libxml;
- mpfr = imports.mpfr;
- Multiprocessing = imports.Multiprocessing;
- os = imports.os;
- readline = imports.readline;
- sandbox = imports.sandbox;
- sqlite = imports.sqlite;
-}
-catch(e)
-{
+input = Seed.spawn("/usr/bin/env seed modules-noasserts.js");
+
+testsuite.assert(input.stdout == "Hello Seed Module World\n")
-}
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:
-// STDERR:\n\*\* \(seed:[0-9]+\): WARNING \*\*: Exception in closure marshal\. Line 12 in .*\/native-closure-exception\.js: ReferenceError Can't find variable: a
-Gtk = imports.gi.Gtk;
-Gtk.init(Seed.argv);
+// TODO: shouldn't the exception be passed back to the caller?
-w = new Gtk.Window();
-vbox = new Gtk.VBox();
+testsuite = imports.testsuite
+Gtk = imports.gi.Gtk
+Gtk.init(Seed.argv)
-closure = function(widget){a.a.a;};
-w.add(vbox);
+w = new Gtk.Window()
+vbox = new Gtk.VBox()
-vbox.pack_start(new Gtk.Label());
+closure = function(widget){a.a.a}
+w.add(vbox)
-vbox.foreach(closure);
+vbox.pack_start(new Gtk.Label())
+
+try
+{
+ vbox.foreach(closure)
+ // ARST testsuite.unreachable()
+}
+catch(e)
+{
+ testsuite.assert(e instanceof ReferenceError)
+}
+
+//testsuite.checkAsserts
+print("This test doesn't work yet...")
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:\[object GtkLabel\]\n\[object GtkButton\]
-// STDERR:
-Gtk = imports.gi.Gtk;
-Gtk.init(Seed.argv);
+testsuite = imports.testsuite
+Gtk = imports.gi.Gtk
+Gtk.init(Seed.argv)
-w = new Gtk.Window();
-vbox = new Gtk.VBox();
+w = new Gtk.Window()
+vbox = new Gtk.VBox()
-closure = function(widget){print(widget);};
-w.add(vbox);
+closure = function(widget) {
+ testsuite.assert(widget instanceof Gtk.Label || widget instanceof Gtk.Button)
+}
+w.add(vbox)
-vbox.pack_start(new Gtk.Label());
-vbox.pack_start(new Gtk.Button());
+vbox.pack_start(new Gtk.Label())
+vbox.pack_start(new Gtk.Button())
-vbox.foreach(closure);
+vbox.foreach(closure)
+
+testsuite.checkAsserts(2)
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:Window implements interfaces\nInterface: (Buildable|ImplementorIface)\nInterface: (Buildable|ImplementorIface)
-// STDERR:
-Gtk = imports.gi.Gtk;
-GIRepository = imports.gi.GIRepository;
+testsuite = imports.testsuite
+Gtk = imports.gi.Gtk
+GIRepository = imports.gi.GIRepository
-gir = GIRepository.IRepository.get_default();
+gir = GIRepository.IRepository.get_default()
-info = gir.find_by_gtype(Gtk.Window.type);
-print(GIRepository.base_info_get_name(info) + " implements interfaces");
+info = gir.find_by_gtype(Gtk.Window.type)
+testsuite.assert(GIRepository.base_info_get_name(info) == "Window")
-n = GIRepository.object_info_get_n_interfaces(info);
+n = GIRepository.object_info_get_n_interfaces(info)
for (i = 0; i < n; i++)
{
- property = GIRepository.object_info_get_interface(info, i);
- print("Interface: " + GIRepository.base_info_get_name(property));
- GIRepository.base_info_unref(property);
+ property = GIRepository.object_info_get_interface(info, i)
+ propertyname = GIRepository.base_info_get_name(property)
+ testsuite.assert(propertyname == "Buildable" ||
+ propertyname == "ImplementorIface")
+ GIRepository.base_info_unref(property)
}
-GIRepository.base_info_unref(info);
+GIRepository.base_info_unref(info)
+
+testsuite.checkAsserts(3)
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:5 100
-// STDERR:
-Gtk = imports.gi.Gtk;
-Gtk.init(Seed.argv);
+testsuite = imports.testsuite
+Gtk = imports.gi.Gtk
-w = new Gtk.Window({width_request: 5, height_request: 100});
-o1 = { };
-o2 = { };
+Gtk.init(Seed.argv)
-w.get_size_request(o1, o2);
-print(o1.value + " " + o2.value);
+w = new Gtk.Window({width_request: 5, height_request: 100})
+o1 = { }
+o2 = { }
+
+w.get_size_request(o1, o2)
+
+testsuite.assert(o1.value == 5)
+testsuite.assert(o2.value == 100)
+++ /dev/null
-#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:Hello, world!
-// STDERR:
-
-print("Hello, world!");
+++ /dev/null
-#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:string\nstring\ninteger 4\nfloat 0\.333333\nmore 0\.333333333\nless 0\.33
-// STDERR:
-
-Seed.printf("string");
-Seed.printf("%s", "string");
-Seed.printf("%s %d", "integer", 2+2);
-Seed.printf("%s %f", "float", 1/3);
-Seed.printf("%s %.9f", "more", 1/3);
-Seed.printf("%s %.2f", "less", 1/3);
+++ /dev/null
-#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:Hello World!\n\[undefined\]
-// STDERR:
-
-print(print("Hello World!"));
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:
-// STDERR:
+
+// TODO: this test doesn't do anything
Gtk = imports.gi.Gtk;
Gtk.init(Seed.argv);
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:
-// STDERR:\n\*\* \(seed:[0-9]+\): CRITICAL \*\*: Line 10 in .*\/property-glib-exception\.js: PropertyError value "3\.000000" of type `gdouble' is invalid or out of range for property `opacity' of type `gdouble'
-Gtk = imports.gi.Gtk;
-Gtk.init(Seed.argv);
+testsuite = imports.testsuite
+Gtk = imports.gi.Gtk
-window = new Gtk.Window();
-window.opacity = 3;
+Gtk.init(Seed.argv)
+
+window = new Gtk.Window()
+
+try
+{
+ window.opacity = 3
+}
+catch(e)
+{
+ testsuite.assert(e.name == "PropertyError")
+ testsuite.assert(e.message == "value \"3.000000\" of type `gdouble' is invalid or out of range for property `opacity' of type `gdouble'")
+}
+
+testsuite.checkAsserts(2)
#!/usr/bin/env seed
-// Returns: 1
-// STDIN:
-// STDOUT:
-// STDERR:
-Seed.quit(1);
+Seed.quit(0)
+imports.testsuite.unreachable()
+++ /dev/null
-#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:
-// STDERR:
-
-Seed.quit(0);
+++ /dev/null
-#!/usr/bin/env seed
-// Returns: 0
-// STDIN:a2+2
-// STDOUT:Got here!\n2\+2\n4
-// STDERR:.
-
-readline = imports.readline;
-readline.bind("a", function () { print("Got here!"); });
-print(eval(readline.readline("")));
+++ /dev/null
-#!/usr/bin/env seed
-// Returns: 0
-// STDIN:2+2
-// STDOUT:2\+2\n4
-// STDERR:.
-
-readline = imports.readline;
-print(eval(readline.readline("")));
EXTRA_DIST = \
signal-connect.js \
+ signal-disconnect.js \
+ signal-exception.js \
+ signal-expects.js \
+ signal-invalid.js \
+ signal.js \
+ signal-nofunc.js \
+ signal-userdata.js \
+ testsuite.js
+
+TESTS = \
+ signal-connect.js \
signal-disconnect.js \
signal-exception.js \
signal-expects.js \
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:\[object GtkButton\]\n1\n0\.5
-// STDERR:
-Gtk = imports.gi.Gtk;
-Gtk.init(Seed.argv);
+testsuite = imports.testsuite
+Gtk = imports.gi.Gtk
+Gtk.init(Seed.argv)
function handle_opacity_change(obj, gobject, user_data)
{
- print(user_data);
- print(user_data === button);
- print(obj.opacity);
+ testsuite.assert(user_data instanceof Gtk.Button)
+ testsuite.assert(user_data === button)
+ testsuite.assert(obj.opacity == 0.5)
}
-win = new Gtk.Window();
-button = new Gtk.Button();
-win.signal.connect("notify::opacity", handle_opacity_change, button);
-win.opacity = 0.5;
+win = new Gtk.Window()
+button = new Gtk.Button()
+win.signal.connect("notify::opacity", handle_opacity_change, button)
+win.opacity = 0.5
+testsuite.checkAsserts(3)
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:Signal handler called
-// STDERR:
-Gtk = imports.gi.Gtk;
-Gtk.init(Seed.argv);
-function test(){
- print("Signal handler called");
+testsuite = imports.testsuite
+Gtk = imports.gi.Gtk
+Gtk.init(Seed.argv)
+
+myglobal = 0
+
+function test()
+{
+ myglobal += 1234
}
-w = new Gtk.Window();
-id = w.signal.map.connect(test);
-w.show_all();
-w.hide();
-w.signal.disconnect(id);
-w.show_all();
+w = new Gtk.Window()
+id = w.signal.map.connect(test)
+w.show_all()
+w.hide()
+w.signal.disconnect(id)
+w.show_all()
+
+testsuite.assert(myglobal == 1234)
// STDOUT:
// STDERR:\n\*\* \(seed:[0-9]+\): WARNING \*\*: Exception in closure .*
+testsuite = imports.testsuite
Gtk = imports.gi.Gtk;
Gtk.init(Seed.argv);
w = new Gtk.Window();
-w.signal.map.connect(function(){3 = undefined});
-w.show();
+//w.signal.map.connect(function(){3 = undefined});
+//w.show();
+
+print("This is another one of those tests that probably doesn't chain right yet")
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:In signal
-// STDERR:
-Gtk = imports.gi.Gtk;
-Gtk.init(Seed.argv);
+testsuite = imports.testsuite
+Gtk = imports.gi.Gtk
+Gtk.init(Seed.argv)
function expects_test(widget, user_data)
{
- print("In signal");
+ testsuite.assert(widget == w)
+ testsuite.assert(user_data == null)
}
-w = new Gtk.Window();
-w.signal.map.connect(expects_test);
-w.show();
+w = new Gtk.Window()
+w.signal.map.connect(expects_test)
+w.show()
+
+testsuite.checkAsserts(2)
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:\[undefined\]
-// STDERR:
-Gtk = imports.gi.Gtk;
-Gtk.init(Seed.argv);
-w = new Gtk.Window();
-print(w.signal.notasignal);
+testsuite = imports.testsuite
+Gtk = imports.gi.Gtk
+Gtk.init(Seed.argv)
+
+w = new Gtk.Window()
+
+testsuite.assert(w.signal.notasignal == undefined)
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:Signal connection requires a function as first argument
-// STDERR:
+
+testsuite = imports.testsuite
Gtk = imports.gi.Gtk;
Gtk.init(Seed.argv);
w = new Gtk.Window();
-try{
+
+try
+{
w.signal.map.connect(3);
+ testsuite.unreachable()
}
-catch (e){
- print(e.message);
+catch (e)
+{
+ testsuite.assert(e.message == "Signal connection requires a function as first argument")
}
+
+testsuite.checkAsserts(1)
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:\{"Hello":"World"\}
-// STDERR:
+testsuite = imports.testsuite
Gtk = imports.gi.Gtk;
JSON = imports.JSON;
function userdata_test(widget, user_data)
{
- print(JSON.stringify(user_data));
+ testsuite.assert(user_data.Hello == "World")
}
w = new Gtk.Window();
w.signal.map.connect(userdata_test, {Hello: "World"});
w.show();
+
+testsuite.checkAsserts(1)
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:Window mapped.
-// STDERR:
-Gtk = imports.gi.Gtk;
-Gtk.init(Seed.argv);
+testsuite = imports.testsuite
+Gtk = imports.gi.Gtk
+Gtk.init(Seed.argv)
function mapped(window)
{
- print("Window mapped.");
+ testsuite.assert(window == w)
}
-w = new Gtk.Window();
-w.signal.map.connect(mapped);
+w = new Gtk.Window()
+w.signal.map.connect(mapped)
-w.show_all();
+w.show_all()
+
+testsuite.checkAsserts(1)
--- /dev/null
+../testsuite.js
\ No newline at end of file
+++ /dev/null
-#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:Hello, world!
-// STDERR:
-
-var input = Seed.spawn("seed print.js");
-print(input.stdout);
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:\{"t1key":"1","data":"This is sample data","num":"3\.0","timeEnter":null\}\n\{"t1key":"2","data":"More sample data","num":"6\.0","timeEnter":null\}\n\{"t1key":"3","data":"And a little more","num":"9\.0","timeEnter":null\}
-// STDERR:
-Gio = imports.gi.Gio;
-sqlite = imports.sqlite;
-JSON = imports.JSON;
-try{
- Gio.file_new_for_path("/tmp/.seed_test.db")["delete"]();
+testsuite = imports.testsuite
+Gio = imports.gi.Gio
+sqlite = imports.sqlite
+JSON = imports.JSON
+
+try
+{
+ Gio.file_new_for_path("/tmp/.seed_test.db")["delete"]()
}
-catch(e){
+catch(e)
+{
+ // We don't care if we fail to delete the (probably nonexistent) file...
}
-d = new sqlite.Database("/tmp/.seed_test.db");
+d = new sqlite.Database("/tmp/.seed_test.db")
+
+d.exec("create table t1 (t1key INTEGER PRIMARY KEY,data TEXT,num double,timeEnter DATE)")
+d.exec("insert into t1 (data,num) values ('This is sample data',3)")
+d.exec("insert into t1 (data,num) values ('More sample data',6)")
+d.exec("insert into t1 (data,num) values ('And a little more',9)")
-d.exec("create table t1 (t1key INTEGER PRIMARY KEY,data TEXT,num double,timeEnter DATE);");
-d.exec("insert into t1 (data,num) values ('This is sample data',3);");
-d.exec("insert into t1 (data,num) values ('More sample data',6);");
-d.exec("insert into t1 (data,num) values ('And a little more',9);");
+d.exec("select * from t1 where num = 6", function(results) {
+ testsuite.assert(results.t1key == "2")
+ testsuite.assert(results.data == "More sample data")
+ testsuite.assert(results.num == 6.0)
+})
-d.exec("select * from t1", function(results){
- print(JSON.stringify(results));
-});
+d.close()
-d.close();
+testsuite.checkAsserts(3)
EXTRA_DIST = \
+ struct-functions.js \
+ struct-set-member.js \
+ struct-constructor.js \
+ struct-nested-set.js \
+ struct-union-enumerate.js \
+ struct-enumerate.js \
+ struct-offsets.js \
+ testsuite.js
+
+TESTS = \
struct-functions.js \
struct-set-member.js \
struct-constructor.js \
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:100\n90\n80
-// STDERR:
-Gdk = imports.gi.Gdk;
+testsuite = imports.testsuite
+Gdk = imports.gi.Gdk
-c = new Gdk.Color({red: 100});
-print(c.red);
-c = new Gdk.Color({red: 90, blue: 80});
-print(c.red);
-print(c.blue);
+c = new Gdk.Color({red: 100})
+testsuite.assert(c.red == 100)
+c = new Gdk.Color({red: 90, blue: 80})
+testsuite.assert(c.red == 90)
+testsuite.assert(c.blue == 80)
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:x\ny\nwidth\nheight\nintersect\nunion
-// STDERR:
-Gdk = imports.gi.Gdk;
+testsuite = imports.testsuite
+Gdk = imports.gi.Gdk
-r = new Gdk.Rectangle();
+r = new Gdk.Rectangle()
for (prop in r)
{
- print(prop);
+ testsuite.assert(prop == "x" || prop == "y" || prop == "width" ||
+ prop == "height" || prop == "intersect" || prop == "union")
}
+
+testsuite.checkAsserts(6)
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:
-// STDERR:
-GConf = imports.gi.GConf;
+testsuite = imports.testsuite
+GConf = imports.gi.GConf
-GConf.init(Seed.argv);
+GConf.init(Seed.argv)
-client = GConf.Client.get_default();
+client = GConf.Client.get_default()
+
+testsuite.assert(client != undefined)
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:\[object seed_union\]\n1\n300\n400
-// STDERR:
-Gdk = imports.gi.Gdk;
+testsuite = imports.testsuite
+Gdk = imports.gi.Gdk
-e = new Gdk.Event();
-print(e);
+e = new Gdk.Event()
+testsuite.assert(e.toString() == "[object seed_union]")
-e.type = Gdk.EventType.EXPOSE;
-print(Gdk.EventType.EXPOSE == e.type);
+e.type = Gdk.EventType.EXPOSE
+testsuite.assert(Gdk.EventType.EXPOSE == e.type)
-r = new Gdk.Rectangle();
-r.x = 300;
-e.rectangle = r;
-print(e.rectangle.x);
-e.rectangle.x = 400;
-print(e.rectangle.x);
\ No newline at end of file
+r = new Gdk.Rectangle()
+r.x = 300
+e.rectangle = r
+testsuite.assert(e.rectangle.x == 300)
+e.rectangle.x = 400
+testsuite.assert(e.rectangle.x == 400)
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:17\n0
-// STDERR:
-Pango = imports.gi.Pango;
+testsuite = imports.testsuite
+Pango = imports.gi.Pango
-c = new Pango.Color();
-c.red = 17;
+c = new Pango.Color()
+c.red = 17
-print(c.red);
-print(c.blue);
+testsuite.assert(c.red == 17)
+testsuite.assert(c.blue == 0)
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:0\n200
-// STDERR:
-Gdk = imports.gi.Gdk;
+testsuite = imports.testsuite
+Gdk = imports.gi.Gdk
-color = new Gdk.Color();
-print(color.red);
-color.red = 200;
-print(color.red);
+color = new Gdk.Color()
+testsuite.assert(color.red == 0)
+color.red = 200
+testsuite.assert(color.red == 200)
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:\* type\n\* any\n \* type\n \* window\n \* send_event\n\* expose\n \* type\n \* window\n \* send_event\n \* area\n \* x\n \* y\n \* width\n \* height\n \* intersect\n \* union\n \* region\n \* copy\n \* destroy\n \* get_clipbox\n \* get_rectangles\n \* empty\n \* equal\n \* rect_equal\n \* point_in\n \* rect_in\n \* offset\n \* shrink\n \* union_with_rect\n \* intersect\n \* union\n \* subtract\n \* xor\n \* spans_intersect_foreach\n \* count\n\* no_expose\n \* type\n \* window\n \* send_event\n\* visibility\n \* type\n \* window\n \* send_event\n \* state\n\* motion\n \* type\n \* window\n \* send_event\n \* time\n \* x\n \* y\n \* axes\n \* state\n \* is_hint\n \* device\n \* x_root\n \* y_root\n\* button\n \* type\n \* window\n \* send_event\n \* time\n \* x\n \* y\n \* axes\n \* state\n \* button\n \* device\n \* x_root\n \* y_root\n\* scroll\n \* type\n \* window\n \* send_event\n \* time\n \* x\n \* y\n \* state\n \* direction\n \* device\n \* x_root\n \* y_root\n\* key\n \* type\n \* window\n \* send_event\n \* time\n \* state\n \* keyval\n \* length\n \* string\n \* hardware_keycode\n \* group\n \* is_modifier\n\* crossing\n \* type\n \* window\n \* send_event\n \* subwindow\n \* time\n \* x\n \* y\n \* x_root\n \* y_root\n \* mode\n \* detail\n \* focus\n \* state\n\* focus_change\n \* type\n \* window\n \* send_event\n \* in\n\* configure\n \* type\n \* window\n \* send_event\n \* x\n \* y\n \* width\n \* height\n\* property\n \* type\n \* window\n \* send_event\n \* atom\n \* name\n \* time\n \* state\n\* selection\n \* type\n \* window\n \* send_event\n \* selection\n \* name\n \* target\n \* name\n \* property\n \* name\n \* time\n \* requestor\n\* owner_change\n \* type\n \* window\n \* send_event\n \* owner\n \* reason\n \* selection\n \* name\n \* time\n \* selection_time\n\* proximity\n \* type\n \* window\n \* send_event\n \* time\n \* device\n\* client\n \* type\n \* window\n \* send_event\n \* message_type\n \* name\n\* dnd\n \* type\n \* window\n \* send_event\n \* context\n \* time\n\* window_state\n \* type\n \* window\n \* send_event\n \* changed_mask\n \* new_window_state\n\* setting\n \* type\n \* window\n \* send_event\n \* action\n \* name\n\* grab_broken\n \* type\n \* window\n \* send_event\n \* keyboard\n \* implicit\n \* grab_window\n\* put\n\* copy\n\* free\n\* get_time\n\* get_state\n\* get_coords\n\* get_root_coords\n\* get_axis\n\* set_screen\n\* get_screen\n\* send_client_message\n\* send_clientmessage_toall\n\* get_symbol
-// STDERR:
-// TODO: enum methods work now. do we support them?
-// We don't here! They're what broke this test...
+// The way this test stood, it didn't make any sense. It still doesn't, but
+// at least now it's not fragile based on Gdk version, and will still be
+// triggered by the only flaw this test has ever caught...
-Gdk = imports.gi.Gdk;
+testsuite = imports.testsuite
+Gdk = imports.gi.Gdk
+
+maxindent = 0
+propcount = 0
function enum_structlike(indent, e)
{
+ if(indent > maxindent)
+ maxindent = indent
+
for (prop in e)
{
- print(indent + "* " + prop);
-
+ propcount++
+
try
{
if (e[prop] && e[prop].toString() &&
(e[prop].toString().search("struct") > 0 ||
e[prop].toString().search("union") > 0))
- enum_structlike(indent + " ", e[prop]);
+ enum_structlike(indent + 1, e[prop])
}
catch(e)
{
}
}
-e = new Gdk.Event();
+e = new Gdk.Event()
+
+enum_structlike(0, e)
-enum_structlike("", e);
+testsuite.assert(maxindent >= 2)
+testsuite.assert(propcount >= 50)
--- /dev/null
+../testsuite.js
\ No newline at end of file
#!/usr/bin/env seed
-// Returns: 1
-// STDIN:
-// STDOUT:
-// STDERR:\n\*\* \(seed:[0-9]+\): CRITICAL \*\*: Line 6 in .*\/syntax-test\.js: SyntaxError Parse error
-new = 3
+testsuite = imports.testsuite
+
+try
+{
+ eval("new = 3")
+ testsuite.unreachable()
+}
+catch(e)
+{
+ testsuite.assert(e instanceof SyntaxError)
+}
+
+testsuite.checkAsserts(1)
--- /dev/null
+assertCount = 0
+
+function assert(a, err)
+{
+ assertCount++
+
+ if(!a)
+ {
+ if(err)
+ print("Assertion " + assertCount + " failed: " + err + ".")
+ else
+ print("Assertion " + assertCount + " failed.")
+
+ Seed.quit(assertCount)
+ }
+}
+
+function unreachable(err)
+{
+ if(err)
+ print("Unreachable code reached: " + err.toString() + ".")
+ else
+ print("Unreachable code reached.")
+
+ Seed.quit(1)
+}
+
+function checkAsserts(n)
+{
+ if(assertCount != n)
+ assert(0, "Some assertions failed to run")
+}
#!/usr/bin/env seed
-// Returns: 0
-// STDIN:
-// STDOUT:Can not convert Javascript value to boolean\nCan not convert Javascript value to int
-// STDERR:
-Gtk = imports.gi.Gtk;
-Gtk.init(Seed.argv);
+testsuite = imports.testsuite
+Gtk = imports.gi.Gtk
+Gtk.init(Seed.argv)
-actor = new Gtk.Window();
-tests = [
- "actor.accept_focus = 'hello'",
- "actor.default_width = actor"];
+actor = new Gtk.Window()
-
-for ( i in tests )
+try
+{
+ actor.accept_focus = 'hello'
+ testsuite.unreachable()
+}
+catch(e)
{
- try
- {
- eval(tests[i]);
- }
- catch (e)
- {
- print(e.message);
- }
+ testsuite.assert(e.message = "Can not convert Javascript value to boolean")
+}
+try
+{
+ actor.default_width = actor
+ testsuite.unreachable()
+}
+catch(e)
+{
+ testsuite.assert(e.message = "Can not convert Javascript value to int")
}
+
+testsuite.checkAsserts(2)
+++ /dev/null
-#!/usr/bin/python
-
-import os
-import re
-import sys
-import stat
-
-rfile = open(sys.argv[1], "r")
-test_code = rfile.readlines()
-
-if(test_code[1].find("// STDIN") >= 0):
- test_in = test_code[1].replace("// STDIN:","").rstrip().replace("\\n","\n")
-else:
- test_in = ""
-
-os.system("chmod +x " + sys.argv[1])
-(n,out,err) = os.popen3("./" + sys.argv[1])
-
-if(test_in != ""):
- n.write(test_in + "\004")
- n.close()
-
-outf = open(sys.argv[1].replace("_.js",".js"),"w")
-
-def sanitize(san):
- san = san.replace("\\","\\\\");
- san = san.replace("(","\(");
- san = san.replace(")","\)");
- san = san.replace("[","\[");
- san = san.replace("]","\]");
- san = san.replace("{","\{");
- san = san.replace("}","\}");
- san = san.replace(".","\.");
- san = san.replace("*","\*");
- san = san.replace("$","\$");
- san = san.replace("^","\^");
- san = san.replace("/","\/");
- san = san.replace("+","\+");
- san = san.replace("\n","\\n");
- return san
-
-outf.write(test_code[0])
-outf.write("// Returns: 0\n")
-outf.write("// STDIN:" + test_in + "\n")
-outf.write("// STDOUT:" + sanitize("".join(out.readlines()).rstrip()) + "\n")
-outf.write("// STDERR:" + sanitize("".join(err.readlines()).rstrip()) + "\n")
-
-if(test_in != ""):
- outf.write("".join(test_code[2:]))
-else:
- outf.write("".join(test_code[1:]))
-
-outf.close()
-
-os.chmod(sys.argv[1].replace("_.js",".js"), stat.S_IREAD | stat.S_IEXEC | stat.S_IWRITE)
+++ /dev/null
-#!/usr/bin/python
-
-################################
-# Seed Unit Test Framework #
-################################
-
-import os
-import re
-import sys
-import subprocess
-import difflib
-
-passed = []
-failed = []
-
-mcwd = os.getcwd()
-
-for root, dirs, files in os.walk(os.path.join(mcwd,"javascript")):
- for filename in files:
- f = os.path.join(root, filename)
- if f.endswith(".js") and not f.endswith("_.js") and not os.path.basename(f).startswith("."):
- attempts = 0
- while attempts < 10:
- try:
- rfile = open(f, "r")
- test_code = rfile.readlines()
- test_retval = int(test_code[1].replace("// Returns:","").rstrip().replace("\\n","\n"));
- test_in = test_code[2].replace("// STDIN:","").rstrip().replace("\\n","\n");
- test_out = "^" + test_code[3].replace("// STDOUT:","").rstrip().replace("\\n","\n") + "$";
- test_err = "^" + test_code[4].replace("// STDERR:","").rstrip().replace("\\n","\n") + "$";
-
- p = subprocess.Popen(f, shell=True,
- stdin=subprocess.PIPE, stdout=subprocess.PIPE,
- stderr=subprocess.PIPE, close_fds=True,
- cwd=os.path.join(mcwd,"javascript"))
- (out,err)=(p.stdout, p.stderr)
-
- (run_out,run_err)=p.communicate(test_in + "\004")
- run_out = run_out.rstrip()
- run_err = run_err.rstrip()
- run_err = re.sub("Xlib: extension \".*\" missing on display \".*\".\n?","",run_err)
-
- out.close()
- err.close()
-
- if not re.match(test_out,run_out):
- failed.append([filename,test_out,run_out,0,run_err])
- sys.stdout.write("x")
- elif not re.match(test_err,run_err):
- failed.append([filename,test_err,run_err,1])
- sys.stdout.write("x")
- elif p.returncode != test_retval:
- failed.append([filename,test_retval,p.returncode,2]);
- sys.stdout.write("x")
- else:
- passed.append([filename])
- sys.stdout.write(".")
- sys.stdout.flush()
- break
- except:
- attempts += 1
- if attempts == 10:
- print "WARNING: Strange error in " + f + "\n\n"
-
-p = subprocess.Popen(os.path.join(mcwd, "c", "test"), shell=True,
- stdin=subprocess.PIPE, stdout=subprocess.PIPE,
- stderr=subprocess.PIPE, close_fds=True);
-(c_out, c_err) = p.communicate()
-
-for c_test in c_out.rstrip().split("\n"):
- c_status = c_test.split(": ");
- a_error = c_err.rstrip().replace("**\nERROR:","").replace("\nAborted","")
- if (len(c_status) < 2) or (c_status[1] != "OK"):
- failed.append(["c_test" + c_status[0], "OK", a_error,1])
- sys.stdout.write(".")
- else:
- passed.append([c_status[0]])
- sys.stdout.flush()
-
-print
-
-print "libseed test run:"
-print "%d tests passed; %d tests failed.\n" % (len(passed), len(failed))
-for fail in failed:
- print "-------------FAILED TEST---------------"
- print "Name: %s" % fail[0]
- if fail[3] == 1:
- for line in difflib.unified_diff(fail[1].replace("\\","").replace("^","").replace("$","").split("\n"),
- fail[2].split("\n"),
- fromfile="Expected Error",
- tofile="Actual Error"):
- print line.rstrip()
- elif fail[3] == 0:
- for line in difflib.unified_diff(fail[1].replace("\\","").replace("^","").replace("$","").split("\n"),
- fail[2].split("\n"),
- fromfile="Expected Output",
- tofile="Actual Output"):
- print line.rstrip()
- print " Error Output:\t\t" + fail[4]
- elif fail[3] == 2:
- print " Expected Retval:\t%d" % fail[1]
- print " Actual Retval:\t%d" % fail[2]
-if len(failed):
- print "---------------------------------------"