[gjs/wip/jsversion: 6/7] gjs-unit: Pull in JS version from header in tests; add version to tests



commit 89a4efe6350c742aa7dbaecde33d5cca4b5c8e16
Author: Colin Walters <walters verbum org>
Date:   Sat Dec 4 15:48:00 2010 -0500

    gjs-unit: Pull in JS version from header in tests; add version to tests
    
    For now, explicitly specify all tests as being "application/javascript;version=1.8".
    We will back down some of the tests to default soon.

 test/gjs-unit.c                       |    9 ++++++++-
 test/js/modules/alwaysThrows.js       |    1 +
 test/js/modules/foobar.js             |    1 +
 test/js/modules/mutualImport/a.js     |    1 +
 test/js/modules/mutualImport/b.js     |    1 +
 test/js/modules/subA/subB/__init__.js |    1 +
 test/js/modules/subA/subB/foobar.js   |    1 +
 test/js/test0010basic.js              |    1 +
 test/js/test0020importer.js           |    1 +
 test/js/test0030basicBoxed.js         |    1 +
 test/js/test0040mainloop.js           |    1 +
 test/js/testByteArray.js              |    1 +
 test/js/testCairo.js                  |    1 +
 test/js/testDbus.js                   |    1 +
 test/js/testEverythingBasic.js        |    1 +
 test/js/testEverythingEncapsulated.js |    1 +
 test/js/testGI.js                     |    1 +
 test/js/testGIMarshalling.js          |    1 +
 test/js/testImporter.js               |    1 +
 test/js/testLang.js                   |    1 +
 test/js/testLocale.js                 |    1 +
 test/js/testMainloop.js               |    1 +
 test/js/testSignals.js                |    1 +
 test/js/testTweener.js                |    1 +
 test/js/testself.js                   |    1 +
 25 files changed, 32 insertions(+), 1 deletions(-)
---
diff --git a/test/gjs-unit.c b/test/gjs-unit.c
index 1b561c7..c605bf8 100644
--- a/test/gjs-unit.c
+++ b/test/gjs-unit.c
@@ -47,11 +47,18 @@ setup(GjsTestJSFixture *fix,
     int code;
     char *filename;
     char *search_path[2];
+    const char *test_filename = test_data;
+    const char *js_version;
+
+    js_version = gjs_context_scan_file_for_js_version(test_filename);
 
     search_path[0] = g_build_filename(top_srcdir, "test", "modules", NULL);
     search_path[1] = NULL;
 
-    fix->context = gjs_context_new_with_search_path(search_path);
+    fix->context = g_object_new (GJS_TYPE_CONTEXT,
+                                 "search-path", search_path,
+                                 "js-version", js_version,
+                                 NULL);
     g_free(search_path[0]);
 
     /* Load jsUnit.js directly into global scope, rather than
diff --git a/test/js/modules/alwaysThrows.js b/test/js/modules/alwaysThrows.js
index 50af1ff..cd0e9db 100644
--- a/test/js/modules/alwaysThrows.js
+++ b/test/js/modules/alwaysThrows.js
@@ -1,3 +1,4 @@
+// application/javascript;version=1.8
 // line 0
 // line 1
 // line 2
diff --git a/test/js/modules/foobar.js b/test/js/modules/foobar.js
index cdd5cad..ab9a84c 100644
--- a/test/js/modules/foobar.js
+++ b/test/js/modules/foobar.js
@@ -1,3 +1,4 @@
+// application/javascript;version=1.8
 // simple test module (used by testImporter.js)
 
 var foo = "This is foo";
diff --git a/test/js/modules/mutualImport/a.js b/test/js/modules/mutualImport/a.js
index c5fd069..5f03f7b 100644
--- a/test/js/modules/mutualImport/a.js
+++ b/test/js/modules/mutualImport/a.js
@@ -1,3 +1,4 @@
+// application/javascript;version=1.8
 const B = imports.mutualImport.b;
 
 let count = 0;
diff --git a/test/js/modules/mutualImport/b.js b/test/js/modules/mutualImport/b.js
index b6443b1..732465d 100644
--- a/test/js/modules/mutualImport/b.js
+++ b/test/js/modules/mutualImport/b.js
@@ -1,3 +1,4 @@
+// application/javascript;version=1.8
 const A = imports.mutualImport.a;
 
 function getCount() {
diff --git a/test/js/modules/subA/subB/__init__.js b/test/js/modules/subA/subB/__init__.js
index c7660dc..0bab842 100644
--- a/test/js/modules/subA/subB/__init__.js
+++ b/test/js/modules/subA/subB/__init__.js
@@ -1,3 +1,4 @@
+// application/javascript;version=1.8
 function testImporterFunction() {
     return "__init__ function tested";
 }
diff --git a/test/js/modules/subA/subB/foobar.js b/test/js/modules/subA/subB/foobar.js
index cdd5cad..ab9a84c 100644
--- a/test/js/modules/subA/subB/foobar.js
+++ b/test/js/modules/subA/subB/foobar.js
@@ -1,3 +1,4 @@
+// application/javascript;version=1.8
 // simple test module (used by testImporter.js)
 
 var foo = "This is foo";
diff --git a/test/js/test0010basic.js b/test/js/test0010basic.js
index 30bb07b..47812fa 100644
--- a/test/js/test0010basic.js
+++ b/test/js/test0010basic.js
@@ -1,3 +1,4 @@
+// application/javascript;version=1.8
 function testBasic1() {
     var foo = 1+1;
     log("1 + 1 = " + foo);
diff --git a/test/js/test0020importer.js b/test/js/test0020importer.js
index 8ca444e..42a33de 100644
--- a/test/js/test0020importer.js
+++ b/test/js/test0020importer.js
@@ -1,3 +1,4 @@
+// application/javascript;version=1.8
 function testImporter1() {
     var GLib = imports.gi.GLib;
     assertEquals(GLib.MAJOR_VERSION, 2);
diff --git a/test/js/test0030basicBoxed.js b/test/js/test0030basicBoxed.js
index 35ec43b..57dbbe3 100644
--- a/test/js/test0030basicBoxed.js
+++ b/test/js/test0030basicBoxed.js
@@ -1,3 +1,4 @@
+// application/javascript;version=1.8
 var Regress = imports.gi.Regress;
 
 function testBasicBoxed() {
diff --git a/test/js/test0040mainloop.js b/test/js/test0040mainloop.js
index e1d3479..0b49a3f 100644
--- a/test/js/test0040mainloop.js
+++ b/test/js/test0040mainloop.js
@@ -1,3 +1,4 @@
+// application/javascript;version=1.8
 var Mainloop = imports.mainloop;
 
 function testBasicMainloop() {
diff --git a/test/js/testByteArray.js b/test/js/testByteArray.js
index 3ead00d..3cfcb33 100644
--- a/test/js/testByteArray.js
+++ b/test/js/testByteArray.js
@@ -1,3 +1,4 @@
+// application/javascript;version=1.8
 // tests for imports.lang module
 
 const ByteArray = imports.byteArray;
diff --git a/test/js/testCairo.js b/test/js/testCairo.js
index 65837ed..56307cd 100644
--- a/test/js/testCairo.js
+++ b/test/js/testCairo.js
@@ -1,3 +1,4 @@
+// application/javascript;version=1.8
 const Cairo = imports.cairo;
 
 function _ts(obj) {
diff --git a/test/js/testDbus.js b/test/js/testDbus.js
index 8f503ea..1794040 100644
--- a/test/js/testDbus.js
+++ b/test/js/testDbus.js
@@ -1,3 +1,4 @@
+// application/javascript;version=1.8
 const DBus = imports.dbus;
 const Mainloop = imports.mainloop;
 
diff --git a/test/js/testEverythingBasic.js b/test/js/testEverythingBasic.js
index 0730eba..79dcb34 100644
--- a/test/js/testEverythingBasic.js
+++ b/test/js/testEverythingBasic.js
@@ -1,3 +1,4 @@
+// application/javascript;version=1.8
 // This used to be called "Everything"
 const Everything = imports.gi.Regress;
 if (!('assertEquals' in this)) { /* allow running this test standalone */
diff --git a/test/js/testEverythingEncapsulated.js b/test/js/testEverythingEncapsulated.js
index 2e4a1b3..a3a6742 100644
--- a/test/js/testEverythingEncapsulated.js
+++ b/test/js/testEverythingEncapsulated.js
@@ -1,3 +1,4 @@
+// application/javascript;version=1.8
 // This used to be called "Everything"
 const Everything = imports.gi.Regress;
 if (!('assertEquals' in this)) { /* allow running this test standalone */
diff --git a/test/js/testGI.js b/test/js/testGI.js
index 08852ee..a88bd0f 100644
--- a/test/js/testGI.js
+++ b/test/js/testGI.js
@@ -1,3 +1,4 @@
+// application/javascript;version=1.8
 function testUTF8() {
     const GLib = imports.gi.GLib;
 
diff --git a/test/js/testGIMarshalling.js b/test/js/testGIMarshalling.js
index 49ec4ca..5d74e95 100644
--- a/test/js/testGIMarshalling.js
+++ b/test/js/testGIMarshalling.js
@@ -1,3 +1,4 @@
+// application/javascript;version=1.8
 const GIMarshallingTests = imports.gi.GIMarshallingTests;
 
 // We use Gio to have some objects that we know exist
diff --git a/test/js/testImporter.js b/test/js/testImporter.js
index bd1cd4f..5022105 100644
--- a/test/js/testImporter.js
+++ b/test/js/testImporter.js
@@ -1,3 +1,4 @@
+// application/javascript;version=1.8
 function testImporter() {
 
     assertNotUndefined(imports);
diff --git a/test/js/testLang.js b/test/js/testLang.js
index b78b775..3ab3474 100644
--- a/test/js/testLang.js
+++ b/test/js/testLang.js
@@ -1,3 +1,4 @@
+// application/javascript;version=1.8
 // tests for imports.lang module
 
 const Lang = imports.lang;
diff --git a/test/js/testLocale.js b/test/js/testLocale.js
index 214b5e6..48ab4f9 100644
--- a/test/js/testLocale.js
+++ b/test/js/testLocale.js
@@ -1,3 +1,4 @@
+// application/javascript;version=1.8
 // tests for JS_SetLocaleCallbacks().
 
 function testToLocaleDateString() {
diff --git a/test/js/testMainloop.js b/test/js/testMainloop.js
index 991f3e7..09d22af 100644
--- a/test/js/testMainloop.js
+++ b/test/js/testMainloop.js
@@ -1,3 +1,4 @@
+// application/javascript;version=1.8
 const Mainloop = imports.mainloop;
 
 function testTimeout() {
diff --git a/test/js/testSignals.js b/test/js/testSignals.js
index 9cfdd8f..30bd254 100644
--- a/test/js/testSignals.js
+++ b/test/js/testSignals.js
@@ -1,3 +1,4 @@
+// application/javascript;version=1.8
 const Signals = imports.signals;
 
 function Foo() {
diff --git a/test/js/testTweener.js b/test/js/testTweener.js
index ec22a00..6761875 100644
--- a/test/js/testTweener.js
+++ b/test/js/testTweener.js
@@ -1,3 +1,4 @@
+// application/javascript;version=1.8
 const Tweener = imports.tweener.tweener;
 const Mainloop = imports.mainloop;
 
diff --git a/test/js/testself.js b/test/js/testself.js
index f9df73a..918a6d9 100644
--- a/test/js/testself.js
+++ b/test/js/testself.js
@@ -1,3 +1,4 @@
+// application/javascript;version=1.8
 var someUndefined;
 var someNumber = 1;
 var someOtherNumber = 42;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]