Statistiques
| Révision :

root / pobysoC-4.0 / src / test-pobyso-constant-expression.c @ 134

Historique | Voir | Annoter | Télécharger (3,29 ko)

1
/** @file test-pobyso-constant-expression.c
2
 * Name & purpose
3
 *
4
 * @author
5
 * @date
6
 *
7
 * @details Verbosity manipulation are performed  to make sur  that verbosity
8
 *  suppression is correctly managed in pobyso_is_constant_expression()
9
 *  function.
10
 */
11
/******************************************************************************/
12
/* Headers, applying the "particular to general" convention.*/
13

    
14
#include "pobyso.h"
15

    
16
/* includes of local headers */
17

    
18
/* includes of project headers */
19

    
20
/* includes of system headers */
21

    
22
/* Other declarations */
23

    
24
/* Internal prototypes */
25

    
26
/* Types, constants and macros definitions */
27

    
28
/* Global variables */
29

    
30
/* Functions */
31

    
32
int
33
main(int argc, char** argv)
34
{
35
  pobyso_func_exp_t func_exp  = NULL;
36
  int verbosity               = 0;
37
  sollya_obj_t on             = NULL;
38
  sollya_obj_t off            = NULL;
39

    
40
  sollya_lib_init();
41

    
42
  pobyso_set_canonical_on();
43
  off = sollya_lib_off();
44
  on  = sollya_lib_on();
45

    
46
  fprintf(stdout, "NULL argument:\n");
47
  if (! pobyso_is_constant_expression(func_exp))
48
  {
49
    fprintf(stdout, "OK.\n");
50
  }
51
  else
52
  {
53
    fprintf(stdout, "Error for NULL argument.\n");
54
    return 1;
55
  }
56

    
57
  fprintf(stdout, "Argument : 1\n");
58
  func_exp = pobyso_parse_string("1");
59
  if (pobyso_is_constant_expression(func_exp))
60
  {
61
    pobyso_autoprint(func_exp);
62
    fprintf(stdout, "OK.\n");
63
    sollya_lib_clear_obj(func_exp);
64
  }
65
  else
66
  {
67
    fprintf(stdout, "Error for \"1\".\n");
68
    return 1;
69
  }
70
  verbosity = pobyso_set_verbosity_off();
71
  func_exp = pobyso_parse_string("1.1");
72
  pobyso_set_verbosity_to(verbosity);
73
  if (pobyso_is_constant_expression(func_exp))
74
  {
75
    pobyso_autoprint(func_exp);
76
    fprintf(stdout, "OK.\n");
77
    sollya_lib_clear_obj(func_exp);
78
  }
79
  else
80
  {
81
    fprintf(stdout, "Error for \"1.1\".\n");
82
    return 1;
83
  }
84

    
85
  func_exp = pobyso_parse_string("1/2");
86
  if (pobyso_is_constant_expression(func_exp))
87
  {
88
    pobyso_autoprint(func_exp);
89
    fprintf(stdout, "OK for \"1/2\".\n");
90
    sollya_lib_clear_obj(func_exp);
91
  }
92
  else
93
  {
94
    fprintf(stdout, "Error for \"1/2\".\n");
95
    return 1;
96
  }
97

    
98
  verbosity = pobyso_set_verbosity_off();
99
  sollya_lib_set_roundingwarnings(off);
100
  func_exp = sollya_lib_pi();
101
  pobyso_set_verbosity_to(verbosity);
102
  sollya_lib_set_roundingwarnings(on);
103
  if (pobyso_is_constant_expression(func_exp))
104
  {
105
    pobyso_autoprint(func_exp);
106
    fprintf(stdout,"OK for pi.\n");
107
    sollya_lib_clear_obj(func_exp);
108
  }
109
  else
110
  {
111
    fprintf(stdout, "Error for \"pi\".\n");
112
    return 1;
113
  }
114

    
115
  func_exp = pobyso_parse_string("x^2");
116
  if (! pobyso_is_constant_expression(func_exp))
117
  {
118
    fprintf(stdout, "Non constant expression \"x^2\": OK\n");
119
  }
120
  else
121
  {
122
    fprintf(stdout, "Error for \"x^2\".\n");
123
    return 1;
124
  }
125

    
126
  func_exp = pobyso_parse_string("cos(x)");
127
  if (! pobyso_is_constant_expression(func_exp))
128
  {
129
    pobyso_autoprint(func_exp);
130
    fprintf(stdout, "Non constant expression \"cos(x)\": OK\n");
131
    sollya_lib_clear_obj(func_exp);
132
  }
133
  else
134
  {
135
    fprintf(stdout, "Error for \"cos(x)\".\n");
136
    return 1;
137
  }
138

    
139
  verbosity = pobyso_set_verbosity_off();
140
  func_exp = pobyso_parse_string("cos(pi)");
141
  pobyso_set_verbosity_to(verbosity);
142
  {
143
    pobyso_autoprint(func_exp);
144
    fprintf(stdout, "OK for \"cos(pi)\".\n");
145
    sollya_lib_clear_obj(func_exp);
146
  }
147
  /*  */
148

    
149
  sollya_lib_close();
150
  return 0;
151
} /* End main */