org-mode/testing/examples/ob-C-test.org
Kévin Le Gouguec e9163591ae Add test case for symbol coercion in C Babel blocks
The ORG-NEWS entry for version 9.1 suggests that this coercion was
always intended, though AFAICT there was no test case for it.

* testing/lisp/test-ob-C.el (ob-C/symbol-include): Check explicitly
that :includes <iostream> (with no double-quotes around <iostream>)
will be parsed correctly.
(ob-D/simple-program, ob-C/integer-var, ob-D/integer-var,
ob-C/two-integer-var, ob-D/two-integer-var, ob-C/string-var,
ob-D/string-var, ob-C/preprocessor): Adjust block indices.

* testing/examples/ob-C-test.org (Simple tests): Add input for the new
test.
2020-05-28 22:32:31 -04:00

3.7 KiB

a collection of examples for ob-C tests

Simple tests

  std::cout << 42;
  return 0;
  std::cout << 42;
  return 0;
  writefln ("%s", 42);
  std::cout << q;
  return 0;
  writefln ("%s", q);
  std::cout << p+q;
  return 0;
  writefln ("%s", p+q);
  std::cout << q << ' ' << std::strlen(q);
  return 0;
  writefln ("%s %s", q, q.length);
  std::cout << N;
  return 0;

Array

  for (int i=1; i<3; i++) {
    std::cout << i << '\n';
  }
  return 0;
  foreach (i; 1..3)
    writefln ("%s", i);

Matrix

1 2
3 4
  std::cout << a[0] << a[1] << sizeof(a)/sizeof(*a) << '\n';
  writefln ("%s%s%s", a[0], a[1], a.length);
  std::cout << a[0] << a[1] << sizeof(a)/sizeof(*a) << '\n';
  writefln ("%s%s%s", a[0], a[1], a.length);
  std::cout << q[0][0] << ' ' << q[1][0] << '\n'
            << q[0][1] << ' ' << q[1][1] << '\n'; // transpose
  writefln ("%s %s", q[0][0], q[1][0]);
  writefln ("%s %s", q[0][1], q[1][1]); // transpose

Inhomogeneous table

day quty
monday 34
tuesday 41
wednesday 56
thursday 17
friday 12
saturday 7
sunday 4
int main()
{
  int i, j;
  for (i=0; i<tinomogen_rows; i++) {
    for (j=0; j<tinomogen_cols; j++)
      printf ("%s ", tinomogen[i][j]);
    printf ("\n");
  }
  printf ("Friday %s\n", tinomogen_h(4,"day"));
  return 0;
}
import std.stdio;
void main()
{
  for (int i=0; i<tinomogen_rows; i++) {
    for (int j=0; j<tinomogen_cols; j++)
      writef ("%s ", tinomogen[i][j]);
    writeln();
  }
  writefln ("Friday %s\n", tinomogen_h(4,"day"));
}