~ubuntu-branches/ubuntu/hardy/sigscheme/hardy-proposed

« back to all changes in this revision

Viewing changes to test-c/test-global.c

  • Committer: Bazaar Package Importer
  • Author(s): NIIBE Yutaka
  • Date: 2007-01-29 15:31:24 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070129153124-j5fcqyrwcfbczma7
Tags: 0.7.4-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*===========================================================================
 
2
 *  Filename : test-global.c
 
3
 *  About    : unit test for global object handlings
 
4
 *
 
5
 *  Copyright (C) 2006 YAMAMOTO Kengo <yamaken AT bp.iij4u.or.jp>
 
6
 *  Copyright (c) 2007 SigScheme Project <uim AT freedesktop.org>
 
7
 *
 
8
 *  All rights reserved.
 
9
 *
 
10
 *  Redistribution and use in source and binary forms, with or without
 
11
 *  modification, are permitted provided that the following conditions
 
12
 *  are met:
 
13
 *
 
14
 *  1. Redistributions of source code must retain the above copyright
 
15
 *     notice, this list of conditions and the following disclaimer.
 
16
 *  2. Redistributions in binary form must reproduce the above copyright
 
17
 *     notice, this list of conditions and the following disclaimer in the
 
18
 *     documentation and/or other materials provided with the distribution.
 
19
 *  3. Neither the name of authors nor the names of its contributors
 
20
 *     may be used to endorse or promote products derived from this software
 
21
 *     without specific prior written permission.
 
22
 *
 
23
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
 
24
 *  IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 
25
 *  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 
26
 *  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
 
27
 *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 
28
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 
29
 *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 
30
 *  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 
31
 *  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 
32
 *  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 
33
 *  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
34
===========================================================================*/
 
35
 
 
36
#define SCM_WRITABLE_STATICLESS_PLATFORM 0
 
37
#define SCM_COMBINED_SOURCE 0
 
38
 
 
39
#include "sscm-test.h"
 
40
 
 
41
#include <sigscheme/global.h>
 
42
#include <sigscheme/sigscheme.h>
 
43
#include "sigschemeinternal.h"
 
44
 
 
45
SCM_GLOBAL_VARS_BEGIN(exported);
 
46
ScmObj obj_a, obj_b;
 
47
ScmObj obj_c;
 
48
SCM_GLOBAL_VARS_END(exported);
 
49
#define obj_a SCM_GLOBAL_VAR(exported, obj_a)
 
50
#define obj_b SCM_GLOBAL_VAR(exported, obj_b)
 
51
#define obj_c SCM_GLOBAL_VAR(exported, obj_c)
 
52
SCM_DECLARE_EXPORTED_VARS(exported);
 
53
SCM_DEFINE_EXPORTED_VARS(exported);
 
54
 
 
55
SCM_GLOBAL_VARS_BEGIN(static);
 
56
ScmObj obj_d, obj_e;
 
57
ScmObj obj_f;
 
58
SCM_GLOBAL_VARS_END(static);
 
59
#define obj_d SCM_GLOBAL_VAR(static, obj_d)
 
60
#define obj_e SCM_GLOBAL_VAR(static, obj_e)
 
61
#define obj_f SCM_GLOBAL_VAR(static, obj_f)
 
62
SCM_DEFINE_STATIC_VARS(static);
 
63
 
 
64
TST_CASE("exported vars")
 
65
{
 
66
    SCM_GLOBAL_VARS_INIT(exported);
 
67
    obj_a = MAKE_INT(1);
 
68
    obj_b = MAKE_INT(2);
 
69
    obj_c = MAKE_INT(3);
 
70
    TST_TN_EQ_INT(1, SCM_INT_VALUE(obj_a));
 
71
    TST_TN_EQ_INT(2, SCM_INT_VALUE(obj_b));
 
72
    TST_TN_EQ_INT(3, SCM_INT_VALUE(obj_c));
 
73
}
 
74
 
 
75
TST_CASE("static vars")
 
76
{
 
77
    SCM_GLOBAL_VARS_INIT(static);
 
78
    obj_d = MAKE_INT(4);
 
79
    obj_e = MAKE_INT(5);
 
80
    obj_f = MAKE_INT(6);
 
81
    TST_TN_EQ_INT(4, SCM_INT_VALUE(obj_d));
 
82
    TST_TN_EQ_INT(5, SCM_INT_VALUE(obj_e));
 
83
    TST_TN_EQ_INT(6, SCM_INT_VALUE(obj_f));
 
84
}