diff options
author | Mark Spruiell <mes@zeroc.com> | 2010-02-05 13:34:06 -0800 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2010-02-05 13:34:06 -0800 |
commit | 2ae657758b62ca65a05a12a291097d8fe98dd2b5 (patch) | |
tree | 88eb13c400efe34ede7282c157907bc7812fe497 /php/test | |
parent | updating CHANGES for bug 4653 (diff) | |
download | ice-2ae657758b62ca65a05a12a291097d8fe98dd2b5.tar.bz2 ice-2ae657758b62ca65a05a12a291097d8fe98dd2b5.tar.xz ice-2ae657758b62ca65a05a12a291097d8fe98dd2b5.zip |
bug 4650 - Slice default values
Diffstat (limited to 'php/test')
-rw-r--r-- | php/test/Ice/Makefile | 2 | ||||
-rw-r--r-- | php/test/Ice/Makefile.mak | 2 | ||||
-rw-r--r-- | php/test/Ice/defaultValue/.depend | 1 | ||||
-rw-r--r-- | php/test/Ice/defaultValue/.depend.mak | 1 | ||||
-rw-r--r-- | php/test/Ice/defaultValue/.gitignore | 1 | ||||
-rw-r--r-- | php/test/Ice/defaultValue/Client.php | 121 | ||||
-rw-r--r-- | php/test/Ice/defaultValue/Makefile | 26 | ||||
-rw-r--r-- | php/test/Ice/defaultValue/Makefile.mak | 24 | ||||
-rw-r--r-- | php/test/Ice/defaultValue/Test.ice | 73 | ||||
-rwxr-xr-x | php/test/Ice/defaultValue/run.py | 31 |
10 files changed, 280 insertions, 2 deletions
diff --git a/php/test/Ice/Makefile b/php/test/Ice/Makefile index ef764b9ba6f..fc5b2e13a86 100644 --- a/php/test/Ice/Makefile +++ b/php/test/Ice/Makefile @@ -11,7 +11,7 @@ top_srcdir = ../.. include $(top_srcdir)/config/Make.rules.php -SUBDIRS = binding checksum exceptions facets info inheritance objects operations proxy slicing +SUBDIRS = binding checksum exceptions facets info inheritance objects operations proxy slicing defaultValue $(EVERYTHING):: @for subdir in $(SUBDIRS); \ diff --git a/php/test/Ice/Makefile.mak b/php/test/Ice/Makefile.mak index 90a045c46c8..2bf6c558b9a 100644 --- a/php/test/Ice/Makefile.mak +++ b/php/test/Ice/Makefile.mak @@ -11,7 +11,7 @@ top_srcdir = ..\.. !include $(top_srcdir)\config\Make.rules.mak.php
-SUBDIRS = binding checksum exceptions facets info inheritance objects operations proxy slicing
+SUBDIRS = binding checksum exceptions facets info inheritance objects operations proxy slicing defaultValue
$(EVERYTHING)::
@for %i in ( $(SUBDIRS) ) do \
diff --git a/php/test/Ice/defaultValue/.depend b/php/test/Ice/defaultValue/.depend new file mode 100644 index 00000000000..f6d6205e60d --- /dev/null +++ b/php/test/Ice/defaultValue/.depend @@ -0,0 +1 @@ +Test.php: Test.ice $(SLICE2PHP) $(SLICEPARSERLIB) diff --git a/php/test/Ice/defaultValue/.depend.mak b/php/test/Ice/defaultValue/.depend.mak new file mode 100644 index 00000000000..8751ce66bf8 --- /dev/null +++ b/php/test/Ice/defaultValue/.depend.mak @@ -0,0 +1 @@ +Test.php: Test.ice "$(SLICE2PHP)" "$(SLICEPARSERLIB)" diff --git a/php/test/Ice/defaultValue/.gitignore b/php/test/Ice/defaultValue/.gitignore new file mode 100644 index 00000000000..bed01730acc --- /dev/null +++ b/php/test/Ice/defaultValue/.gitignore @@ -0,0 +1 @@ +Test.php diff --git a/php/test/Ice/defaultValue/Client.php b/php/test/Ice/defaultValue/Client.php new file mode 100644 index 00000000000..d19b531aa75 --- /dev/null +++ b/php/test/Ice/defaultValue/Client.php @@ -0,0 +1,121 @@ +<? +// ********************************************************************** +// +// Copyright (c) 2003-2010 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +error_reporting(E_ALL | E_STRICT); + +if(!extension_loaded("ice")) +{ + echo "\nerror: Ice extension is not loaded.\n\n"; + exit(1); +} + +$NS = function_exists("Ice\\initialize"); +require ($NS ? 'Ice_ns.php' : 'Ice.php'); +require 'Test.php'; + +function test($b) +{ + if(!$b) + { + $bt = debug_backtrace(); + die("\ntest failed in ".$bt[0]["file"]." line ".$bt[0]["line"]."\n"); + } +} + +function allTests() +{ + global $NS; + + $red = $NS ? constant("Test\\Color::red") : constant("Test_Color::red"); + $green = $NS ? constant("Test\\Color::green") : constant("Test_Color::green"); + $blue = $NS ? constant("Test\\Color::blue") : constant("Test_Color::blue"); + + echo "testing default values... "; + flush(); + + { + $v = $NS ? eval("return new Test\\Struct1;") : eval("return new Test_Struct1;"); + test(!$v->boolFalse); + test($v->boolTrue); + test($v->b == 254); + test($v->s == 16000); + test($v->i == 3); + test($v->l == 4); + test($v->f == 5.0); + test($v->d == 6.0); + test($v->str == "foo bar"); + test($v->c == $red); + test(strlen($v->noDefault) == 0); + } + + { + $v = $NS ? eval("return new Test\\Base;") : eval("return new Test_Base;"); + test(!$v->boolFalse); + test($v->boolTrue); + test($v->b == 1); + test($v->s == 2); + test($v->i == 3); + test($v->l == 4); + test($v->f == 5.0); + test($v->d == 6.0); + test($v->str == "foo bar"); + test(strlen($v->noDefault) == 0); + } + + { + $v = $NS ? eval("return new Test\\Derived;") : eval("return new Test_Derived;"); + test(!$v->boolFalse); + test($v->boolTrue); + test($v->b == 1); + test($v->s == 2); + test($v->i == 3); + test($v->l == 4); + test($v->f == 5.0); + test($v->d == 6.0); + test($v->str == "foo bar"); + test(strlen($v->noDefault) == 0); + test($v->c == $green); + } + + { + $v = $NS ? eval("return new Test\\BaseEx;") : eval("return new Test_BaseEx;"); + test(!$v->boolFalse); + test($v->boolTrue); + test($v->b == 1); + test($v->s == 2); + test($v->i == 3); + test($v->l == 4); + test($v->f == 5.0); + test($v->d == 6.0); + test($v->str == "foo bar"); + test(strlen($v->noDefault) == 0); + } + + { + $v = $NS ? eval("return new Test\\DerivedEx;") : eval("return new Test_DerivedEx;"); + test(!$v->boolFalse); + test($v->boolTrue); + test($v->b == 1); + test($v->s == 2); + test($v->i == 3); + test($v->l == 4); + test($v->f == 5.0); + test($v->d == 6.0); + test($v->str == "foo bar"); + test(strlen($v->noDefault) == 0); + test($v->c == $green); + } + echo "ok\n"; +} + +allTests(); + +exit(); +?> diff --git a/php/test/Ice/defaultValue/Makefile b/php/test/Ice/defaultValue/Makefile new file mode 100644 index 00000000000..78320613de4 --- /dev/null +++ b/php/test/Ice/defaultValue/Makefile @@ -0,0 +1,26 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2010 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +top_srcdir = ../../.. + +SLICE_SRCS = Test.ice + +include $(top_srcdir)/config/Make.rules.php + +SRCS = Test.php + +all:: $(SRCS) + +%.php: %.ice + $(SLICE2PHP) $(SLICE2PHPFLAGS) $< + +clean:: + rm -f $(SRCS) + +include .depend diff --git a/php/test/Ice/defaultValue/Makefile.mak b/php/test/Ice/defaultValue/Makefile.mak new file mode 100644 index 00000000000..ee6030d6d3b --- /dev/null +++ b/php/test/Ice/defaultValue/Makefile.mak @@ -0,0 +1,24 @@ +# **********************************************************************
+#
+# Copyright (c) 2003-2010 ZeroC, Inc. All rights reserved.
+#
+# This copy of Ice is licensed to you under the terms described in the
+# ICE_LICENSE file included in this distribution.
+#
+# **********************************************************************
+
+top_srcdir = ..\..\..
+
+!include $(top_srcdir)\config\Make.rules.mak.php
+
+SRCS = Test.php
+
+all:: $(SRCS)
+
+$(SRCS): $*.ice
+ -"$(SLICE2PHP)" $(SLICE2PHPFLAGS) $*.ice
+
+clean::
+ del /q $(SRCS)
+
+include .depend.mak
diff --git a/php/test/Ice/defaultValue/Test.ice b/php/test/Ice/defaultValue/Test.ice new file mode 100644 index 00000000000..95725630fe7 --- /dev/null +++ b/php/test/Ice/defaultValue/Test.ice @@ -0,0 +1,73 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2010 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#ifndef TEST_ICE +#define TEST_ICE + +module Test +{ + +enum Color { red, green, blue }; + +struct Struct1 +{ + bool boolFalse = false; + bool boolTrue = true; + byte b = 254; + short s = 16000; + int i = 3; + long l = 4; + float f = 5.0; + double d = 6.0; + string str = "foo bar"; + Color c = red; + string noDefault; +}; + +class Base +{ + bool boolFalse = false; + bool boolTrue = true; + byte b = 1; + short s = 2; + int i = 3; + long l = 4; + float f = 5.0; + double d = 6.0; + string str = "foo bar"; + string noDefault; +}; + +class Derived extends Base +{ + Color c = green; +}; + +exception BaseEx +{ + bool boolFalse = false; + bool boolTrue = true; + byte b = 1; + short s = 2; + int i = 3; + long l = 4; + float f = 5.0; + double d = 6.0; + string str = "foo bar"; + string noDefault; +}; + +exception DerivedEx extends BaseEx +{ + Color c = green; +}; + +}; + +#endif diff --git a/php/test/Ice/defaultValue/run.py b/php/test/Ice/defaultValue/run.py new file mode 100755 index 00000000000..98970d82c0d --- /dev/null +++ b/php/test/Ice/defaultValue/run.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2010 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +import os, sys + +path = [ ".", "..", "../..", "../../..", "../../../.." ] +head = os.path.dirname(sys.argv[0]) +if len(head) > 0: + path = [os.path.join(head, p) for p in path] +path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] +if len(path) == 0: + raise "can't find toplevel directory!" +sys.path.append(os.path.join(path[0])) +from scripts import * + +testdir = os.getcwd() + +client = os.path.join(testdir, "Client.php") + +print "starting client...", +clientProc = TestUtil.startClient(client, startReader = False) +print "ok" +clientProc.startReader() +clientProc.waitTestSuccess() |