m4-patches
[Top][All Lists]
Advanced

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

19-fyi-macros-at.patch


From: Akim Demaille
Subject: 19-fyi-macros-at.patch
Date: Sat, 13 Oct 2001 10:57:26 +0200

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * tests/builtins.at (pushdef/popdef, trace, trace2, trace3): Move
        to...
        * tests/macros.at (pushdef/popdef, Tracing Hanoi Towers)
        (Propagation of traceon, Propagation of --trace): this new file.

Index: tests/Makefile.am
--- tests/Makefile.am Thu, 04 Oct 2001 09:06:46 +0200 akim
+++ tests/Makefile.am Sat, 13 Oct 2001 10:04:10 +0200 akim
@@ -30,7 +30,7 @@

 TESTSUITE_AT = \
        testsuite.at \
-       builtins.at options.at others.at modules.at generated.at
+       macros.at builtins.at options.at others.at modules.at generated.at
 TESTSUITE = testsuite

 check-local: atconfig $(TESTSUITE)
Index: tests/builtins.at
--- tests/builtins.at Sat, 13 Oct 2001 08:43:17 +0200 akim
+++ tests/builtins.at Sat, 13 Oct 2001 10:02:16 +0200 akim
@@ -455,53 +455,6 @@ OBS: GNUs OBS: not OBS: Unix.



-## ---------------- ##
-## pushdef/popdef.  ##
-## ---------------- ##
-
-AT_SETUP([pushdef/popdef])
-
-AT_DATA([[pushpop.m4]],
-[[divert(-1)
-pushdef(`hej', `def 1.')
-dumpdef(`hej')
-pushdef(`hej', `def 2.')
-dumpdef(`hej')
-pushdef(`hej', `def 3.')
-dumpdef(`hej')
-pushdef(`hej', `def 4.')
-dumpdef(`hej')
-
-popdef(`hej')
-dumpdef(`hej')
-popdef(`hej')
-dumpdef(`hej')
-popdef(`hej')
-dumpdef(`hej')
-popdef(`hej')
-dumpdef(`hej')
-
-dumpdef(`mac2')
-popdef(`mac2')
-]])
-
-AT_CHECK_M4([pushpop.m4], 0, [],
-[[hej: `def 1.'
-hej:   `def 2.'
-hej:   `def 3.'
-hej:   `def 4.'
-hej:   `def 3.'
-hej:   `def 2.'
-hej:   `def 1.'
-m4: pushpop.m4: 18: Warning: dumpdef: undefined name: hej
-m4: pushpop.m4: 20: Warning: dumpdef: undefined name: mac2
-m4: pushpop.m4: 21: Warning: popdef: undefined name: mac2
-]])
-
-AT_CLEANUP
-
-
-
 ## ------ ##
 ## regexp ##
 ## ------ ##
@@ -601,266 +554,6 @@ m4trace: -1- regexp(`hej med dig', `m\(.
 #line 12
 foo line three.
 ]])
-
-AT_CLEANUP
-
-
-
-## ----- ##
-## trace ##
-## ----- ##
-
-AT_SETUP([trace])
-
-AT_DATA([[trace.m4]],
-[[divert(-1)
-
-# move(from, to)
-define(`move', `Move one disk from `$1' to `$2'.
-')
-
-# _hanoi (cnt, from, to, aux)
-define(`_hanoi', `ifelse(eval(`$1'<=1), 1, `move($2, $3)',
-`_hanoi(decr($1), $2, $4, $3)move($2, $3)_hanoi(decr($1), $4, $3, $2)')')
-
-# hanoi (cnt)
-define(`hanoi', `_hanoi(`$1', source, destination, auxilliary)')
-divert`'dnl
-
-# Debugmode t
-debugmode(`t')
-hanoi(2)
-
-# Debugmode taeq
-debugmode(`taeq')
-hanoi(2)
-
-# Debugmode OFF
-debugmode
-hanoi(2)
-
-# Debugmode ae
-debugmode(`ae')
-traceon(`move', `_hanoi')
-hanoi(2)
-]])
-
-AT_DATA([[expout]],
-[[
-# Debugmode t
-
-Move one disk from source to auxilliary.
-Move one disk from source to destination.
-Move one disk from auxilliary to destination.
-
-
-# Debugmode taeq
-
-Move one disk from source to auxilliary.
-Move one disk from source to destination.
-Move one disk from auxilliary to destination.
-
-
-# Debugmode OFF
-
-Move one disk from source to auxilliary.
-Move one disk from source to destination.
-Move one disk from auxilliary to destination.
-
-
-# Debugmode ae
-
-
-Move one disk from source to auxilliary.
-Move one disk from source to destination.
-Move one disk from auxilliary to destination.
-
-]])
-
-AT_DATA([[experr]],
-[[m4trace: -1- hanoi
-m4trace: -1- _hanoi
-m4trace: -2- eval
-m4trace: -1- ifelse
-m4trace: -2- decr
-m4trace: -1- _hanoi
-m4trace: -2- eval
-m4trace: -1- ifelse
-m4trace: -1- move
-m4trace: -1- move
-m4trace: -2- decr
-m4trace: -1- _hanoi
-m4trace: -2- eval
-m4trace: -1- ifelse
-m4trace: -1- move
-
-m4trace: -1- hanoi(`2') -> `_hanoi(`2', source, destination, auxilliary)'
-m4trace: -1- _hanoi(`2', `source', `destination', `auxilliary') -> 
`ifelse(eval(`2'<=1), 1, `move(source, destination)',
-`_hanoi(decr(2), source, auxilliary, destination)move(source, 
destination)_hanoi(decr(2), auxilliary, destination, source)')'
-m4trace: -2- eval(`2<=1') -> `0'
-m4trace: -1- ifelse(`0', `1', `move(source, destination)', `_hanoi(decr(2), 
source, auxilliary, destination)move(source, destination)_hanoi(decr(2), 
auxilliary, destination, source)') -> `_hanoi(decr(2), source, auxilliary, 
destination)move(source, destination)_hanoi(decr(2), auxilliary, destination, 
source)'
-m4trace: -2- decr(`2') -> `1'
-m4trace: -1- _hanoi(`1', `source', `auxilliary', `destination') -> 
`ifelse(eval(`1'<=1), 1, `move(source, auxilliary)',
-`_hanoi(decr(1), source, destination, auxilliary)move(source, 
auxilliary)_hanoi(decr(1), destination, auxilliary, source)')'
-m4trace: -2- eval(`1<=1') -> `1'
-m4trace: -1- ifelse(`1', `1', `move(source, auxilliary)', `_hanoi(decr(1), 
source, destination, auxilliary)move(source, auxilliary)_hanoi(decr(1), 
destination, auxilliary, source)') -> `move(source, auxilliary)'
-m4trace: -1- move(`source', `auxilliary') -> `Move one disk from `source' to 
`auxilliary'.
-'
-m4trace: -1- move(`source', `destination') -> `Move one disk from `source' to 
`destination'.
-'
-m4trace: -2- decr(`2') -> `1'
-m4trace: -1- _hanoi(`1', `auxilliary', `destination', `source') -> 
`ifelse(eval(`1'<=1), 1, `move(auxilliary, destination)',
-`_hanoi(decr(1), auxilliary, source, destination)move(auxilliary, 
destination)_hanoi(decr(1), source, destination, auxilliary)')'
-m4trace: -2- eval(`1<=1') -> `1'
-m4trace: -1- ifelse(`1', `1', `move(auxilliary, destination)', 
`_hanoi(decr(1), auxilliary, source, destination)move(auxilliary, 
destination)_hanoi(decr(1), source, destination, auxilliary)') -> 
`move(auxilliary, destination)'
-m4trace: -1- move(`auxilliary', `destination') -> `Move one disk from 
`auxilliary' to `destination'.
-'
-m4trace: -1- debugmode
-m4trace: -1- _hanoi(2, source, destination, auxilliary) -> 
ifelse(eval(`2'<=1), 1, `move(source, destination)',
-`_hanoi(decr(2), source, auxilliary, destination)move(source, 
destination)_hanoi(decr(2), auxilliary, destination, source)')
-m4trace: -1- _hanoi(1, source, auxilliary, destination) -> 
ifelse(eval(`1'<=1), 1, `move(source, auxilliary)',
-`_hanoi(decr(1), source, destination, auxilliary)move(source, 
auxilliary)_hanoi(decr(1), destination, auxilliary, source)')
-m4trace: -1- move(source, auxilliary) -> Move one disk from `source' to 
`auxilliary'.
-
-m4trace: -1- move(source, destination) -> Move one disk from `source' to 
`destination'.
-
-m4trace: -1- _hanoi(1, auxilliary, destination, source) -> 
ifelse(eval(`1'<=1), 1, `move(auxilliary, destination)',
-`_hanoi(decr(1), auxilliary, source, destination)move(auxilliary, 
destination)_hanoi(decr(1), source, destination, auxilliary)')
-m4trace: -1- move(auxilliary, destination) -> Move one disk from `auxilliary' 
to `destination'.
-
-]])
-
-AT_CHECK_M4([trace.m4], 0, expout, experr)
-
-AT_CLEANUP
-
-
-
-## ------ ##
-## trace2 ##
-## ------ ##
-
-AT_SETUP([trace2])
-
-AT_DATA([[trace2.m4]],
-[[traceon(`define')
-debugmode(`aeq')
-
-# copy the `define' builtin definition to another symbol
-define(`my_define', defn(`define'))
-
-# delete the original
-undefine(`define')
-
-# Does it work?
-my_define(`foo', `bar')
-
-# Use the new definition to redefine the original symbol
-my_define(`define', defn(`my_define'))
-
-# Torture the flag propogation
-undefine(`my_define')
-define(`my_define', defn(`define'))
-
-# There are now 2 symbols pointing to the same builtin function
-my_define(`foo', `bar')
-define(`foo', `bar')
-]])
-
-AT_DATA([[expout]],
-[[
-
-
-# copy the `define' builtin definition to another symbol
-
-
-# delete the original
-
-
-# Does it work?
-
-
-# Use the new definition to redefine the original symbol
-
-
-# Torture the flag propogation
-
-
-
-# There are now 2 symbols pointing to the same builtin function
-
-
-]])
-
-AT_DATA([[experr]],
-[[m4trace: -1- define(`my_define', <define>)
-m4trace: -1- define(`my_define', <define>)
-m4trace: -1- define(`foo', `bar')
-]])
-
-AT_CHECK_M4([trace2.m4], 0, expout, experr)
-
-AT_CLEANUP
-
-
-
-## ------ ##
-## trace3 ##
-## ------ ##
-
-AT_SETUP([trace3])
-
-AT_DATA([[trace3.m4]],
-[[# copy the `define' builtin definition to another symbol
-define(`my_define', defn(`define'))
-
-# delete the original
-undefine(`define')
-
-# Does it work?
-my_define(`foo', `bar')
-
-# Use the new definition to redefine the original symbol
-my_define(`define', defn(`my_define'))
-
-# Torture the flag propogation
-undefine(`my_define')
-define(`my_define', defn(`define'))
-
-# There are now 2 symbols pointing to the same builtin function
-my_define(`foo', `bar')
-define(`foo', `bar')
-]])
-
-AT_DATA([[expout]],
-[[# copy the `define' builtin definition to another symbol
-
-
-# delete the original
-
-
-# Does it work?
-
-
-# Use the new definition to redefine the original symbol
-
-
-# Torture the flag propogation
-
-
-
-# There are now 2 symbols pointing to the same builtin function
-
-
-]])
-
-AT_DATA([[experr]],
-[[m4trace: -1- define(`my_define', <define>)
-m4trace: -1- define(`my_define', <define>)
-m4trace: -1- define(`foo', `bar')
-]])
-
-AT_CHECK_M4([-t define -daeq trace3.m4], 0, expout, experr)

 AT_CLEANUP

Index: tests/testsuite.at
--- tests/testsuite.at Thu, 04 Oct 2001 09:06:46 +0200 akim
+++ tests/testsuite.at Sat, 13 Oct 2001 10:04:45 +0200 akim
@@ -49,6 +49,9 @@ m4_define([AT_TEST_M4],

 AT_INIT

+# Macro definitions, uses, tracing etc.
+m4_include([macros.at])
+
 # Torturing builtins.
 m4_include([builtins.at])

Index: tests/macros.at
--- tests/macros.at Sat, 13 Oct 2001 10:06:47 +0200 akim
+++ tests/macros.at Sat, 13 Oct 2001 10:01:38 +0200 akim
@@ -0,0 +1,328 @@
+# Hand crafted tests for GNU M4.                               -*- Autotest -*-
+# Copyright 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
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+AT_BANNER([Macro definitions.])
+
+# Checking everything related to macro definitions: the expansion of
+# user macros, the propagation of various bits (tracing, number of
+# arguments and so on).
+
+## ---------------- ##
+## pushdef/popdef.  ##
+## ---------------- ##
+
+AT_SETUP([pushdef/popdef])
+
+AT_DATA([[pushpop.m4]],
+[[divert(-1)
+pushdef(`hej', `def 1.')
+dumpdef(`hej')
+pushdef(`hej', `def 2.')
+dumpdef(`hej')
+pushdef(`hej', `def 3.')
+dumpdef(`hej')
+pushdef(`hej', `def 4.')
+dumpdef(`hej')
+
+popdef(`hej')
+dumpdef(`hej')
+popdef(`hej')
+dumpdef(`hej')
+popdef(`hej')
+dumpdef(`hej')
+popdef(`hej')
+dumpdef(`hej')
+
+dumpdef(`mac2')
+popdef(`mac2')
+]])
+
+AT_CHECK_M4([pushpop.m4], 0, [],
+[[hej: `def 1.'
+hej:   `def 2.'
+hej:   `def 3.'
+hej:   `def 4.'
+hej:   `def 3.'
+hej:   `def 2.'
+hej:   `def 1.'
+m4: pushpop.m4: 18: Warning: dumpdef: undefined name: hej
+m4: pushpop.m4: 20: Warning: dumpdef: undefined name: mac2
+m4: pushpop.m4: 21: Warning: popdef: undefined name: mac2
+]])
+
+AT_CLEANUP
+
+
+
+## ---------------------- ##
+## Tracing Hanoi Towers.  ##
+## ---------------------- ##
+
+AT_SETUP([Tracing Hanoi Towers])
+
+AT_DATA([[trace.m4]],
+[[divert(-1)
+
+# move(from, to)
+define(`move', `Move one disk from `$1' to `$2'.
+')
+
+# _hanoi (cnt, from, to, aux)
+define(`_hanoi', `ifelse(eval(`$1'<=1), 1, `move($2, $3)',
+`_hanoi(decr($1), $2, $4, $3)move($2, $3)_hanoi(decr($1), $4, $3, $2)')')
+
+# hanoi (cnt)
+define(`hanoi', `_hanoi(`$1', source, destination, auxilliary)')
+divert`'dnl
+
+# Debugmode t
+debugmode(`t')
+hanoi(2)
+
+# Debugmode taeq
+debugmode(`taeq')
+hanoi(2)
+
+# Debugmode OFF
+debugmode
+hanoi(2)
+
+# Debugmode ae
+debugmode(`ae')
+traceon(`move', `_hanoi')
+hanoi(2)
+]])
+
+AT_DATA([[expout]],
+[[
+# Debugmode t
+
+Move one disk from source to auxilliary.
+Move one disk from source to destination.
+Move one disk from auxilliary to destination.
+
+
+# Debugmode taeq
+
+Move one disk from source to auxilliary.
+Move one disk from source to destination.
+Move one disk from auxilliary to destination.
+
+
+# Debugmode OFF
+
+Move one disk from source to auxilliary.
+Move one disk from source to destination.
+Move one disk from auxilliary to destination.
+
+
+# Debugmode ae
+
+
+Move one disk from source to auxilliary.
+Move one disk from source to destination.
+Move one disk from auxilliary to destination.
+
+]])
+
+AT_DATA([[experr]],
+[[m4trace: -1- hanoi
+m4trace: -1- _hanoi
+m4trace: -2- eval
+m4trace: -1- ifelse
+m4trace: -2- decr
+m4trace: -1- _hanoi
+m4trace: -2- eval
+m4trace: -1- ifelse
+m4trace: -1- move
+m4trace: -1- move
+m4trace: -2- decr
+m4trace: -1- _hanoi
+m4trace: -2- eval
+m4trace: -1- ifelse
+m4trace: -1- move
+
+m4trace: -1- hanoi(`2') -> `_hanoi(`2', source, destination, auxilliary)'
+m4trace: -1- _hanoi(`2', `source', `destination', `auxilliary') -> 
`ifelse(eval(`2'<=1), 1, `move(source, destination)',
+`_hanoi(decr(2), source, auxilliary, destination)move(source, 
destination)_hanoi(decr(2), auxilliary, destination, source)')'
+m4trace: -2- eval(`2<=1') -> `0'
+m4trace: -1- ifelse(`0', `1', `move(source, destination)', `_hanoi(decr(2), 
source, auxilliary, destination)move(source, destination)_hanoi(decr(2), 
auxilliary, destination, source)') -> `_hanoi(decr(2), source, auxilliary, 
destination)move(source, destination)_hanoi(decr(2), auxilliary, destination, 
source)'
+m4trace: -2- decr(`2') -> `1'
+m4trace: -1- _hanoi(`1', `source', `auxilliary', `destination') -> 
`ifelse(eval(`1'<=1), 1, `move(source, auxilliary)',
+`_hanoi(decr(1), source, destination, auxilliary)move(source, 
auxilliary)_hanoi(decr(1), destination, auxilliary, source)')'
+m4trace: -2- eval(`1<=1') -> `1'
+m4trace: -1- ifelse(`1', `1', `move(source, auxilliary)', `_hanoi(decr(1), 
source, destination, auxilliary)move(source, auxilliary)_hanoi(decr(1), 
destination, auxilliary, source)') -> `move(source, auxilliary)'
+m4trace: -1- move(`source', `auxilliary') -> `Move one disk from `source' to 
`auxilliary'.
+'
+m4trace: -1- move(`source', `destination') -> `Move one disk from `source' to 
`destination'.
+'
+m4trace: -2- decr(`2') -> `1'
+m4trace: -1- _hanoi(`1', `auxilliary', `destination', `source') -> 
`ifelse(eval(`1'<=1), 1, `move(auxilliary, destination)',
+`_hanoi(decr(1), auxilliary, source, destination)move(auxilliary, 
destination)_hanoi(decr(1), source, destination, auxilliary)')'
+m4trace: -2- eval(`1<=1') -> `1'
+m4trace: -1- ifelse(`1', `1', `move(auxilliary, destination)', 
`_hanoi(decr(1), auxilliary, source, destination)move(auxilliary, 
destination)_hanoi(decr(1), source, destination, auxilliary)') -> 
`move(auxilliary, destination)'
+m4trace: -1- move(`auxilliary', `destination') -> `Move one disk from 
`auxilliary' to `destination'.
+'
+m4trace: -1- debugmode
+m4trace: -1- _hanoi(2, source, destination, auxilliary) -> 
ifelse(eval(`2'<=1), 1, `move(source, destination)',
+`_hanoi(decr(2), source, auxilliary, destination)move(source, 
destination)_hanoi(decr(2), auxilliary, destination, source)')
+m4trace: -1- _hanoi(1, source, auxilliary, destination) -> 
ifelse(eval(`1'<=1), 1, `move(source, auxilliary)',
+`_hanoi(decr(1), source, destination, auxilliary)move(source, 
auxilliary)_hanoi(decr(1), destination, auxilliary, source)')
+m4trace: -1- move(source, auxilliary) -> Move one disk from `source' to 
`auxilliary'.
+
+m4trace: -1- move(source, destination) -> Move one disk from `source' to 
`destination'.
+
+m4trace: -1- _hanoi(1, auxilliary, destination, source) -> 
ifelse(eval(`1'<=1), 1, `move(auxilliary, destination)',
+`_hanoi(decr(1), auxilliary, source, destination)move(auxilliary, 
destination)_hanoi(decr(1), source, destination, auxilliary)')
+m4trace: -1- move(auxilliary, destination) -> Move one disk from `auxilliary' 
to `destination'.
+
+]])
+
+AT_CHECK_M4([trace.m4], 0, expout, experr)
+
+AT_CLEANUP
+
+
+
+## ------------------------------- ##
+## Propagation of trace requests.  ##
+## ------------------------------- ##
+
+AT_SETUP([Propagation of traceon])
+
+AT_DATA([[trace2.m4]],
+[[traceon(`define')
+debugmode(`aeq')
+
+# copy the `define' builtin definition to another symbol
+define(`my_define', defn(`define'))
+
+# delete the original
+undefine(`define')
+
+# Does it work?
+my_define(`foo', `bar')
+
+# Use the new definition to redefine the original symbol
+my_define(`define', defn(`my_define'))
+
+# Torture the flag propogation
+undefine(`my_define')
+define(`my_define', defn(`define'))
+
+# There are now 2 symbols pointing to the same builtin function
+my_define(`foo', `bar')
+define(`foo', `bar')
+]])
+
+AT_DATA([[expout]],
+[[
+
+
+# copy the `define' builtin definition to another symbol
+
+
+# delete the original
+
+
+# Does it work?
+
+
+# Use the new definition to redefine the original symbol
+
+
+# Torture the flag propogation
+
+
+
+# There are now 2 symbols pointing to the same builtin function
+
+
+]])
+
+AT_DATA([[experr]],
+[[m4trace: -1- define(`my_define', <define>)
+m4trace: -1- define(`my_define', <define>)
+m4trace: -1- define(`foo', `bar')
+]])
+
+AT_CHECK_M4([trace2.m4], 0, expout, experr)
+
+AT_CLEANUP
+
+
+
+## ------------------------ ##
+## Propagation of --trace.  ##
+## ------------------------ ##
+
+AT_SETUP([Propagation of --trace])
+
+AT_DATA([[trace3.m4]],
+[[# copy the `define' builtin definition to another symbol
+define(`my_define', defn(`define'))
+
+# delete the original
+undefine(`define')
+
+# Does it work?
+my_define(`foo', `bar')
+
+# Use the new definition to redefine the original symbol
+my_define(`define', defn(`my_define'))
+
+# Torture the flag propogation
+undefine(`my_define')
+define(`my_define', defn(`define'))
+
+# There are now 2 symbols pointing to the same builtin function
+my_define(`foo', `bar')
+define(`foo', `bar')
+]])
+
+AT_DATA([[expout]],
+[[# copy the `define' builtin definition to another symbol
+
+
+# delete the original
+
+
+# Does it work?
+
+
+# Use the new definition to redefine the original symbol
+
+
+# Torture the flag propogation
+
+
+
+# There are now 2 symbols pointing to the same builtin function
+
+
+]])
+
+AT_DATA([[experr]],
+[[m4trace: -1- define(`my_define', <define>)
+m4trace: -1- define(`my_define', <define>)
+m4trace: -1- define(`foo', `bar')
+]])
+
+AT_CHECK_M4([-t define -daeq trace3.m4], 0, expout, experr)
+
+AT_CLEANUP



reply via email to

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