cvs: smarty /libs Smarty_Compiler.class.php /unit_test test_cases.php

"Monte Ohrt" <[email protected]>
Newsgroups gmane.comp.php.cvs.smarty
Message-ID <cvsmohrt1094767293@cvsserver>
mohrt		Thu Sep  9 18:01:33 2004 EDT

  Modified files:              
    /smarty/libs	Smarty_Compiler.class.php 
    /smarty/unit_test	test_cases.php 
  Log:
  break down regex to digestable chunks, fix multiple param problem with method calls,
  add object method testing to unit_test cases
  
  
http://cvs.php.net/diff.php/smarty/libs/Smarty_Compiler.class.php?r1=1.340&r2=1.341&ty=u
Index: smarty/libs/Smarty_Compiler.class.php
diff -u smarty/libs/Smarty_Compiler.class.php:1.340 smarty/libs/Smarty_Compiler.class.php:1.341
--- smarty/libs/Smarty_Compiler.class.php:1.340	Thu Sep  9 14:25:55 2004
+++ smarty/libs/Smarty_Compiler.class.php	Thu Sep  9 18:01:33 2004
@@ -26,7 +26,7 @@
  * @package Smarty
  */
 
-/* $Id: Smarty_Compiler.class.php,v 1.340 2004/09/09 18:25:55 mohrt Exp $ */
+/* $Id: Smarty_Compiler.class.php,v 1.341 2004/09/09 22:01:33 mohrt Exp $ */
 
 /**
  * Template compiling class
@@ -151,14 +151,16 @@
         // $foo->bar($foo->bar())
         // $foo->bar($foo->bar($blah,$foo,44,"foo",$foo[0].bar))
         $this->_obj_ext_regexp = '\->(?:\$?' . $this->_dvar_guts_regexp . ')';
-        $this->_obj_params_regexp = '\((?:\w+|(?:'
+        $this->_obj_restricted_param_regexp = '(?:'
                 . $this->_var_regexp . '(?:' . $this->_obj_ext_regexp . '(?:\((?:' . $this->_var_regexp
-                . '(?:\s*,\s*' . $this->_var_regexp . ')*)?\))?)*)(?:\s*,\s*(?:(?:\w+|'
-                . $this->_var_regexp . '(?:' . $this->_obj_ext_regexp . '(?:\((?:' . $this->_var_regexp
-                . '(?:\s*,\s*' . $this->_var_regexp . ')*)?\))?))))*)?\)';
+                . '(?:\s*,\s*' . $this->_var_regexp . ')*)?\))?)*)';
+        $this->_obj_single_param_regexp = '(?:\w+|' . $this->_obj_restricted_param_regexp . '(?:\s*,\s*(?:(?:\w+|'
+                . $this->_var_regexp . $this->_obj_restricted_param_regexp . ')))*)';
+        $this->_obj_params_regexp = '\((?:' . $this->_obj_single_param_regexp
+                . '(?:\s*,\s*' . $this->_obj_single_param_regexp . ')*)?\)';
         $this->_obj_start_regexp = '(?:' . $this->_dvar_regexp . '(?:' . $this->_obj_ext_regexp . ')+)';
         $this->_obj_call_regexp = '(?:' . $this->_obj_start_regexp . '(?:' . $this->_obj_params_regexp . ')?)';
-
+        
         // matches valid modifier syntax:
         // |foo
         // |@foo
http://cvs.php.net/diff.php/smarty/unit_test/test_cases.php?r1=1.7&r2=1.8&ty=u
Index: smarty/unit_test/test_cases.php
diff -u smarty/unit_test/test_cases.php:1.7 smarty/unit_test/test_cases.php:1.8
--- smarty/unit_test/test_cases.php:1.7	Mon Apr 12 08:21:39 2004
+++ smarty/unit_test/test_cases.php	Thu Sep  9 18:01:33 2004
@@ -3,6 +3,16 @@
 require_once './config.php';
 require_once SMARTY_DIR . 'Smarty.class.php';
 require_once 'PHPUnit.php';
+
+class Obj {
+    var $val = 'val';
+    var $arr = array('one' => 'one');
+
+    function meth($a="a", $b="b") {
+        return "$a:$b";
+    }
+}
+
     
 class SmartyTest extends PHPUnit_TestCase {
     // contains the object handle of the string class
@@ -229,6 +239,22 @@
     function test_assign_var() {
         $this->smarty->assign('foo', 'bar');
         $this->assertEquals($this->smarty->fetch('assign_var.tpl'), 'bar');
+    }
+
+    // test assigning and calling an object
+    function test_obj_meth() {
+        $obj  = new Obj();
+        $this->smarty->assign('obj', $obj);
+        $this->smarty->assign('foo', 'foo');
+        $this->assertEquals(
+'foo:2.5
+2.5:foo
+2.5:b
+val:foo
+foo:val
+foo:foo
+one:2
+foo:foo:b',   $this->smarty->fetch('assign_obj.tpl'));
     }
     
     /* CONFIG FILE TESTS */

-- 
Smarty CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.