source: trunk/src/kmk/testcase-stack.kmk

Last change on this file was 2413, checked in by bird, 15 years ago

copyright year update.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 KB
RevLine 
[2019]1# $Id: testcase-stack.kmk 2413 2010-09-11 17:43:04Z bird $
[819]2## @file
3# kBuild - testcase for the functions.
4#
[2019]5
[819]6#
[2413]7# Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net>
[819]8#
[2019]9# This file is part of kBuild.
[819]10#
[2019]11# kBuild is free software; you can redistribute it and/or modify
[819]12# it under the terms of the GNU General Public License as published by
[2019]13# the Free Software Foundation; either version 3 of the License, or
[819]14# (at your option) any later version.
15#
[2019]16# kBuild is distributed in the hope that it will be useful,
[819]17# but WITHOUT ANY WARRANTY; without even the implied warranty of
18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19# GNU General Public License for more details.
20#
21# You should have received a copy of the GNU General Public License
[2019]22# along with kBuild. If not, see <http://www.gnu.org/licenses/>
[819]23#
24#
25
26DEPTH = ../..
27include $(PATH_KBUILD)/header.kmk
28
29ifneq ($(not 1),)
30 $(error The 'not' function is missing)
31endif
32ifneq ($(eq 1,1),1)
33 $(error The 'eq' function is missing)
34endif
35
36ASSERT1 = $(if $(not $(eq $(STACK1),$(1))),$(error failure: STACK1:='$(STACK1)' expected='$(1)'))
37$(call stack-push,STACK1,1)
38$(call ASSERT,1)
39$(call stack-push,STACK1,2)
40$(call ASSERT,1 2)
41$(call stack-push,STACK1,3)
42$(call ASSERT,1 2 3)
43$(call stack-push,STACK1,4)
44$(call ASSERT,1 2 3 4)
45$(call stack-push,STACK1,5)
46$(call ASSERT,1 2 3 4 5)
47$(call stack-popv,STACK1)
48$(call ASSERT,1 2 3 4)
49$(call stack-push,STACK1,5)
50$(call ASSERT,1 2 3 4 5)
51$(call stack-popv,STACK1)
52$(call ASSERT,1 2 3 4)
53$(call stack-popv,STACK1)
54$(call ASSERT,1 2 3)
55$(call stack-push,STACK1,4)
56$(call ASSERT,1 2 3 4)
57$(call stack-push,STACK1,5)
58$(call ASSERT,1 2 3 4 5)
59top := $(call stack-top,STACK1)
60$(if $(not $(eq $(top),5)),$(error failure STACK1:='$(STACK1)' top:='$(top)' expected='5'))
61$(call ASSERT,1 2 3 4 5)
62top := $(call stack-pop,STACK1)
63$(if $(not $(eq $(top),5)),$(error failure STACK1:='$(STACK1)' top:='$(top)' expected='5'))
64$(call ASSERT,1 2 3 4)
65top := $(call stack-pop,STACK1)
66$(if $(not $(eq $(top),4)),$(error failure STACK1:='$(STACK1)' top:='$(top)' expected='4'))
67$(call ASSERT,1 2 3)
68top := $(call stack-pop,STACK1)
69$(if $(not $(eq $(top),3)),$(error failure STACK1:='$(STACK1)' top:='$(top)' expected='3'))
70$(call ASSERT,1 2)
71top := $(call stack-pop,STACK1)
72$(if $(not $(eq $(top),2)),$(error failure STACK1:='$(STACK1)' top:='$(top)' expected='2'))
73$(call ASSERT,1)
74top := $(call stack-top,STACK1)
75$(if $(not $(eq $(top),1)),$(error failure STACK1:='$(STACK1)' top:='$(top)' expected='1'))
76$(call ASSERT,1)
77top := $(call stack-pop,STACK1)
78$(if $(not $(eq $(top),1)),$(error failure STACK1:='$(STACK1)' top:='$(top)' expected='1'))
79$(call ASSERT,)
80top := $(call stack-pop,STACK1)
81$(if $(not $(eq $(top),)),$(error failure STACK1:='$(STACK1)' top:='$(top)' expected=''))
82$(call ASSERT,)
83
84all_recursive:
85 $(ECHO) The stack works.$(STACK1)
[2019]86
Note: See TracBrowser for help on using the repository browser.