~ubuntu-branches/ubuntu/trusty/emscripten/trusty-proposed

« back to all changes in this revision

Viewing changes to tests/core/test_statics.in

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2014-01-19 14:12:40 UTC
  • mfrom: (1.2.4)
  • Revision ID: package-import@ubuntu.com-20140119141240-jg1l42cc158j59tn
Tags: 1.9.0~20140119~7dc8c2f-1
* New snapshot release (Closes: #733714)
* Provide sources for javascript and flash. Done in orig-tar.sh
  Available in third_party/websockify/include/web-socket-js/src/
  (Closes: #735903)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
#include <string.h>
 
3
 
 
4
#define CONSTRLEN 32
 
5
 
 
6
char *(*func)(char *, const char *) = NULL;
 
7
 
 
8
void conoutfv(const char *fmt) {
 
9
  static char buf[CONSTRLEN];
 
10
  func(buf, fmt);  // call by function pointer to make sure we test strcpy here
 
11
  puts(buf);
 
12
}
 
13
 
 
14
struct XYZ {
 
15
  float x, y, z;
 
16
  XYZ(float a, float b, float c) : x(a), y(b), z(c) {}
 
17
  static const XYZ &getIdentity() {
 
18
    static XYZ iT(1, 2, 3);
 
19
    return iT;
 
20
  }
 
21
};
 
22
struct S {
 
23
  static const XYZ &getIdentity() {
 
24
    static const XYZ iT(XYZ::getIdentity());
 
25
    return iT;
 
26
  }
 
27
};
 
28
 
 
29
int main() {
 
30
  func = &strcpy;
 
31
  conoutfv("*staticccz*");
 
32
  printf("*%.2f,%.2f,%.2f*\n", S::getIdentity().x, S::getIdentity().y,
 
33
         S::getIdentity().z);
 
34
  return 0;
 
35
}