VirtualBox

source: kBuild/trunk/src/kmk/testcase-math.kmk@ 2657

Last change on this file since 2657 was 2413, checked in by bird, 14 years ago

copyright year update.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.3 KB
Line 
1# $Id: testcase-math.kmk 2413 2010-09-11 17:43:04Z bird $
2## @file
3# kBuild - testcase for the math functions.
4#
5
6#
7# Copyright (c) 2007-2010 knut st. osmundsen <[email protected]>
8#
9# This file is part of kBuild.
10#
11# kBuild is free software; you can redistribute it and/or modify
12# it under the terms of the GNU General Public License as published by
13# the Free Software Foundation; either version 3 of the License, or
14# (at your option) any later version.
15#
16# kBuild is distributed in the hope that it will be useful,
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
22# along with kBuild. If not, see <http://www.gnu.org/licenses/>
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
36
37ASSERT_TRUE = $(if $(not $(1)),$(error failure: '$(1)' isn't true))
38ASSERT_FALSE = $(if $(1) ,$(error failure: '$(1)' isn't false))
39
40$(call ASSERT_TRUE, $(int-eq 0x0, 0))
41$(call ASSERT_FALSE,$(int-eq 1, 0))
42$(call ASSERT_FALSE,$(int-eq 1123123123, 9898787987))
43$(call ASSERT_TRUE, $(int-eq 1234567890, 1234567890))
44$(call ASSERT_TRUE, $(int-eq 0x1c, 28))
45$(call ASSERT_TRUE, $(int-eq 1c, 28))
46$(call ASSERT_TRUE, $(int-ne 0x123, -0x123))
47$(call ASSERT_TRUE, $(int-ne 123, -0x123))
48$(call ASSERT_FALSE,$(int-ne 0x100, 256))
49$(call ASSERT_FALSE,$(int-ne 0x0, 0))
50$(call ASSERT_FALSE,$(int-ne 0x1c, 28))
51$(call ASSERT_TRUE, $(int-le 0, 0))
52$(call ASSERT_TRUE, $(int-le -0, 0))
53$(call ASSERT_FALSE,$(int-le 5, 1))
54$(call ASSERT_FALSE,$(int-lt 5, 1))
55$(call ASSERT_FALSE,$(int-lt 5, 5))
56$(call ASSERT_TRUE, $(int-lt 9, 10))
57$(call ASSERT_TRUE, $(int-lt -9, -8))
58$(call ASSERT_TRUE, $(int-ge 0, 0))
59$(call ASSERT_TRUE, $(int-ge -0, 0))
60$(call ASSERT_TRUE, $(int-ge 1, 0))
61$(call ASSERT_TRUE, $(int-ge -55, -55))
62$(call ASSERT_TRUE, $(int-ge 512, 400))
63$(call ASSERT_TRUE, $(int-ge -18, -19))
64$(call ASSERT_FALSE,$(int-ge -19, -18))
65$(call ASSERT_FALSE,$(int-ge 15, 20))
66$(call ASSERT_FALSE,$(int-gt 15, 20))
67$(call ASSERT_FALSE,$(int-gt 15, 15))
68$(call ASSERT_TRUE, $(int-gt 20, 15))
69
70ASSERT2 = $(if $(not $(int-eq $(1),$(2))),$(error failure: '$(1)' -ne '$(2)'))
71$(call ASSERT2,$(int-add 1, 1),0x2)
72$(call ASSERT2,$(int-add 1, 1, 1, 1, 1, 1, 1),7)
73$(call ASSERT2,$(int-add 1, -1),0)
74$(call ASSERT2,$(int-sub 1, -1),2)
75$(call ASSERT2,$(int-sub 1, 5),-4)
76$(call ASSERT2,$(int-mul 0x10, 0x20),0x200)
77$(call ASSERT2,$(int-mul 0x20, 0x10),0x200)
78$(call ASSERT2,$(int-mul 4, 7),28)
79$(call ASSERT2,$(int-mul 2, 2, 2, 2, 2, 4, 1, 1, 1, 1),128)
80$(call ASSERT2,$(int-div 0x1000, 0x100),0x10)
81$(call ASSERT2,$(int-div 999, 10),99)
82$(call ASSERT2,$(int-div 4096, 4,2,2,2,2),64)
83#$(call ASSERT2,$(int-div 0x1230023213, 0),0x0)
84$(call ASSERT2,$(int-mod 19, 10),9)
85$(call ASSERT2,$(int-mod 9, 10),9)
86$(call ASSERT2,$(int-mod 30, 10),0)
87$(call ASSERT2,$(int-not 0),-1)
88$(call ASSERT2,$(int-and 1, 1),1)
89$(call ASSERT2,$(int-and 0x123123214, 0xfff),0x214)
90$(call ASSERT2,$(int-and 0x123123214, 0xf0f, 0xf),4)
91$(call ASSERT2,$(int-or 1, 1, 1, 2, 2),3)
92$(call ASSERT2,$(int-xor 1, 1, 2, 2),0)
93$(call ASSERT2,$(int-xor 1, 2, 4),7)
94
95
96all_recursive:
97 $(ECHO) The math works. 6 * 7 = $(int-mul 6,7)
98
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette