~ubuntu-branches/ubuntu/precise/cppo/precise

« back to all changes in this revision

Viewing changes to test.cppo

  • Committer: Package Import Robot
  • Author(s): Stéphane Glondu
  • Date: 2011-11-02 07:09:56 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20111102070956-7ww040c3t4detxbq
Tags: 0.9.2-1
* Team upload
* New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
(* comment *)
2
2
 
3
 
#include "testdata/incl.cppo"
4
 
# 123456
5
 
#789 "test"
6
 
#include "testdata/incl.cppo"
7
 
 
8
 
#define debug(s) Printf.eprintf "%S %i: %s\n%!" __FILE__ __LINE__ s
9
 
 
10
3
#define pi 3.14
11
4
f(1)
12
5
#define f(x) x+pi
106
99
#error "math error"
107
100
#endif
108
101
 
 
102
 
 
103
#undef f
 
104
#undef g
 
105
#undef x
 
106
#undef y
 
107
 
 
108
#define trace(f) \
 
109
let f x = \
 
110
  printf "call %s\n%!" STRINGIFY(f); \
 
111
  let y = f x in \
 
112
  printf "return %s\n%!" STRINGIFY(f); \
 
113
  y \
 
114
;;
 
115
 
 
116
trace(g)
 
117
 
 
118
#define field(name,type) \
 
119
  val mutable name : type option \
 
120
  method CONCAT(get_, name) = name \
 
121
  method CONCAT(set_, name) x = name <- Some x
 
122
 
 
123
class foo () =
 
124
object
 
125
  field(field_1, int)
 
126
  field(field_2, string)
 
127
end
 
128
 
 
129
#define DEBUG(x) \
 
130
  (if !debug then \
 
131
    eprintf "[debug] %s %i: " __FILE__ __LINE__; \
 
132
    eprintf x; \
 
133
    eprintf "\n")
 
134
DEBUG("test1 %i %i" x y)
 
135
DEBUG("test2 %i" x)
 
136
 
 
137
#include "testdata/incl.cppo"
 
138
# 123456
 
139
 
 
140
#789 "test"
 
141
#include "testdata/incl.cppo"
 
142
 
 
143
#define debug(s) Printf.eprintf "%S %i: %s\n%!" __FILE__ __LINE__ s
 
144
 
109
145
end