summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPat Pannuto <pat.pannuto@gmail.com>2013-04-17 18:42:28 -0400
committerPat Pannuto <pat.pannuto@gmail.com>2013-04-17 18:42:28 -0400
commit8725d196905bce3d1d15e5b8160968e1e346ebfe (patch)
treec7e4fcbbb983a0595a1e3c865991f80f9c55f2f3 /tests
parent9d6f717722f88ce4a57acd7c705802eb034b8d13 (diff)
parent690efaf0304427ab5ab023c67b27459beccc4b15 (diff)
downloadpygments-8725d196905bce3d1d15e5b8160968e1e346ebfe.tar.gz
Pull mainline changes and merge
Diffstat (limited to 'tests')
-rw-r--r--tests/examplefiles/example.ceylon39
-rw-r--r--tests/examplefiles/example.clay33
-rw-r--r--tests/examplefiles/example.stan161
3 files changed, 148 insertions, 85 deletions
diff --git a/tests/examplefiles/example.ceylon b/tests/examplefiles/example.ceylon
index b136b995..04223c56 100644
--- a/tests/examplefiles/example.ceylon
+++ b/tests/examplefiles/example.ceylon
@@ -1,33 +1,52 @@
+import ceylon.language { parseInteger }
+
doc "A top-level function,
with multi-line documentation."
-void topLevel(String? a, Integer b=5, String... seqs) {
+void topLevel(String? a, Integer b=5, String* seqs) {
function nested(String s) {
print(s[1..2]);
return true;
}
- for (s in seqs.filter((String x) x.size > 2)) {
+ for (s in seqs.filter((String x) => x.size > 2)) {
nested(s);
}
- value uppers = seqs.sequence[].uppercased;
- String|Nothing z = a;
- Sequence<Integer> ints = { 1, 2, 3, 4, 5 };
+ value uppers = seqs.map((String x) {
+ return x.uppercased;
+ });
+ String|Null z = a;
+ {Integer+} ints = { 1, 2, 3, 4, 5 };
+ value numbers = [ 1, #ffff, #ffff_ffff, $10101010, $1010_1010_1010_1010,
+ 123_456_789 ];
+ value chars = ['a', '\{#ffff}' ];
}
-shared class Example<Element>(name, element) satisfies Comparable<Example<Element>>
+shared class Example_1<Element>(name, element) satisfies Comparable<Example_1<Element>>
given Element satisfies Comparable<Element> {
shared String name;
shared Element element;
+ shared [Integer,String] tuple = [1, "2"];
+ shared late String lastName;
+ variable Integer cnt = 0;
+
+ shared Integer count => cnt;
+ assign count {
+ assert(count >= cnt);
+ cnt = count;
+ }
- shared actual Comparison compare(Example<Element> other) {
+ shared actual Comparison compare(Example_1<Element> other) {
return element <=> other.element;
}
shared actual String string {
- return "Example with " + element.string;
+ return "Example with ``element.string``";
}
}
-Example<Integer> instance = Example {
- name = "Named args call";
+Example_1<Integer> instance = Example_1 {
element = 5;
+ name = "Named args call \{#0060}";
};
+
+object example1 extends Example_1<Integer>("object", 5) {
+} \ No newline at end of file
diff --git a/tests/examplefiles/example.clay b/tests/examplefiles/example.clay
new file mode 100644
index 00000000..784752c6
--- /dev/null
+++ b/tests/examplefiles/example.clay
@@ -0,0 +1,33 @@
+
+/// @section StringLiteralRef
+
+record StringLiteralRef (
+ sizep : Pointer[SizeT],
+);
+
+
+/// @section predicates
+
+overload ContiguousSequence?(#StringLiteralRef) : Bool = true;
+[s when StringLiteral?(s)]
+overload ContiguousSequence?(#Static[s]) : Bool = true;
+
+
+
+/// @section size, begin, end, index
+
+forceinline overload size(a:StringLiteralRef) = a.sizep^;
+
+forceinline overload begin(a:StringLiteralRef) : Pointer[Char] = Pointer[Char](a.sizep + 1);
+forceinline overload end(a:StringLiteralRef) = begin(a) + size(a);
+
+[I when Integer?(I)]
+forceinline overload index(a:StringLiteralRef, i:I) : ByRef[Char] {
+ assert["boundsChecks"](i >= 0 and i < size(a), "StringLiteralRef index out of bounds");
+ return ref (begin(a) + i)^;
+}
+
+foo() = """
+long\tlong
+story
+"""
diff --git a/tests/examplefiles/example.stan b/tests/examplefiles/example.stan
index 5723403c..e936f54a 100644
--- a/tests/examplefiles/example.stan
+++ b/tests/examplefiles/example.stan
@@ -6,92 +6,103 @@ It is not a real model and will not compile
# also a comment
// also a comment
data {
- // valid name
- int abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_abc;
- // all types should be highlighed
- int a3;
- real foo[2];
- vector[3] bar;
- row_vector[3] baz;
- matrix[3,3] qux;
- simplex[3] quux;
- ordered[3] corge;
- positive_ordered[3] wibble;
- corr_matrix[3] grault;
- cov_matrix[3] garply;
-
- real<lower=-1,upper=1> foo1;
- real<lower=0> foo2;
- real<upper=0> foo3;
-
- // bad names
- // includes .
- // real foo.;
- // beings with number
- //real 0foo;
- // begins with _
- //real _foo;
+ // valid name
+ int abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_abc;
+ // all types should be highlighed
+ int a3;
+ real foo[2];
+ vector[3] bar;
+ row_vector[3] baz;
+ matrix[3,3] qux;
+ simplex[3] quux;
+ ordered[3] corge;
+ positive_ordered[3] wibble;
+ corr_matrix[3] grault;
+ cov_matrix[3] garply;
+
+ real<lower=-1,upper=1> foo1;
+ real<lower=0> foo2;
+ real<upper=0> foo3;
}
transformed data {
- real xyzzy;
- int thud;
- row_vector grault2;
- matrix qux2;
-
- // all floating point literals should be recognized
- // all operators should be recognized
- // paren should be recognized;
- xyzzy <- 1234.5687 + .123 - (2.7e3 / 2E-5 * 135e-5);
- // integer literal
- thud <- -12309865;
- // ./ and .* should be recognized as operators
- grault2 <- grault .* garply ./ garply;
- // ' and \ should be regognized as operators
- qux2 <- qux' \ bar;
-
+ real xyzzy;
+ int thud;
+ row_vector grault2;
+ matrix qux2;
+
+ // all floating point literals should be recognized
+ // all operators should be recognized
+ // paren should be recognized;
+ xyzzy <- 1234.5687 + .123 - (2.7e3 / 2E-5 * 135e-5);
+ // integer literal
+ thud <- -12309865;
+ // ./ and .* should be recognized as operators
+ grault2 <- grault .* garply ./ garply;
+ // ' and \ should be regognized as operators
+ qux2 <- qux' \ bar;
+
}
parameters {
- real fred;
- real plugh;
-
+ real fred;
+ real plugh;
}
transformed parameters {
}
model {
- // ~, <- are operators,
- // T may be be recognized
- // normal is a function
- fred ~ normal(0, 1) T(-0.5, 0.5);
- // interior block
- {
- real tmp;
- // for, in should be highlighted
- for (i in 1:10) {
- tmp <- tmp + 0.1;
- }
- }
- // lp__ should be highlighted
- // normal_log as a function
- lp__ <- lp__ + normal_log(plugh, 0, 1);
+ // ~, <- are operators,
+ // T may be be recognized
+ // normal is a function
+ fred ~ normal(0, 1) T(-0.5, 0.5);
+ real tmp;
+ // C++ reserved
+ real public;
+
+ // control structures
+ for (i in 1:10) {
+ tmp <- tmp + 0.1;
+ }
+ tmp <- 0.0;
+ while (tmp < 5.0) {
+ tmp <- tmp + 1;
+ }
+ if (tmp > 0.0) {
+ print(tmp);
+ } else {
+ print(tmp);
+ }
- // print statement and string literal
- print("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_~@#$%^&*`'-+={}[].,;: ");
- print("Hello, world!");
- print("");
+ // operators
+ tmp || tmp;
+ tmp && tmp;
+ tmp == tmp;
+ tmp != tmp;
+ tmp < tmp;
+ tmp <= tmp;
+ tmp > tmp;
+ tmp >= tmp;
+ tmp + tmp;
+ tmp - tmp;
+ tmp * tmp;
+ tmp / tmp;
+ tmp .* tmp;
+ tmp ./ tmp;
+ ! tmp;
+ - tmp;
+ + tmp;
+ tmp ';
+ // lp__ should be highlighted
+ // normal_log as a function
+ lp__ <- lp__ + normal_log(plugh, 0, 1);
+
+ // print statement and string literal
+ print("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_~@#$%^&*`'-+={}[].,;: ");
+ print("Hello, world!");
+ print("");
+
}
generated quantities {
- real bar1;
- bar1 <- foo + 1;
+ real bar1;
+ bar1 <- foo + 1;
}
-## Baddness
-//foo <- 2.0;
-//foo ~ normal(0, 1);
-//not_a_block {
-//}
-
-/*
-what happens with this?
-*/
-// */