Index: trunk/ooRexx/base/directives/CONSTANT.testGroup
===================================================================
--- trunk/ooRexx/base/directives/CONSTANT.testGroup	(revision 11626)
+++ trunk/ooRexx/base/directives/CONSTANT.testGroup	(working copy)
@@ -227,16 +227,6 @@
  *  raised during the instantiation of the Package object, when the code is
  *  parsed.
  */
-::method test_bad_syntax_object
-  src = .array~new
-
-  src[1] = "return 0"
-  src[2] = "::class 'TestClass'"
-  src[3] = "::constant MESSAGE_PRODUCER (.Message~class)"
-
-  self~expectSyntax(19.916)
-  p = .Package~new("constant_TestGroup", src)
-
 ::method  test_duplicate_name
   src = .array~new
 
@@ -372,6 +362,82 @@
   self~expectSyntax(93.902)
   value = .test~s1(123)
 
+-- constant expression tests
+
+::method test_expression_empty
+  -- Missing expression on ::CONSTANT directive
+  self~assertSyntaxError(35.936, ("::class c", "::constant d ()"))
+
+::method test_expression_body
+  -- Constant methods cannot have a method body
+  self~assertSyntaxError(99.938, ("::class c", "::constant d", "(2 * 2)"))
+
+::method test_expression_floating
+  -- A ::CONSTANT directive with an expression requires a matching ::CLASS directive
+  self~assertSyntaxError(99.906, "::constant d (2 * 2)")
+
+::method test_expression_parens_required
+  -- Data must not follow the ::CONSTANT value
+  self~assertSyntaxError(21.913, ("::class c", "::constant d .RexxInfo~platform"))
+
+::method test_expression_reference_forward
+  -- Constant "PI" of object "The C class" has not been initialized
+  self~assertSyntaxError(97.4, ("::class c", "::constant d (2 * self~pi)", "::constant pi (355 / 113)"))
+
+::method test_expression_self
+  -- expression constants are evaluated at class creation time
+  -- self must always return class, not instance
+  self~assertSame("The C class", self~runDynamicSource(("return .c~d~string", "::class c", "::constant d (self)")))
+  self~assertSame("The C class", self~runDynamicSource(("return .c~new~d~string", "::class c", "::constant d (self)")))
+
+::method test_expression_activate
+  -- expression constants are evaluated at class creation time
+  -- they should already be availabe to the class activate() method
+  self~assertSame(4, self~runDynamicSource(.resources~activate))
+
+::resource activate
+return .c~return
+::class c
+  ::method activate class
+    expose return
+    return = self~d
+  ::attribute return class
+  ::constant d (2 * 2)
+::END
+
+::method test_expression_directives
+  self~assertIsA(.ExpressionDirective~primes, .Array)
+  self~assertSame("2, 3, 5, 7, 11, 13", .ExpressionDirective~primes~toString(, ", "))
+
+  if .RexxInfo~platform~caselessStartsWith("Windows") then
+    self~assertSame("type", .ExpressionDirective~command)
+  else
+    self~assertSame("cat", .ExpressionDirective~command)
+
+  self~assertSame("0." || 3~copies(20), .ExpressionDirective~multiClause)
+
+  -- constant expressions must have been evaluated before
+  self~assertSame(.ExpressionDirective~random, .ExpressionDirective~random)
+
+  -- real constants are initialized before expression constants
+  -- a forward reference from an expression constant to a real constant should work
+  self~assertSame(.ExpressionDirective~constant, .ExpressionDirective~constantRef)
+
+  self~assertSame(6.28318584, .ExpressionDirective~d)
+
+::class ExpressionDirective
+  ::constant primes (2, 3, 5, 7, 11, 13)
+  ::constant command (.RexxInfo~platform~caselessStartsWith("Windows")~?("type", "cat"))
+  ::constant multiClause (.Routine~new("r", ("numeric digits 20", "return 1 / 3"))~call)
+  ::constant random (random(0, 1e6))
+  -- forward reference to real constant
+  ::constant constantRef (self~constant)
+  ::constant constant 123
+  -- constant expressions can reference backwards
+  ::constant pi (355 / 113)
+  ::constant d (2 * self~pi)
+
+
 ::class test mixinclass object
 ::CONSTANT s1 'Fred'
 ::constant S2 "Rick"
