gjs r63 - in trunk: . test/js
- From: tko svn gnome org
- To: svn-commits-list gnome org
- Subject: gjs r63 - in trunk: . test/js
- Date: Wed, 29 Oct 2008 11:34:05 +0000 (UTC)
Author: tko
Date: Wed Oct 29 11:34:05 2008
New Revision: 63
URL: http://svn.gnome.org/viewvc/gjs?rev=63&view=rev
Log:
Bug 558115 â Add test for basic types
* Makefile-test.am:
* test/js/testEverythingBasic.js: Test basic types as in args
and return values. Test values at range limits are properly
handled. Test there's no implicit signed to unsigned conversion.
Added:
trunk/test/js/testEverythingBasic.js
Modified:
trunk/Makefile-test.am
Modified: trunk/Makefile-test.am
==============================================================================
--- trunk/Makefile-test.am (original)
+++ trunk/Makefile-test.am Wed Oct 29 11:34:05 2008
@@ -102,6 +102,7 @@
test/js/modules/jsUnit.js \
test/js/modules/testUtil.js \
test/js/testself.js \
+ test/js/testEverythingBasic.js \
test/js/testImporter.js \
test/js/testLang.js \
test/js/testMainloop.js \
Added: trunk/test/js/testEverythingBasic.js
==============================================================================
--- (empty file)
+++ trunk/test/js/testEverythingBasic.js Wed Oct 29 11:34:05 2008
@@ -0,0 +1,72 @@
+const Everything = imports.gi.Everything;
+
+const INT8_MIN = (-128);
+const INT16_MIN = (-32767-1);
+const INT32_MIN = (-2147483647-1);
+const INT64_MIN = (-9223372036854775807-1);
+
+const INT8_MAX = (127);
+const INT16_MAX = (32767);
+const INT32_MAX = (2147483647);
+const INT64_MAX = (9223372036854775807);
+
+const UINT8_MAX = (255);
+const UINT16_MAX = (65535);
+const UINT32_MAX = (4294967295);
+const UINT64_MAX = (18446744073709551615);
+
+function testLifeUniverseAndEverything() {
+ assertEquals(false, Everything.test_boolean(false));
+ assertEquals(true, Everything.test_boolean(true));
+
+ assertEquals(42, Everything.test_int8(42));
+ assertEquals(42, Everything.test_uint8(42));
+ assertEquals(42, Everything.test_int16(42));
+ assertEquals(42, Everything.test_uint16(42));
+ assertEquals(42, Everything.test_int32(42));
+ assertEquals(42, Everything.test_uint32(42));
+ assertEquals(42, Everything.test_int64(42));
+ assertEquals(42, Everything.test_uint64(42));
+ assertEquals(42, Everything.test_int(42));
+ assertEquals(42, Everything.test_uint(42));
+ assertEquals(42, Everything.test_long(42));
+ assertEquals(42, Everything.test_ulong(42));
+ assertEquals(42, Everything.test_ssize(42));
+ assertEquals(42, Everything.test_size(42));
+ assertEquals(42, Everything.test_float(42));
+ assertEquals(42, Everything.test_double(42));
+}
+
+function testLimits() {
+ assertEquals(UINT8_MAX, Everything.test_uint8(UINT8_MAX));
+ assertEquals(UINT16_MAX, Everything.test_uint16(UINT16_MAX));
+ assertEquals(UINT32_MAX, Everything.test_uint32(UINT32_MAX));
+
+ // FAIL: expected 18446744073709552000, got 0
+ //assertEquals(UINT64_MAX, Everything.test_uint64(UINT64_MAX));
+
+ assertEquals(INT8_MIN, Everything.test_int8(INT8_MIN));
+ assertEquals(INT8_MAX, Everything.test_int8(INT8_MAX));
+ assertEquals(INT16_MIN, Everything.test_int16(INT16_MIN));
+ assertEquals(INT16_MAX, Everything.test_int16(INT16_MAX));
+ assertEquals(INT32_MIN, Everything.test_int32(INT32_MIN));
+ assertEquals(INT32_MAX, Everything.test_int32(INT32_MAX));
+ assertEquals(INT64_MIN, Everything.test_int64(INT64_MIN));
+
+ // FAIL: expected 9223372036854776000, got -9223372036854776000
+ //assertEquals(INT64_MAX, Everything.test_int64(INT64_MAX));
+}
+
+function testNoImplicitConversionToUnsigned() {
+ assertRaises(function() { return Everything.test_uint8(-42); });
+ assertRaises(function() { return Everything.test_uint16(-42); });
+ assertRaises(function() { return Everything.test_uint32(-42); });
+
+ // FAIL: returns 18446744073709552000 instead of raising exception
+ //assertRaises(function() { return Everything.test_uint64(-42); });
+
+ assertRaises(function() { return Everything.test_uint(-42); });
+ assertRaises(function() { return Everything.test_size(-42); });
+}
+
+gjstestRun();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]