m4-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

07-modtest.patch


From: Akim Demaille
Subject: 07-modtest.patch
Date: Mon, 01 Oct 2001 09:39:10 +0200

I'm waiting for (dis)?approvals.

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * modules/modtest.c (init_handler): Consistently output to stderr.
        (finish_handler): New.
        (test): The `if' is an `assert'.
        * tests/modules.at: Adjust.

Index: modules/modtest.c
--- modules/modtest.c Thu, 30 Aug 2001 15:53:29 +0200 akim
+++ modules/modtest.c Sun, 30 Sep 2001 14:32:52 +0200 akim
@@ -1,5 +1,5 @@
 /* GNU m4 -- A simple macro processor
-   Copyright 1999, 2000 Free Software Foundation, Inc.
+   Copyright 1999, 2000, 2001 Free Software Foundation, Inc.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -23,6 +23,8 @@

 #include <m4module.h>

+#include <assert.h>
+
 #define m4_builtin_table       modtest_LTX_m4_builtin_table
 #define m4_macro_table         modtest_LTX_m4_macro_table

@@ -59,10 +61,24 @@
  **/
 M4INIT_HANDLER (modtest)
 {
-  char *s = "Test module loaded.";
+  const char *s = "Test module loaded.";
+
+  /* Don't depend on OBS so that the traces are the same when used
+     directly, or via a frozen file.  */
+  fprintf (stderr, "%s\n", s);
+}
+
+
+/**
+ * modtest()
+ **/
+M4FINISH_HANDLER (modtest)
+{
+  const char *s = "Test module unloaded.";

-  if (obs != 0)
-    obstack_grow (obs, s, strlen(s));
+  /* Don't depend on OBS so that the traces are the same when used
+     directly, or via a frozen file.  */
+  fprintf (stderr, "%s\n", s);
 }


@@ -71,8 +87,8 @@
  **/
 M4BUILTIN_HANDLER (test)
 {
-  char *s = "Test module called.";
+  const char *s = "Test module called.";

-  if (obs != 0)
+  assert (obs != 0);
   obstack_grow (obs, s, strlen(s));
 }
Index: tests/modules.at
--- tests/modules.at Sun, 30 Sep 2001 14:01:09 +0200 akim
+++ tests/modules.at Sun, 30 Sep 2001 14:40:26 +0200 akim
@@ -83,16 +83,25 @@ m4_define([AT_CHECK_M4_MODTEST],
 [[load(`modtest')
 test
 Dumpdef: dumpdef(`test').
+unload(`modtest')
+test
+Dumpdef: dumpdef(`test').
 ]])

 AT_CHECK([$2 m4 -m load -d input.m4 $3], 0,
          m4_default([$4],
-[[Test module loaded.
+[[
 Test module called.
 Dumpdef: .
+
+test
+Dumpdef: .
 ]]),
          m4_default([$5],
-[[test:        <test>
+[[Test module loaded.
+test:  <test>
+Test module unloaded.
+m4: input.m4: 6: Warning: dumpdef: undefined name: test
 ]]))

 AT_CLEANUP
@@ -124,7 +133,7 @@ Dumpdef: .
 ## shadow ##
 ## ------ ##

-AT_SETUP([shadow])
+AT_SETUP([modules: shadow])

 AT_DATA([[input.m4]],
 [[# no modules loaded yet
@@ -147,7 +156,7 @@ Dumpdef: .
 # save the definition of `test' from the Shadow module
 define(`Shadow::test', defn(`test'))

-# module Test also defines a `test' macro
+# module Modtest also defines a `test' macro
 load(`modtest')
 dumpdef(`test')
 dumpdef(`shadow')
@@ -161,7 +170,7 @@ Dumpdef: .
 test
 shadow

-# Unloading Test will unshadow the test definition in Shadow
+# Unloading Modtest will unshadow the test definition in Shadow
 unload(`modtest')
 dumpdef(`test')
 dumpdef(`shadow')
@@ -203,8 +212,8 @@ Shadow::shadow called.
 # save the definition of `test' from the Shadow module


-# module Test also defines a `test' macro
-Test module loaded.
+# module Modtest also defines a `test' macro
+


 Test module called.
@@ -217,7 +226,7 @@ Shadow::shadow called.
 Test module called.
 Shadow::shadow called.

-# Unloading Test will unshadow the test definition in Shadow
+# Unloading Modtest will unshadow the test definition in Shadow



@@ -241,10 +250,12 @@ local::shadow
 AT_DATA([[experr]],
 [[test:        <test>
 shadow:        <shadow>
+Test module loaded.
 test:  <test>
 shadow:        <shadow>
 test:  <test>
 shadow:        <shadow>
+Test module unloaded.
 test:  <test>
 shadow:        <shadow>
 test:  <test>
@@ -262,7 +273,7 @@ shadow:     <shadow>
 ## unload ##
 ## ------ ##

-AT_SETUP([unload])
+AT_SETUP([modules: unload])

 AT_DATA([[input.m4]],
 [[test
@@ -290,7 +301,7 @@ shadow:     <shadow>
 AT_DATA([[expout]],
 [[test
 __test__
-Test module loaded.
+
 Test module called.
 modtest
 Shadow module loaded.
@@ -299,7 +310,7 @@ Shadow::test called.

 Shadow::test called.
 shadow
-Test module loaded.
+
 Test module called.
 modtest

@@ -310,6 +321,14 @@ Shadow::test called.
 __test__
 ]])

-AT_CHECK_M4([-m load input.m4], 0, expout)
+AT_DATA([[experr]],
+[[Test module loaded.
+Test module unloaded.
+Test module loaded.
+Test module unloaded.
+]])
+
+
+AT_CHECK_M4([-m load input.m4], 0, expout, experr)

 AT_CLEANUP



reply via email to

[Prev in Thread] Current Thread [Next in Thread]