summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFred Hornsey <hornseyf@objectcomputing.com>2018-11-27 19:12:44 -0600
committerFred Hornsey <hornseyf@objectcomputing.com>2018-11-27 19:12:44 -0600
commit2ff6c3fd080f8c1bc31910b80bc80c49b6dc24c0 (patch)
tree8f415bb495a785523163572e49d4d814a71e5d77
parent80ac0c1e3cf3ea61c1853927c9c568704f21dab0 (diff)
downloadATCD-2ff6c3fd080f8c1bc31910b80bc80c49b6dc24c0.tar.gz
annotest_idl: Mostly Complete Test Cases
-rw-r--r--TAO/tests/IDLv4/annotations/be_init.cpp800
-rw-r--r--TAO/tests/IDLv4/annotations/be_util.cpp2
2 files changed, 767 insertions, 35 deletions
diff --git a/TAO/tests/IDLv4/annotations/be_init.cpp b/TAO/tests/IDLv4/annotations/be_init.cpp
index 55a3053ffb6..681676c9c62 100644
--- a/TAO/tests/IDLv4/annotations/be_init.cpp
+++ b/TAO/tests/IDLv4/annotations/be_init.cpp
@@ -5,6 +5,11 @@
#include "idl_version.h"
#include "ace/OS_NS_stdlib.h"
+#include "ace/OS_NS_string.h"
+
+#ifndef ACE_LACKS_IOSTREAM_TOTALLY
+# include "ace/streams.h"
+#endif
#include "utl_identifier.h"
#include "ast_generator.h"
@@ -12,6 +17,7 @@
#include "fe_declarator.h"
#include "ast_field.h"
#include "ast_annotation_decl.h"
+#include "ast_annotation_member.h"
void
BE_version ()
@@ -26,50 +32,776 @@ BE_init (int&, ACE_TCHAR*[])
{
ACE_NEW_RETURN (be_global, BE_GlobalData, -1);
+ // Enable Annotations
idl_global->idl_version_.version (IDL_VERSION_4);
+ // Disable Trying to Parse File Arguments and creating File Output
+ idl_global->ignore_files_ = true;
+
return 0;
}
+/// Test Statistics
+///{
+static unsigned failed_test_count = 0;
+static unsigned total_test_count = 0;
+///}
+
+struct Failed {};
+
+class Annotation_Test {
+public:
+ const char *name_;
+ const char *idl_;
+ bool failed_;
+ int error_count_;
+ UTL_Error::ErrorCode last_error_, last_warning_;
+
+ Annotation_Test (const char *name)
+ : name_ (name),
+ idl_ (0),
+ failed_ (false),
+ error_count_ (0),
+ last_error_ (UTL_Error::EIDL_OK),
+ last_warning_ (UTL_Error::EIDL_OK)
+ {
+ total_test_count++;
+ }
+
+ ~Annotation_Test ()
+ {
+ if (idl_global->err ()->last_error == UTL_Error::EIDL_SYNTAX_ERROR)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Annotation Test: %C: ")
+ ACE_TEXT ("FAILED because of syntax error in:\n%C\n")
+ ACE_TEXT ("Check Syntax Error Message Above For More Infomation\n"),
+ name_, idl_));
+ failed_test_count++;
+ }
+ else if (!failed_)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Annotation Test: %C: PASSED\n"), name_));
+ }
+ }
+
+ void failed (const char * message = 0)
+ {
+ if (message)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Annotation Test Error: %C: %C\n"),
+ name_, message));
+ }
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Annotation Test: %C: FAILED\nFailed IDL:\n%C\n"),
+ name_, idl_));
+ failed_test_count++;
+ failed_ = true;
+ throw Failed();
+ }
+
+ Annotation_Test &error_count (int error_count)
+ {
+ error_count_ = error_count;
+ return *this;
+ }
+
+ Annotation_Test &last_error (UTL_Error::ErrorCode last_error)
+ {
+ last_error_ = last_error;
+ return *this;
+ }
+
+ Annotation_Test &last_warning (UTL_Error::ErrorCode last_warning)
+ {
+ last_warning_ = last_warning;
+ return *this;
+ }
+
+ Annotation_Test &run (const char *idl)
+ {
+ // Reset Error State
+ idl_global->set_err_count (0);
+ idl_global->err ()->last_error = UTL_Error::EIDL_OK;
+ idl_global->err ()->last_warning = UTL_Error::EIDL_OK;
+
+ // Eval IDL
+ idl_ = idl;
+ idl_global->eval (idl);
+
+ // Look at Results
+ if (idl_global->err_count () != error_count_)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Annotation Test Error: %C:\nError Count: expecting %d, got %d!\n"),
+ name_, error_count_, idl_global->err_count ()));
+ failed ();
+ }
+ if (idl_global->err ()->last_error != last_error_)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Annotation Test Error: %C:\nLast Error Code (UTL_Error::ErrorCode): ")
+ ACE_TEXT ("expecting %d, got %d!\n"),
+ name_, last_error_, idl_global->err ()->last_error));
+ failed ();
+ }
+ if (idl_global->err ()->last_warning != last_warning_)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Annotation Test Error: %C:\nLast Warning Code (UTL_Error::ErrorCode): ")
+ ACE_TEXT ("expecting %d, got %d!\n"),
+ name_, last_warning_, idl_global->err ()->last_warning));
+ failed ();
+ }
+
+ return *this;
+ }
+
+ AST_Decl *assert_node (const char *name)
+ {
+ AST_Decl *node = 0;
+ UTL_ScopedName *scoped_name = FE_Utils::string_to_scoped_name (name);
+
+ if (scoped_name)
+ {
+ node = idl_global->scopes ().top_non_null ()->
+ lookup_by_name (scoped_name);
+ }
+
+ if (!node)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Annotation Test Error: %C:\n")
+ ACE_TEXT ("Failed to Find AST Node named %C!\n"),
+ name_, name));
+ failed ();
+ }
+
+ delete scoped_name;
+ return node;
+ }
+
+ AST_Annotation_Decl *assert_annotation_decl (const char *name)
+ {
+ AST_Annotation_Decl *node = dynamic_cast<AST_Annotation_Decl*>(
+ assert_node (name));
+
+ if (node->node_type () != AST_Decl::NT_annotation_decl)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Annotation Test Error: %C:\n")
+ ACE_TEXT ("AST Node named %C is not an AST_Annotation_Decl!\n"),
+ name_, name));
+ failed ();
+ }
+
+ return node;
+ }
+
+ void assert_annotation_appl_count (
+ AST_Decl *node, size_t count)
+ {
+ AST_Annotation_Appls *annotations = node->annotation_appls ();
+ if (!annotations && count)
+ {
+ char *node_name = node->name ()->get_string_copy ();
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Annotation Test Error: %C:\n")
+ ACE_TEXT ("asserting that %C has %d annotations failed, ")
+ ACE_TEXT ("annotations are null!\n"),
+ name_, node_name, count));
+ delete [] node_name;
+ failed ();
+ }
+ if (annotations->size () != count)
+ {
+ char *node_name = node->name ()->get_string_copy ();
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Annotation Test Error: %C:\n")
+ ACE_TEXT ("asserting %C has %d annotations, but there are %d!\n"),
+ name_, node_name, count, annotations->size ()));
+ delete [] node_name;
+ failed ();
+ }
+ }
+
+ AST_Annotation_Appl *assert_annotation_appl (
+ AST_Decl *node, size_t index, AST_Annotation_Decl *anno_decl)
+ {
+ if (!anno_decl)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Annotation Test Error: %C:\n")
+ ACE_TEXT ("assert_annotation_appl: annotation decl is null!\n"),
+ name_));
+ failed ();
+ }
+
+ AST_Annotation_Appls *annotations = node->annotation_appls ();
+ if (!annotations || !annotations->size ())
+ {
+ char *node_name = node->name ()->get_string_copy ();
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Annotation Test Error: %C:\n")
+ ACE_TEXT ("can not access %C annotation %d, ")
+ ACE_TEXT ("it has no annotations!\n"),
+ name_, node_name, index));
+ delete [] node_name;
+ failed ();
+ }
+
+ if (index >= annotations->size ())
+ {
+ char *node_name = node->name ()->get_string_copy ();
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Annotation Test Error: %C:\n")
+ ACE_TEXT ("can not access %C annotation %d, ")
+ ACE_TEXT ("it only has %d annotation(s)!\n"),
+ name_, node_name, index, annotations->size ()));
+ delete [] node_name;
+ failed ();
+ }
+
+ AST_Annotation_Appl *anno_appl = (*annotations)[index];
+ if (!anno_appl)
+ {
+ char *node_name = node->name ()->get_string_copy ();
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Annotation Test Error: %C:\n")
+ ACE_TEXT ("%C annotation %d is NULL!\n"),
+ name_, node_name, index));
+ delete [] node_name;
+ failed ();
+ }
+ if (anno_appl->annotation_decl () != anno_decl)
+ {
+ char *anno_appl_name = anno_appl->name ()->get_string_copy ();
+ char *anno_decl_name = anno_decl->name ()->get_string_copy ();
+ char *node_name = node->name ()->get_string_copy ();
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Annotation Test Error: %C:\n")
+ ACE_TEXT ("%C annotation %d is a %C, looking for a %C!\n"),
+ name_, node_name, index, anno_appl_name, anno_decl_name));
+ delete [] anno_appl_name;
+ delete [] anno_decl_name;
+ delete [] node_name;
+ failed ();
+ }
+
+ return anno_appl;
+ }
+
+ void assert_annotation_member_count (
+ AST_Annotation_Decl *anno_decl, size_t count)
+ {
+ if (!anno_decl)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Annotation Test Error: %C:\n")
+ ACE_TEXT ("assert_annotation_member_count: annotation decl is null!\n"),
+ name_));
+ failed ();
+ }
+
+ size_t actual_count = anno_decl->member_count ();
+ if (actual_count != count)
+ {
+ char *anno_decl_name = anno_decl->name ()->get_string_copy ();
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Annotation Test Error: %C:\n")
+ ACE_TEXT ("%C should have %d members, but it actually has %d!\n"),
+ name_, anno_decl_name, count, actual_count));
+ delete [] anno_decl_name;
+ failed ();
+ }
+ }
+
+ void assert_annotation_member_count (
+ AST_Annotation_Appl *anno_appl, size_t count)
+ {
+ assert_annotation_member_count (
+ dynamic_cast<AST_Annotation_Decl*>(anno_appl), count);
+ }
+
+ AST_Annotation_Member *get_annotation_member (
+ AST_Annotation_Decl *anno_decl, const char *name)
+ {
+ AST_Decl *decl = (*anno_decl)[name];
+ AST_Annotation_Member *member = decl ?
+ AST_Annotation_Member::narrow_from_decl(decl) : 0;
+ if (!member)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Annotation Test Error: %C:\n")
+ ACE_TEXT ("Could not get annotation member %C!\n"),
+ name_, name));
+ failed ();
+ }
+ return member;
+ }
+
+ AST_Annotation_Member *get_annotation_member (
+ AST_Annotation_Appl *anno_appl, const char *name)
+ {
+ return get_annotation_member(
+ dynamic_cast<AST_Annotation_Decl*>(anno_appl), name);
+ }
+
+ void assert_annotation_member_type (
+ AST_Annotation_Member *member, AST_Expression::ExprType type)
+ {
+ if (member->expr_type () != type)
+ {
+ char *member_name = member->name ()->get_string_copy ();
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Annotation Test Error: %C:\n")
+ ACE_TEXT ("For Annotation Member %C, ")
+ ACE_TEXT ("expecting it to be a %C, but it is a %C!\n"),
+ name_, member_name,
+ AST_Expression::exprtype_to_string (type),
+ AST_Expression::exprtype_to_string (member->expr_type ())));
+ delete [] member_name;
+ failed ();
+ }
+ }
+
+ template <typename T1, typename T2>
+ void assert_annotation_member_value (
+ AST_Annotation_Member *member, T1 expected_value)
+ {
+ AST_Expression *member_value = member->value ();
+ if (!member_value)
+ {
+ char *member_name = member->name ()->get_string_copy ();
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Annotation Test Error: %C:\n")
+ ACE_TEXT ("For Annotation Member %C, ")
+ ACE_TEXT ("expecting it to have a value, but it doesn't!\n"),
+ name_, member_name));
+ delete [] member_name;
+ failed ();
+ }
+
+ AST_Expression expected(static_cast<T2>(expected_value));
+ if (!(expected == member_value))
+ {
+ char *member_name = member->name ()->get_string_copy ();
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Annotation Test Error: %C:\n")
+ ACE_TEXT ("For Annotation Member %C, ")
+ ACE_TEXT ("expecting "),
+ name_, member_name));
+ delete [] member_name;
+ expected.dump (*ACE_DEFAULT_LOG_STREAM);
+ ACE_ERROR ((LM_ERROR, ACE_TEXT (", got ")));
+ member_value->dump (*ACE_DEFAULT_LOG_STREAM);
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("!\n")));
+ failed ();
+ }
+ }
+
+ void assert_annotation_member_no_value (AST_Annotation_Member *member)
+ {
+ AST_Expression *member_value = member->value ();
+ if (member_value)
+ {
+ char *member_name = member->name ()->get_string_copy ();
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Annotation Test Error: %C:\n")
+ ACE_TEXT ("For Annotation Member %C, ")
+ ACE_TEXT ("expecting it to not have a value, but it does!\n"),
+ name_, member_name));
+ delete [] member_name;
+ failed ();
+ }
+ }
+};
+
void
BE_post_init (char *[], long)
{
- // Get Root Scope
- UTL_Scope *root_scope = idl_global->scopes ().bottom ();
-
/*
- * @annotation id {
- * unsigned long value;
- * };
+ * Notes About These Tests
+ * =========================================================================
+ *
+ * - They are in the same IDL namespace, so they can conflict with each
+ * other.
+ *
+ * - You can't test for a syntax error really because tao_idl throws an
+ * exception for them. Even if the exception was caught, the AST might be
+ * in an invalid state afterwards.
+ *
+ * - Annotations local names internally start with @ so that they don't
+ * conflict with other non-annotation names. See below for examples.
+ *
+ * - Some of these tests intentionally cause errors.
*/
- /*
- // Create Annoation
- Identifier *name = new Identifier("id");
- UTL_ScopedName *scoped_name = new UTL_ScopedName(name, 0);
- AST_Annotation_Decl *id_annotation = idl_global->gen ()->create_annotation_decl (scoped_name);
- root_scope->fe_add_structure (id_annotation);
-
- // Enter id scope
- idl_global->scopes ().push (id_annotation);
-
- // Set value member
- AST_Decl* type = root_scope->lookup_primitive_type (AST_Expression::EV_ulong); // unsigned long
- FE_Declarator *declarator = new FE_Declarator (
- new UTL_ScopedName(new Identifier("value"), 0), FE_Declarator::FD_simple, 0);
- AST_Field *field = idl_global->gen ()->create_field (
- declarator->compose (type), declarator->name (), AST_Field::vis_PRIVATE);
- id_annotation->fe_add_field (field);
-
- // Exit id scope
- idl_global->scopes ().pop ();
- */
+ /* -------------------------------------------------------------------------
+ * Annotations Declarations
+ * -------------------------------------------------------------------------
+ * These tests assert that annotations can be declared.
+ */
- /*
- idl_global->eval (
- "struct MyStruct {"
- " short value;"
- "};"
- );
- */
+ AST_Annotation_Decl *test_annotation_1 = 0;
+ try {
+ Annotation_Test t("Annotation Declaration with No Members");
+ test_annotation_1 = t.run (
+ "@annotation test_annotation_1 {\n"
+ "};\n"
+ ).assert_annotation_decl ("::@test_annotation_1");
+ t.assert_annotation_member_count (test_annotation_1, 0);
+ } catch (Failed &f) {}
+
+ AST_Annotation_Decl *test_annotation_2 = 0;
+ try {
+ Annotation_Test t("Annotation Declaration with Members");
+ test_annotation_2 = t.run (
+ "@annotation test_annotation_2 {\n"
+ " short short_value;\n"
+ " char char_value;\n"
+ " long long_value;\n"
+ " boolean boolean_value;\n"
+ "};\n"
+ ).assert_annotation_decl ("::@test_annotation_2");
+ t.assert_annotation_member_count (test_annotation_2, 4);
+
+ AST_Annotation_Member *short_value =
+ t.get_annotation_member (test_annotation_2, "short_value");
+ t.assert_annotation_member_type (short_value, AST_Expression::EV_short);
+ t.assert_annotation_member_no_value (short_value);
+
+ AST_Annotation_Member *char_value =
+ t.get_annotation_member (test_annotation_2, "char_value");
+ t.assert_annotation_member_type (char_value, AST_Expression::EV_char);
+ t.assert_annotation_member_no_value (char_value);
+
+ AST_Annotation_Member *long_value =
+ t.get_annotation_member (test_annotation_2, "long_value");
+ t.assert_annotation_member_type (long_value, AST_Expression::EV_long);
+ t.assert_annotation_member_no_value (long_value);
+
+ AST_Annotation_Member *boolean_value =
+ t.get_annotation_member (test_annotation_2, "boolean_value");
+ t.assert_annotation_member_type (boolean_value, AST_Expression::EV_bool);
+ t.assert_annotation_member_no_value (boolean_value);
+ } catch (Failed &f) {}
+
+ AST_Annotation_Decl *test_annotation_3 = 0;
+ try {
+ Annotation_Test t("Annotation Declaration with Defaulted Members");
+ test_annotation_3 = t.run (
+ "@annotation test_annotation_3 {\n"
+ " short short_value default 1;\n"
+ " char char_value default '&';\n"
+ " long long_value default -1;\n"
+ " boolean boolean_value default FALSE;\n"
+ "};\n"
+ ).assert_annotation_decl ("::@test_annotation_3");
+ t.assert_annotation_member_count (test_annotation_3, 4);
+
+ AST_Annotation_Member *short_value =
+ t.get_annotation_member (test_annotation_3, "short_value");
+ t.assert_annotation_member_type (short_value, AST_Expression::EV_short);
+ t.assert_annotation_member_value<short, ACE_CDR::Short> (short_value, 1);
+
+ AST_Annotation_Member *char_value =
+ t.get_annotation_member (test_annotation_3, "char_value");
+ t.assert_annotation_member_type (char_value, AST_Expression::EV_char);
+ t.assert_annotation_member_value<char, ACE_CDR::Char> (char_value, '&');
+
+ AST_Annotation_Member *long_value =
+ t.get_annotation_member (test_annotation_3, "long_value");
+ t.assert_annotation_member_type (long_value, AST_Expression::EV_long);
+ t.assert_annotation_member_value<int, ACE_CDR::Long> (long_value, -1);
+
+ AST_Annotation_Member *boolean_value =
+ t.get_annotation_member (test_annotation_3, "boolean_value");
+ t.assert_annotation_member_type (boolean_value, AST_Expression::EV_bool);
+ t.assert_annotation_member_value<bool, ACE_CDR::Boolean> (boolean_value, false);
+ } catch (Failed &f) {}
+
+ AST_Annotation_Decl *test_annotation_4 = 0;
+ try {
+ Annotation_Test t("Annotation Declaration with Mixed Members");
+ test_annotation_4 = t.run (
+ "@annotation test_annotation_4 {\n"
+ " short x;\n"
+ " short y default 0;\n"
+ "};\n"
+ ).assert_annotation_decl ("::@test_annotation_4");
+ t.assert_annotation_member_count (test_annotation_4, 2);
+
+ AST_Annotation_Member *x =
+ t.get_annotation_member (test_annotation_4, "x");
+ t.assert_annotation_member_type (x, AST_Expression::EV_short);
+ t.assert_annotation_member_no_value (x);
+
+ AST_Annotation_Member *y =
+ t.get_annotation_member (test_annotation_4, "y");
+ t.assert_annotation_member_type (y, AST_Expression::EV_short);
+ t.assert_annotation_member_value<short, ACE_CDR::Short> (y, 0);
+ } catch (Failed &f) {}
+
+ AST_Annotation_Decl *test_annotation_in_module = 0;
+ try {
+ Annotation_Test t("Annotation Declaration In Module");
+ test_annotation_in_module = t.run (
+ "module module_with_annotation_decl {\n"
+ " @annotation test_annotation {\n"
+ " };\n"
+ "};\n"
+ ).assert_annotation_decl (
+ "::module_with_annotation_decl::@test_annotation");
+ t.assert_annotation_member_count (test_annotation_in_module, 0);
+ } catch (Failed &f) {}
+
+ try {
+ Annotation_Test t("Annotation Declaration with Enum");
+ t.run (
+ "@annotation enum_annotation {\n"
+ " enum Enum_t {\n"
+ " A,\n"
+ " B,\n"
+ " C\n"
+ " };\n"
+ " Enum_t value default C;\n"
+ "};\n"
+ );
+ // TODO
+ } catch (Failed &f) {}
+
+ try {
+ Annotation_Test t("Annotation Declaration with String");
+ t.run (
+ "@annotation string_annotation {\n"
+ " string value default \"This is some text\";\n"
+ "};\n"
+ );
+ // TODO
+ } catch (Failed &f) {}
+
+ /* -------------------------------------------------------------------------
+ * Annotations Applications
+ * -------------------------------------------------------------------------
+ * These tests assert that annotations can be applied to various IDL
+ * constructs.
+ */
+
+ try {
+ Annotation_Test t("Module Annotation Application");
+ AST_Decl *module1 = t.run (
+ "@test_annotation_1\n"
+ "module module1 {\n"
+ " struct struct_in_module1 {\n"
+ " short member;\n"
+ " };\n"
+ "};\n"
+ ).assert_node ("::module1");
+ t.assert_annotation_appl_count (module1, 1);
+ t.assert_annotation_appl (module1, 0, test_annotation_1);
+ } catch (Failed &f) {}
+
+ try {
+ Annotation_Test t("Struct Annotation Application");
+ AST_Decl *struct1 = t.run (
+ "@test_annotation_1\n"
+ "struct struct1 {\n"
+ " short member;\n"
+ "};\n"
+ ).assert_node ("::struct1");
+ t.assert_annotation_appl_count (struct1, 1);
+ t.assert_annotation_appl (struct1, 0, test_annotation_1);
+ } catch (Failed &f) {}
+
+ try {
+ Annotation_Test t("Typedef Annotation Application");
+ AST_Decl *small_positive = t.run (
+ "@test_annotation_1\n"
+ "typedef short small_positive;\n"
+ "struct struct6 {\n"
+ " small_positive member;\n"
+ "};\n"
+ ).assert_node ("small_positive");
+ t.assert_annotation_appl_count (small_positive, 1);
+ t.assert_annotation_appl (small_positive, 0, test_annotation_1);
+
+ // TODO
+ // Assert We Can Access test_annotation_1 when we use "member"
+ AST_Decl *member = t.assert_node ("struct6::member");
+ } catch (Failed &f) {}
+
+ // TODO
+ try {
+ Annotation_Test t("Sequence Type Parameter Annotation Application");
+ t.run (
+ "typedef sequence<@test_annotation_1 short, 5> test_seq_t;\n"
+ );
+ } catch (Failed &f) {}
+
+ try {
+ Annotation_Test t("Constant Declarations Annotation Application");
+ AST_Decl *test_const = t.run (
+ "@test_annotation_1\n"
+ "const short test_const = 5;\n"
+ ).assert_node ("test_const");
+ t.assert_annotation_appl_count (test_const, 1);
+ t.assert_annotation_appl (test_const, 0, test_annotation_1);
+ } catch (Failed &f) {}
+
+ try {
+ Annotation_Test t("Multiple Annotation Applications");
+ AST_Decl *struct3 = t.run (
+ "@test_annotation_1\n"
+ "@test_annotation_1\n"
+ "struct struct3 {\n"
+ " short test_member_1;\n"
+ "};\n"
+ ).assert_node ("struct3");
+ t.assert_annotation_appl_count (struct3, 2);
+ t.assert_annotation_appl (struct3, 0, test_annotation_1);
+ t.assert_annotation_appl (struct3, 1, test_annotation_1);
+ } catch (Failed &f) {}
+
+ try {
+ Annotation_Test t("Annotation Application with a Single Parameter");
+ AST_Decl *struct4 = t.run (
+ "@test_annotation_4 (100)\n"
+ "struct struct4 {\n"
+ " short test_member_1;\n"
+ "};\n"
+ ).assert_node ("struct4");
+ t.assert_annotation_appl_count (struct4, 1);
+ AST_Annotation_Appl *appl =
+ t.assert_annotation_appl (struct4, 0, test_annotation_4);
+ t.assert_annotation_member_count (appl, 2);
+
+ AST_Annotation_Member *x = t.get_annotation_member (appl, "x");
+ t.assert_annotation_member_value<short, ACE_CDR::Short> (x, 100);
+
+ AST_Annotation_Member *y = t.get_annotation_member (appl, "y");
+ t.assert_annotation_member_value<short, ACE_CDR::Short> (y, 0);
+ } catch (Failed &f) {}
+
+ try {
+ Annotation_Test t("Annotation Application with Named Parameters");
+ AST_Decl *struct2 = t.run (
+ "@test_annotation_4 (x = 101, y = 102)\n"
+ "struct struct2 {\n"
+ " short test_member_1;\n"
+ "};\n"
+ ).assert_node ("struct2");
+ t.assert_annotation_appl_count (struct2, 1);
+ AST_Annotation_Appl *appl =
+ t.assert_annotation_appl (struct2, 0, test_annotation_4);
+ t.assert_annotation_member_count (appl, 2);
+
+ AST_Annotation_Member *x = t.get_annotation_member (appl, "x");
+ t.assert_annotation_member_value<short, ACE_CDR::Short> (x, 101);
+
+ AST_Annotation_Member *y = t.get_annotation_member (appl, "y");
+ t.assert_annotation_member_value<short, ACE_CDR::Short> (y, 102);
+ } catch (Failed &f) {}
+
+ try {
+ Annotation_Test t("Annotation Applications with Scoped Names");
+ AST_Decl *struct5 = t.run (
+ "@module_with_annotation_decl::test_annotation\n"
+ "@::module_with_annotation_decl::test_annotation\n"
+ "struct struct5 {\n"
+ " short test_member_1;\n"
+ "};\n"
+ ).assert_node ("struct5");
+ t.assert_annotation_appl_count (struct5, 2);
+ t.assert_annotation_appl (struct5, 0, test_annotation_in_module);
+ t.assert_annotation_appl (struct5, 1, test_annotation_in_module);
+ } catch (Failed &f) {}
+
+ try {
+ Annotation_Test t("Annotation Applications in Unions");
+ AST_Decl *Test_Union = t.run (
+ /* Annotations on the union and the discriminator */
+ "@test_annotation_1\n"
+ "union Test_Union switch (@test_annotation_1 short) {\n"
+ "case 0:\n"
+ "case 1:\n"
+ /* Annotation on a Union Member */
+ " @test_annotation_1 short union_member_1;\n"
+ "default:\n"
+ " short union_member_2;\n"
+ "};\n"
+ ).assert_node("Test_Union");
+ // TODO
+ } catch (Failed &f) {}
+
+ try {
+ Annotation_Test t("Annotation Applications in Enums");
+ AST_Decl *Test_Enum = t.run (
+ /* Annotation on the enum */
+ "@test_annotation_1\n"
+ "enum Test_Enum {\n"
+ " TEST_ENUM_MEMBER_1,\n"
+ /* Annotation on a enumerator */
+ " @test_annotation_1 TEST_ENUM_MEMBER_2,\n"
+ " TEST_ENUM_MEMBER_3\n"
+ "};\n"
+ ).assert_node ("Test_Enum");
+ // TODO
+ } catch (Failed &f) {}
+
+ /* -------------------------------------------------------------------------
+ * Annotation Names
+ * -------------------------------------------------------------------------
+ * These tests assert various aspects of how annotations work in regards to
+ * naming.
+ */
+
+ try {
+ Annotation_Test t("Annotation and Non-Annotation Names Can't Clash");
+ t.run (
+ "@annotation samename {\n"
+ "};\n"
+ "struct samename {\n"
+ " short member;\n"
+ "};"
+ );
+ } catch (Failed &f) {}
+
+ try {
+ Annotation_Test t("Annotation Names Can't Be \"annotation\"");
+ t.last_error (UTL_Error::EIDL_MISC).error_count (1);
+ t.run (
+ "@annotation annotation {\n"
+ "};\n"
+ );
+ } catch (Failed &f) {}
+
+ try {
+ Annotation_Test t("Annotation Names Can Start with \"annotation\"");
+ t.run (
+ "@annotation annotationannotation {\n"
+ "};\n"
+ "@annotationannotation\n"
+ "struct annotationannotation_struct {\n"
+ " short member;\n"
+ "};\n"
+ ).assert_annotation_decl ("::@annotationannotation");
+ } catch (Failed &f) {}
+
+ // Done, Print Overall Results
+ if (failed_test_count)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Annotation Test: %d out of %d subtests failed!\n"),
+ failed_test_count, total_test_count));
+ }
+ else
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Annotation Test: All %d subtests passed\n"),
+ total_test_count));
+ }
+ idl_global->set_err_count (failed_test_count);
}
diff --git a/TAO/tests/IDLv4/annotations/be_util.cpp b/TAO/tests/IDLv4/annotations/be_util.cpp
index 70ba9a2c9da..02ae81c5de1 100644
--- a/TAO/tests/IDLv4/annotations/be_util.cpp
+++ b/TAO/tests/IDLv4/annotations/be_util.cpp
@@ -6,7 +6,7 @@
#include "ace/OS_NS_strings.h"
void
-be_util::prep_be_arg (char *arg)
+be_util::prep_be_arg (char * /*arg*/)
{
}