summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTim Hatch <tim@timhatch.com>2014-04-14 20:14:51 -0400
committerTim Hatch <tim@timhatch.com>2014-04-14 20:14:51 -0400
commitc75a752481251a0f2033a0db2466f293e73fa7e2 (patch)
tree2fd7271a0e92112cb2c3c7dc04773379bd72dd07 /tests
parent11226c63db8ed714bf233e34d44141a4ad3df934 (diff)
parentc852aa1e65a7175a4d62d321b9b18f70e4e6b93a (diff)
downloadpygments-c75a752481251a0f2033a0db2466f293e73fa7e2.tar.gz
Merged in ssproessig/pygments-main (pull request #266)
Diffstat (limited to 'tests')
-rw-r--r--tests/examplefiles/99_bottles_of_beer.chpl118
-rw-r--r--tests/examplefiles/Error.pmod38
-rw-r--r--tests/examplefiles/FakeFile.pike360
-rw-r--r--tests/examplefiles/antlr_ANTLRv3.g (renamed from tests/examplefiles/ANTLRv3.g)0
-rw-r--r--tests/examplefiles/core.cljs52
-rw-r--r--tests/examplefiles/demo.hbs12
-rw-r--r--tests/examplefiles/ember.handlebars33
-rw-r--r--tests/examplefiles/example.e124
-rw-r--r--tests/examplefiles/example.gd23
-rw-r--r--tests/examplefiles/example.gi64
-rw-r--r--tests/examplefiles/example.i6t32
-rw-r--r--tests/examplefiles/example.i7x45
-rw-r--r--tests/examplefiles/example.inf374
-rw-r--r--tests/examplefiles/example.kal75
-rw-r--r--tests/examplefiles/example.ma8
-rw-r--r--tests/examplefiles/example.mq4187
-rw-r--r--tests/examplefiles/example.mqh123
-rw-r--r--tests/examplefiles/example.ni57
-rw-r--r--tests/examplefiles/example.nix80
-rw-r--r--tests/examplefiles/example.stan2
-rw-r--r--tests/examplefiles/example.todotxt9
-rw-r--r--tests/examplefiles/exampleScript.cfc241
-rw-r--r--tests/examplefiles/exampleTag.cfc18
-rw-r--r--tests/examplefiles/example_elixir.ex4
-rw-r--r--tests/examplefiles/function_arrows.coffee11
-rw-r--r--tests/examplefiles/hash_syntax.rb5
-rw-r--r--tests/examplefiles/hello.at6
-rw-r--r--tests/examplefiles/hello.golo5
-rw-r--r--tests/examplefiles/hello.lsl12
-rw-r--r--tests/examplefiles/hybris_File.hy (renamed from tests/examplefiles/File.hy)0
-rw-r--r--tests/examplefiles/idl_sample.pro (renamed from tests/examplefiles/mg_sample.pro)0
-rw-r--r--tests/examplefiles/inet_pton6.dg48
-rw-r--r--tests/examplefiles/language.hy165
-rw-r--r--tests/examplefiles/limbo.b456
-rw-r--r--tests/examplefiles/livescript-demo.ls2
-rw-r--r--tests/examplefiles/objc_example.m3
-rw-r--r--tests/examplefiles/robotframework_test.txt (renamed from tests/examplefiles/robotframework.txt)0
-rw-r--r--tests/examplefiles/rql-queries.rql34
-rw-r--r--tests/examplefiles/scope.cirru43
-rw-r--r--tests/examplefiles/sparql.rq23
-rw-r--r--tests/examplefiles/test.R42
-rw-r--r--tests/examplefiles/test.apl26
-rw-r--r--tests/examplefiles/test.idr93
-rw-r--r--tests/examplefiles/test.mask41
-rw-r--r--tests/examplefiles/test.php4
-rw-r--r--tests/examplefiles/test.pig148
-rw-r--r--tests/examplefiles/test.pwn253
-rw-r--r--tests/examplefiles/test.zep33
-rw-r--r--tests/examplefiles/vbnet_test.bas (renamed from tests/examplefiles/test.bas)0
-rw-r--r--tests/examplefiles/vctreestatus_hg4
-rw-r--r--tests/old_run.py138
-rw-r--r--tests/run.py33
-rw-r--r--tests/test_basic_api.py42
-rw-r--r--tests/test_clexer.py2
-rw-r--r--tests/test_cmdline.py11
-rw-r--r--tests/test_examplefiles.py49
-rw-r--r--tests/test_html_formatter.py28
-rw-r--r--tests/test_latex_formatter.py6
-rw-r--r--tests/test_lexers_other.py4
-rw-r--r--tests/test_perllexer.py2
-rw-r--r--tests/test_regexlexer.py2
-rw-r--r--tests/test_token.py6
-rw-r--r--tests/test_using_api.py2
-rw-r--r--tests/test_util.py2
64 files changed, 3612 insertions, 251 deletions
diff --git a/tests/examplefiles/99_bottles_of_beer.chpl b/tests/examplefiles/99_bottles_of_beer.chpl
new file mode 100644
index 00000000..f73be7b1
--- /dev/null
+++ b/tests/examplefiles/99_bottles_of_beer.chpl
@@ -0,0 +1,118 @@
+/***********************************************************************
+ * Chapel implementation of "99 bottles of beer"
+ *
+ * by Brad Chamberlain and Steve Deitz
+ * 07/13/2006 in Knoxville airport while waiting for flight home from
+ * HPLS workshop
+ * compiles and runs with chpl compiler version 1.7.0
+ * for more information, contact: chapel_info@cray.com
+ *
+ *
+ * Notes:
+ * o as in all good parallel computations, boundary conditions
+ * constitute the vast bulk of complexity in this code (invite Brad to
+ * tell you about his zany boundary condition simplification scheme)
+ * o uses type inference for variables, arguments
+ * o relies on integer->string coercions
+ * o uses named argument passing (for documentation purposes only)
+ ***********************************************************************/
+
+// allow executable command-line specification of number of bottles
+// (e.g., ./a.out -snumBottles=999999)
+config const numBottles = 99;
+const numVerses = numBottles+1;
+
+// a domain to describe the space of lyrics
+var LyricsSpace: domain(1) = {1..numVerses};
+
+// array of lyrics
+var Lyrics: [LyricsSpace] string;
+
+// parallel computation of lyrics array
+[verse in LyricsSpace] Lyrics(verse) = computeLyric(verse);
+
+// as in any good parallel language, I/O to stdout is serialized.
+// (Note that I/O to a file could be parallelized using a parallel
+// prefix computation on the verse strings' lengths with file seeking)
+writeln(Lyrics);
+
+
+// HELPER FUNCTIONS:
+
+proc computeLyric(verseNum) {
+ var bottleNum = numBottles - (verseNum - 1);
+ var nextBottle = (bottleNum + numVerses - 1)%numVerses;
+ return "\n" // disguise space used to separate elements in array I/O
+ + describeBottles(bottleNum, startOfVerse=true) + " on the wall, "
+ + describeBottles(bottleNum) + ".\n"
+ + computeAction(bottleNum)
+ + describeBottles(nextBottle) + " on the wall.\n";
+}
+
+
+proc describeBottles(bottleNum, startOfVerse:bool = false) {
+ // NOTE: bool should not be necessary here (^^^^); working around bug
+ var bottleDescription = if (bottleNum) then bottleNum:string
+ else (if startOfVerse then "N"
+ else "n")
+ + "o more";
+ return bottleDescription
+ + " bottle" + (if (bottleNum == 1) then "" else "s")
+ + " of beer";
+}
+
+
+proc computeAction(bottleNum) {
+ return if (bottleNum == 0) then "Go to the store and buy some more, "
+ else "Take one down and pass it around, ";
+}
+
+
+// Modules...
+module M1 {
+ var x = 10;
+}
+
+module M2 {
+ use M1;
+ proc main() {
+ writeln("M2 -> M1 -> x " + x);
+ }
+}
+
+
+// Classes, records, unions...
+const PI: real = 3.14159;
+
+record Point {
+ var x, y: real;
+}
+var p: Point;
+writeln("Distance from origin: " + sqrt(p.x ** 2 + p.y ** 2));
+p = new Point(1.0, 2.0);
+writeln("Distance from origin: " + sqrt(p.x ** 2 + p.y ** 2));
+
+class Circle {
+ var p: Point;
+ var r: real;
+}
+var c = new Circle(r=2.0);
+proc Circle.area()
+ return PI * r ** 2;
+writeln("Area of circle: " + c.area());
+
+class Oval: Circle {
+ var r2: real;
+}
+proc Oval.area()
+ return PI * r * r2;
+
+delete c;
+c = nil;
+c = new Oval(r=1.0, r2=2.0);
+writeln("Area of oval: " + c.area());
+
+union U {
+ var i: int;
+ var r: real;
+}
diff --git a/tests/examplefiles/Error.pmod b/tests/examplefiles/Error.pmod
new file mode 100644
index 00000000..808ecb0e
--- /dev/null
+++ b/tests/examplefiles/Error.pmod
@@ -0,0 +1,38 @@
+#pike __REAL_VERSION__
+
+constant Generic = __builtin.GenericError;
+
+constant Index = __builtin.IndexError;
+
+constant BadArgument = __builtin.BadArgumentError;
+
+constant Math = __builtin.MathError;
+
+constant Resource = __builtin.ResourceError;
+
+constant Permission = __builtin.PermissionError;
+
+constant Decode = __builtin.DecodeError;
+
+constant Cpp = __builtin.CppError;
+
+constant Compilation = __builtin.CompilationError;
+
+constant MasterLoad = __builtin.MasterLoadError;
+
+constant ModuleLoad = __builtin.ModuleLoadError;
+
+//! Returns an Error object for any argument it receives. If the
+//! argument already is an Error object or is empty, it does nothing.
+object mkerror(mixed error)
+{
+ if (error == UNDEFINED)
+ return error;
+ if (objectp(error) && error->is_generic_error)
+ return error;
+ if (arrayp(error))
+ return Error.Generic(@error);
+ if (stringp(error))
+ return Error.Generic(error);
+ return Error.Generic(sprintf("%O", error));
+} \ No newline at end of file
diff --git a/tests/examplefiles/FakeFile.pike b/tests/examplefiles/FakeFile.pike
new file mode 100644
index 00000000..48f3ea64
--- /dev/null
+++ b/tests/examplefiles/FakeFile.pike
@@ -0,0 +1,360 @@
+#pike __REAL_VERSION__
+
+//! A string wrapper that pretends to be a @[Stdio.File] object
+//! in addition to some features of a @[Stdio.FILE] object.
+
+
+//! This constant can be used to distinguish a FakeFile object
+//! from a real @[Stdio.File] object.
+constant is_fake_file = 1;
+
+protected string data;
+protected int ptr;
+protected int(0..1) r;
+protected int(0..1) w;
+protected int mtime;
+
+protected function read_cb;
+protected function read_oob_cb;
+protected function write_cb;
+protected function write_oob_cb;
+protected function close_cb;
+
+//! @seealso
+//! @[Stdio.File()->close()]
+int close(void|string direction) {
+ direction = lower_case(direction||"rw");
+ int cr = has_value(direction, "r");
+ int cw = has_value(direction, "w");
+
+ if(cr) {
+ r = 0;
+ }
+
+ if(cw) {
+ w = 0;
+ }
+
+ // FIXME: Close callback
+ return 1;
+}
+
+//! @decl void create(string data, void|string type, void|int pointer)
+//! @seealso
+//! @[Stdio.File()->create()]
+void create(string _data, void|string type, int|void _ptr) {
+ if(!_data) error("No data string given to FakeFile.\n");
+ data = _data;
+ ptr = _ptr;
+ mtime = time();
+ if(type) {
+ type = lower_case(type);
+ if(has_value(type, "r"))
+ r = 1;
+ if(has_value(type, "w"))
+ w = 1;
+ }
+ else
+ r = w = 1;
+}
+
+protected string make_type_str() {
+ string type = "";
+ if(r) type += "r";
+ if(w) type += "w";
+ return type;
+}
+
+//! @seealso
+//! @[Stdio.File()->dup()]
+this_program dup() {
+ return this_program(data, make_type_str(), ptr);
+}
+
+//! Always returns 0.
+//! @seealso
+//! @[Stdio.File()->errno()]
+int errno() { return 0; }
+
+//! Returns size and the creation time of the string.
+Stdio.Stat stat() {
+ Stdio.Stat st = Stdio.Stat();
+ st->size = sizeof(data);
+ st->mtime=st->ctime=mtime;
+ st->atime=time();
+ return st;
+}
+
+//! @seealso
+//! @[Stdio.File()->line_iterator()]
+String.SplitIterator line_iterator(int|void trim) {
+ if(trim)
+ return String.SplitIterator( data-"\r", '\n' );
+ return String.SplitIterator( data, '\n' );
+}
+
+protected mixed id;
+
+//! @seealso
+//! @[Stdio.File()->query_id()]
+mixed query_id() { return id; }
+
+//! @seealso
+//! @[Stdio.File()->set_id()]
+void set_id(mixed _id) { id = _id; }
+
+//! @seealso
+//! @[Stdio.File()->read_function()]
+function(:string) read_function(int nbytes) {
+ return lambda() { return read(nbytes); };
+}
+
+//! @seealso
+//! @[Stdio.File()->peek()]
+int(-1..1) peek(int|float|void timeout) {
+ if(!r) return -1;
+ if(ptr >= sizeof(data)) return 0;
+ return 1;
+}
+
+//! Always returns 0.
+//! @seealso
+//! @[Stdio.File()->query_address()]
+string query_address(void|int(0..1) is_local) { return 0; }
+
+//! @seealso
+//! @[Stdio.File()->read()]
+string read(void|int(0..) len, void|int(0..1) not_all) {
+ if(!r) return 0;
+ if (len < 0) error("Cannot read negative number of characters.\n");
+ int start=ptr;
+ ptr += len;
+ if(zero_type(len) || ptr>sizeof(data))
+ ptr = sizeof(data);
+
+ // FIXME: read callback
+ return data[start..ptr-1];
+}
+
+//! @seealso
+//! @[Stdio.FILE()->gets()]
+string gets() {
+ if(!r) return 0;
+ string ret;
+ sscanf(data,"%*"+(string)ptr+"s%[^\n]",ret);
+ if(ret)
+ {
+ ptr+=sizeof(ret)+1;
+ if(ptr>sizeof(data))
+ {
+ ptr=sizeof(data);
+ if(!sizeof(ret))
+ ret = 0;
+ }
+ }
+
+ // FIXME: read callback
+ return ret;
+}
+
+//! @seealso
+//! @[Stdio.FILE()->getchar()]
+int getchar() {
+ if(!r) return 0;
+ int c;
+ if(catch(c=data[ptr]))
+ c=-1;
+ else
+ ptr++;
+
+ // FIXME: read callback
+ return c;
+}
+
+//! @seealso
+//! @[Stdio.FILE()->unread()]
+void unread(string s) {
+ if(!r) return;
+ if(data[ptr-sizeof(s)..ptr-1]==s)
+ ptr-=sizeof(s);
+ else
+ {
+ data=s+data[ptr..];
+ ptr=0;
+ }
+}
+
+//! @seealso
+//! @[Stdio.File()->seek()]
+int seek(int pos, void|int mult, void|int add) {
+ if(mult)
+ pos = pos*mult+add;
+ if(pos<0)
+ {
+ pos = sizeof(data)+pos;
+ if( pos < 0 )
+ pos = 0;
+ }
+ ptr = pos;
+ if( ptr > strlen( data ) )
+ ptr = strlen(data);
+ return ptr;
+}
+
+//! Always returns 1.
+//! @seealso
+//! @[Stdio.File()->sync()]
+int(1..1) sync() { return 1; }
+
+//! @seealso
+//! @[Stdio.File()->tell()]
+int tell() { return ptr; }
+
+//! @seealso
+//! @[Stdio.File()->truncate()]
+int(0..1) truncate(int length) {
+ data = data[..length-1];
+ return sizeof(data)==length;
+}
+
+//! @seealso
+//! @[Stdio.File()->write()]
+int(-1..) write(string|array(string) str, mixed ... extra) {
+ if(!w) return -1;
+ if(arrayp(str)) str=str*"";
+ if(sizeof(extra)) str=sprintf(str, @extra);
+
+ if(ptr==sizeof(data)) {
+ data += str;
+ ptr = sizeof(data);
+ }
+ else if(sizeof(str)==1)
+ data[ptr++] = str[0];
+ else {
+ data = data[..ptr-1] + str + data[ptr+sizeof(str)..];
+ ptr += sizeof(str);
+ }
+
+ // FIXME: write callback
+ return sizeof(str);
+}
+
+//! @seealso
+//! @[Stdio.File()->set_blocking]
+void set_blocking() {
+ close_cb = 0;
+ read_cb = 0;
+ read_oob_cb = 0;
+ write_cb = 0;
+ write_oob_cb = 0;
+}
+
+//! @seealso
+//! @[Stdio.File()->set_blocking_keep_callbacks]
+void set_blocking_keep_callbacks() { }
+
+//! @seealso
+//! @[Stdio.File()->set_blocking]
+void set_nonblocking(function rcb, function wcb, function ccb,
+ function rocb, function wocb) {
+ read_cb = rcb;
+ write_cb = wcb;
+ close_cb = ccb;
+ read_oob_cb = rocb;
+ write_oob_cb = wocb;
+}
+
+//! @seealso
+//! @[Stdio.File()->set_blocking_keep_callbacks]
+void set_nonblocking_keep_callbacks() { }
+
+
+//! @seealso
+//! @[Stdio.File()->set_close_callback]
+void set_close_callback(function cb) { close_cb = cb; }
+
+//! @seealso
+//! @[Stdio.File()->set_read_callback]
+void set_read_callback(function cb) { read_cb = cb; }
+
+//! @seealso
+//! @[Stdio.File()->set_read_oob_callback]
+void set_read_oob_callback(function cb) { read_oob_cb = cb; }
+
+//! @seealso
+//! @[Stdio.File()->set_write_callback]
+void set_write_callback(function cb) { write_cb = cb; }
+
+//! @seealso
+//! @[Stdio.File()->set_write_oob_callback]
+void set_write_oob_callback(function cb) { write_oob_cb = cb; }
+
+
+//! @seealso
+//! @[Stdio.File()->query_close_callback]
+function query_close_callback() { return close_cb; }
+
+//! @seealso
+//! @[Stdio.File()->query_read_callback]
+function query_read_callback() { return read_cb; }
+
+//! @seealso
+//! @[Stdio.File()->query_read_oob_callback]
+function query_read_oob_callback() { return read_oob_cb; }
+
+//! @seealso
+//! @[Stdio.File()->query_write_callback]
+function query_write_callback() { return write_cb; }
+
+//! @seealso
+//! @[Stdio.File()->query_write_oob_callback]
+function query_write_oob_callback() { return write_oob_cb; }
+
+string _sprintf(int t) {
+ return t=='O' && sprintf("%O(%d,%O)", this_program, sizeof(data),
+ make_type_str());
+}
+
+
+// FakeFile specials.
+
+//! A FakeFile can be casted to a string.
+mixed cast(string to) {
+ switch(to) {
+ case "string": return data;
+ case "object": return this;
+ }
+ error("Can not cast object to %O.\n", to);
+}
+
+//! Sizeof on a FakeFile returns the size of its contents.
+int(0..) _sizeof() {
+ return sizeof(data);
+}
+
+//! @ignore
+
+#define NOPE(X) mixed X (mixed ... args) { error("This is a FakeFile. %s is not available.\n", #X); }
+NOPE(assign);
+NOPE(async_connect);
+NOPE(connect);
+NOPE(connect_unix);
+NOPE(open);
+NOPE(open_socket);
+NOPE(pipe);
+NOPE(tcgetattr);
+NOPE(tcsetattr);
+
+// Stdio.Fd
+NOPE(dup2);
+NOPE(lock); // We could implement this
+NOPE(mode); // We could implement this
+NOPE(proxy); // We could implement this
+NOPE(query_fd);
+NOPE(read_oob);
+NOPE(set_close_on_exec);
+NOPE(set_keepalive);
+NOPE(trylock); // We could implement this
+NOPE(write_oob);
+
+//! @endignore \ No newline at end of file
diff --git a/tests/examplefiles/ANTLRv3.g b/tests/examplefiles/antlr_ANTLRv3.g
index fbe6d654..fbe6d654 100644
--- a/tests/examplefiles/ANTLRv3.g
+++ b/tests/examplefiles/antlr_ANTLRv3.g
diff --git a/tests/examplefiles/core.cljs b/tests/examplefiles/core.cljs
new file mode 100644
index 00000000..f135b832
--- /dev/null
+++ b/tests/examplefiles/core.cljs
@@ -0,0 +1,52 @@
+
+(ns bounder.core
+ (:require [bounder.html :as html]
+ [domina :refer [value set-value! single-node]]
+ [domina.css :refer [sel]]
+ [lowline.functions :refer [debounce]]
+ [enfocus.core :refer [at]]
+ [cljs.reader :as reader]
+ [clojure.string :as s])
+ (:require-macros [enfocus.macros :as em]))
+
+(def filter-input
+ (single-node
+ (sel ".search input")))
+
+(defn project-matches [query project]
+ (let [words (cons (:name project)
+ (map name (:categories project)))
+ to-match (->> words
+ (s/join "")
+ (s/lower-case))]
+ (<= 0 (.indexOf to-match (s/lower-case query)))))
+
+(defn apply-filter-for [projects]
+ (let [query (value filter-input)]
+ (html/render-projects
+ (filter (partial project-matches query)
+ projects))))
+
+(defn filter-category [projects evt]
+ (let [target (.-currentTarget evt)]
+ (set-value! filter-input
+ (.-innerHTML target))
+ (apply-filter-for projects)))
+
+(defn init-listeners [projects]
+ (at js/document
+ ["input"] (em/listen
+ :keyup
+ (debounce
+ (partial apply-filter-for projects)
+ 500))
+ [".category-links li"] (em/listen
+ :click
+ (partial filter-category projects))))
+
+(defn init [projects-edn]
+ (let [projects (reader/read-string projects-edn)]
+ (init-listeners projects)
+ (html/render-projects projects)
+ (html/loaded)))
+
diff --git a/tests/examplefiles/demo.hbs b/tests/examplefiles/demo.hbs
new file mode 100644
index 00000000..1b9ed5a7
--- /dev/null
+++ b/tests/examplefiles/demo.hbs
@@ -0,0 +1,12 @@
+<!-- post.handlebars -->
+
+<div class='intro'>
+ {{intro}}
+</div>
+
+{{#if isExpanded}}
+ <div class='body'>{{body}}</div>
+ <button {{action contract}}>Contract</button>
+{{else}}
+ <button {{action expand}}>Show More...</button>
+{{/if}}
diff --git a/tests/examplefiles/ember.handlebars b/tests/examplefiles/ember.handlebars
new file mode 100644
index 00000000..515dffbd
--- /dev/null
+++ b/tests/examplefiles/ember.handlebars
@@ -0,0 +1,33 @@
+{{#view EmberFirebaseChat.ChatView class="chat-container"}}
+ <div class="chat-messages-container">
+ <ul class="chat-messages">
+ {{#each message in content}}
+ <li>
+ [{{formatTimestamp "message.timestamp" fmtString="h:mm:ss A"}}]
+ <strong>{{message.sender}}</strong>: {{message.content}}
+ </li>
+ {{/each}}
+ </ul>
+ </div>
+
+ {{! Comment }}
+ {{{unescaped value}}}
+
+ {{#view EmberFirebaseChat.InputView class="chat-input-container"}}
+ <form class="form-inline">
+ {{#if "auth.authed"}}
+ {{#if "auth.hasName"}}
+ <input type="text" id="message" placeholder="Message">
+ <button {{action "postMessage" target="view"}} class="btn">Send</button>
+ {{else}}
+ <input type="text" id="username" placeholder="Enter your username...">
+ <button {{action "pickName" target="view"}} class="btn">Send</button>
+ {{/if}}
+ {{else}}
+ <input type="text" placeholder="Log in with Persona to chat!" disabled="disabled">
+ <button {{action "login"}} class="btn">Login</button>
+ {{/if}}
+ </form>
+ {{/view}}
+{{/view}}
+
diff --git a/tests/examplefiles/example.e b/tests/examplefiles/example.e
new file mode 100644
index 00000000..2e43954b
--- /dev/null
+++ b/tests/examplefiles/example.e
@@ -0,0 +1,124 @@
+note
+ description : "[
+ This is use to have almost every language element."
+
+ That way, I can correctly test the lexer. %]"
+
+ Don't try to understand what it does. It's not even compilling.
+ ]"
+ date : "August 6, 2013"
+ revision : "0.1"
+
+class
+ SAMPLE
+
+inherit
+ ARGUMENTS
+ rename
+ Command_line as Caller_command,
+ command_name as Application_name
+ undefine
+ out
+ end
+ ANY
+ export
+ {ANY} out
+ redefine
+ out
+ end
+
+
+
+create
+ make
+
+convert
+ as_boolean: {BOOLEAN}
+
+feature {NONE} -- Initialization
+
+ make
+ -- Run application.
+ local
+ i1_:expanded INTEGER
+ f_1:REAL_64
+ l_char:CHARACTER_8
+ do
+ l_char:='!'
+ l_char:='%''
+ l_char:='%%'
+ i1_:=80 - 0x2F0C // 0C70 \\ 0b10110 * 1;
+ f_1:=0.1 / .567
+ f_1:=34.
+ f_1:=12345.67890
+ inspect i1_
+ when 1 then
+ io.output.put_integer (i1_) -- Comment
+ else
+ io.output.put_real (f_1.truncated_to_real)
+ end
+ io.output.put_string (CuRrEnt.out) -- Comment
+ (agent funct_1).call([1,2,"Coucou"])
+ end
+
+feature -- Access
+
+ funct_1(x,y:separate INTEGER;a_text:READABLE_STRING_GENERAL):detachable BOOLEAN
+ obsolete "This function is obsolete"
+ require
+ Is_Attached: AttAched a_text
+ local
+ l_list:LIST[like x]
+ do
+ if (NOT a_text.is_empty=TrUe or elSe ((x<0 aNd x>10) oR (y>0 and then y<10))) xor True thEn
+ ResuLT := FalSe
+ elseif (acROss l_list as la_list SoMe la_list.item<0 end) implies a_text.is_boolean then
+ ResuLT := FalSe
+ else
+ Result := TruE
+ eND
+ from
+ l_list.start
+ until
+ l_list.exhausted
+ loop
+ l_list.forth
+ variant
+ l_list.count - l_list.index
+ end
+ check Current /= Void end
+ debug print("%"Here%"%N") end
+ ensure
+ Is_Cool_Not_Change: is_cool = old is_cool
+ end
+
+ is_cool:BOOLEAN
+ attribute
+ Result:=False
+ end
+
+ froZen c_malloc: POINTER is
+ exTErnal
+ "C inline use <stdlib.h>"
+ alIAs
+ "malloc (1)"
+ end
+
+ as_boolean:BOOLEAN
+ do
+ Result:=True
+ rescue
+ retry
+ end
+
+feature {ANY} -- The redefine feature
+
+ out:STRING_8
+ once
+ reSUlt:=PrecursOr {ANY}
+ Result := "Hello Worl"+('d').out
+ end
+
+invariant
+ Always_Cool: is_cool
+end
diff --git a/tests/examplefiles/example.gd b/tests/examplefiles/example.gd
new file mode 100644
index 00000000..c285ea32
--- /dev/null
+++ b/tests/examplefiles/example.gd
@@ -0,0 +1,23 @@
+#############################################################################
+##
+#W example.gd
+##
+## This file contains a sample of a GAP declaration file.
+##
+DeclareProperty( "SomeProperty", IsLeftModule );
+DeclareGlobalFunction( "SomeGlobalFunction" );
+
+
+#############################################################################
+##
+#C IsQuuxFrobnicator(<R>)
+##
+## <ManSection>
+## <Filt Name="IsQuuxFrobnicator" Arg='R' Type='Category'/>
+##
+## <Description>
+## Tests whether R is a quux frobnicator.
+## </Description>
+## </ManSection>
+##
+DeclareSynonym( "IsQuuxFrobnicator", IsField and IsGroup );
diff --git a/tests/examplefiles/example.gi b/tests/examplefiles/example.gi
new file mode 100644
index 00000000..c9c5e55d
--- /dev/null
+++ b/tests/examplefiles/example.gi
@@ -0,0 +1,64 @@
+#############################################################################
+##
+#W example.gd
+##
+## This file contains a sample of a GAP implementation file.
+##
+
+
+#############################################################################
+##
+#M SomeOperation( <val> )
+##
+## performs some operation on <val>
+##
+InstallMethod( SomeProperty,
+ "for left modules",
+ [ IsLeftModule ], 0,
+ function( M )
+ if IsFreeLeftModule( M ) and not IsTrivial( M ) then
+ return true;
+ fi;
+ TryNextMethod();
+ end );
+
+
+
+#############################################################################
+##
+#F SomeGlobalFunction( )
+##
+## A global variadic funfion.
+##
+InstallGlobalFunction( SomeGlobalFunction, function( arg )
+ if Length( arg ) = 3 then
+ return arg[1] + arg[2] * arg[3];
+ elif Length( arg ) = 2 then
+ return arg[1] - arg[2]
+ else
+ Error( "usage: SomeGlobalFunction( <x>, <y>[, <z>] )" );
+ fi;
+ end );
+
+
+#
+# A plain function.
+#
+SomeFunc := function(x, y)
+ local z, func, tmp, j;
+ z := x * 1.0;
+ y := 17^17 - y;
+ func := a -> a mod 5;
+ tmp := List( [1..50], func );
+ while y > 0 do
+ for j in tmp do
+ Print(j, "\n");
+ od;
+ repeat
+ y := y - 1;
+ until 0 < 1;
+ y := y -1;
+ od;
+ return z;
+end;
+ \ No newline at end of file
diff --git a/tests/examplefiles/example.i6t b/tests/examplefiles/example.i6t
new file mode 100644
index 00000000..0f41b425
--- /dev/null
+++ b/tests/examplefiles/example.i6t
@@ -0,0 +1,32 @@
+B/examt: Example Template.
+
+@Purpose: To show the syntax of I6T, specifically the parts relating to the
+inclusion of I7 and at signs in the first column.
+
+@-------------------------------------------------------------------------------
+
+@p Lines.
+
+@c
+{-lines:type}
+! This is a comment.
+{-endlines}
+
+@-This line begins with @-, so it is ignored.
+
+@p Paragraph.
+This is a paragraph.
+@p Another paragraph.
+So
+
+is
+
+this.
+
+@Purpose: This purpose line is ignored.
+
+@c At signs and (+ +).
+[ Foo i;
+print (+score [an I7 value]+), "^";
+@add sp 1 -> i; ! Assembly works even in the first column.
+];
diff --git a/tests/examplefiles/example.i7x b/tests/examplefiles/example.i7x
new file mode 100644
index 00000000..ab94ac69
--- /dev/null
+++ b/tests/examplefiles/example.i7x
@@ -0,0 +1,45 @@
+example by David Corbett begins here.
+
+"Implements testable examples."
+
+An example is a kind of thing. An example can be tested. An example is seldom tested.
+
+example ends here.
+
+----
+[The] documentation [starts here.]
+----
+
+This extension adds examples, which may be tested.
+
+Chapter: Usage
+
+To add an example to the story, we write:
+
+ The foobar is an example.
+
+To interact with it in Inform 6, we write something like:
+
+ To say (E - example): (-
+ print (object) {E};
+ -).
+ [The IDE's documentation viewer does not display the closing -). I don't know how to fix that.]
+
+Section: Testing
+
+We can make an example be tested using:
+
+ now the foobar is tested;
+
+Example: * Exempli Gratia - A simple example.
+
+ *: "Exempli Gratia"
+
+ Include example by David Corbett.
+
+ The Kitchen is a room. The egg is an example, here.
+
+ Before dropping the egg:
+ now the egg is tested.
+
+ Test me with "get egg / drop egg".
diff --git a/tests/examplefiles/example.inf b/tests/examplefiles/example.inf
new file mode 100644
index 00000000..73cdd087
--- /dev/null
+++ b/tests/examplefiles/example.inf
@@ -0,0 +1,374 @@
+!% $SMALL ! This is ICL, not a comment.
+!% -w
+
+!% A comprehensive test of Inform6Lexer.
+
+Switches d2SDq;
+
+Constant Story "Informal Testing";
+Constant Headline "^Not a game.^";!% This is a comment, not ICL.
+
+Release 2;
+Serial "140308";
+Version 5;
+
+Ifndef TARGET_ZCODE;
+Ifndef TARGET_GLULX;
+Ifndef WORDSIZE;
+Default WORDSIZE 2;
+Constant TARGET_ZCODE;
+Endif;
+Endif;
+Endif;
+
+Ifv3; Message "Compiling to version 3"; Endif;
+Ifv5; Message "Not compiling to version 3"; endif;
+ifdef TARGET_ZCODE;
+#IFTRUE (#version_number == 5);
+Message "Compiling to version 5";
+#ENDIF;
+endif ;
+
+Replace CreatureTest;
+
+Include "Parser";
+Include "VerbLib";
+
+# ! A hash is optional at the top level.
+Object kitchen "Kitchen"
+ with description "You are in a kitchen.",
+ arr 1 2 3 4,
+ has light;
+
+#[ Initialise;
+ location = kitchen;
+ print "v"; inversion; "^";
+];
+
+Ifdef VN_1633;
+Replace IsSeeThrough IsSeeThroughOrig;
+[ IsSeeThrough * o;
+ return o hasnt opaque || IsSeeThroughOrig(o);
+];
+Endif;
+
+Abbreviate "test";
+
+Array table buffer 260;
+
+Attribute reversed;
+Attribute opaque alias locked;
+Constant to reversed;
+
+Property long additive additive long alias;
+Property long long long wingspan alias alias;
+
+Class Flier with wingspan 5;
+Class Bird(10) has animate class Flier with wingspan 2;
+
+Constant Constant1;
+Constant Constant2 Constant1;
+Constant Constant3 = Constant2;
+Ifdef VN_1633; Undef Constant; Endif;
+
+Ifdef VN_1633;
+Dictionary 'word' 1 2;
+Ifnot;
+Dictionary dict_word "word";
+Endif;
+
+Fake_action NotReal;
+
+Global global1;
+Global global2 = 69105;
+
+Lowstring low_string "low string";
+
+Iftrue false;
+Message error "Uh-oh!^~false~ shouldn't be ~true~.";
+Endif;
+Iffalse true;
+Message fatalerror "Uh-oh!^~true~ shouldn't be ~false~.";
+Endif;
+
+Nearby person "person"
+ with name 'person',
+ description "This person is barely implemented.",
+ life [ * x y z;
+ Ask: print_ret (The) self, " says nothing.";
+ Answer: print (The) self, " didn't say anything.^"; rfalse;
+ ]
+ has has animate transparent;
+
+Object -> -> test_tube "test tube"
+ with name 'test' "tube" 'testtube',
+ has ~openable ~opaque container;
+
+Bird -> pigeon
+ with name 'pigeon',
+ description [;
+ "The pigeon has a wingspan of ", self.&wingspan-->0, " wing units.";
+ ];
+
+Object -> "thimble" with name 'thimble';
+
+Object -> pebble "pebble" with name 'pebble';
+
+Ifdef TARGET_ZCODE; Trace objects; Endif;
+
+Statusline score;
+
+Stub StubR 3;
+
+Ifdef TARGET_ZCODE;
+Zcharacter "abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "123456789.,!?_#'0/@{005C}-:()";
+Zcharacter table '@!!' '@<<' '@'A';
+Zcharacter table + '@AE' '@{dc}' '@et' '@:y';
+Ifnot;
+Ifdef TARGET_GLULX;
+Message "Glulx doesn't use ~Zcharacter~.^Oh well."; ! '~' and '^' work here.
+Ifnot;
+Message warning "Uh-oh! ^~^"; ! They don't work in other Messages.
+Endif;
+Endif;
+
+Include "Grammar";
+
+Verb"acquire"'collect'='take';
+
+[ NounFilter; return noun ofclass Bird; ];
+
+[ ScopeFilter obj;
+ switch (scope_stage) {
+ 1: rtrue;
+ 2: objectloop (obj in compass) PlaceInScope(obj);
+ 3: "Nothing is in scope.";
+ }
+];
+
+Verb meta "t" 'test'
+ * 'held' held -> TestHeld
+ * number -> TestNumber
+ * reversed -> TestAttribute
+ * 'creature' creature -> TestCreature
+ * 'multiheld' multiheld -> TestMultiheld
+ * 'm' multiexcept 'into'/"in" noun -> TestMultiexcept
+ * 'm' multiinside 'from' noun -> TestMultiinside
+ * multi -> TestMulti
+ * 'filter'/'f' noun=NounFilter -> TestNounFilter
+ * 'filter'/'f' scope=ScopeFilter -> TestScopeFilter
+ * 'special' special -> TestSpecial
+ * topic -> TestTopic;
+
+Verb 'reverse' 'swap' 'exchange'
+ * held 'for' noun -> reverse
+ * noun 'with' noun -> reverse reverse;
+
+Extend "t" last * noun -> TestNoun;
+
+Extend 't' first * -> Test;
+
+Extend 'wave' replace * -> NewWave;
+
+Extend only 'feel' 'touch' replace * noun -> Feel;
+
+[ TestSub a b o;
+ string 25 low_string;
+ print "Test what?> ";
+ table->0 = 260;
+ parse->0 = 61;
+ #Ifdef TARGET_ZCODE;
+ read buffer parse;
+ #Ifnot; ! TARGET_GLULX
+ KeyboardPrimitive(buffer, parse);
+ #Endif; ! TARGET_
+ switch (parse-->1) {
+ 'save':
+ #Ifdef TARGET_ZCODE;
+ #Ifv3;
+ @save ?saved;
+ #Ifnot;
+ save saved;
+ #Endif;
+ #Endif;
+ print "Saving failed.^";
+ 'restore':
+ #Ifdef TARGET_ZCODE;
+ restore saved;
+ #Endif;
+ print "Restoring failed.^";
+ 'restart':
+ @restart;
+ 'quit', 'q//':
+ quit;
+ return 2; rtrue; rfalse; return;
+ 'print', 'p//':
+ print "Print:^",
+ " (string): ", (string) "xyzzy^",
+ " (number): ", (number) 123, "^",
+ " (char): ", (char) 'x', "^",
+ " (address): ", (address) 'plugh//p', "^",
+ " (The): ", (The) person, "^",
+ " (the): ", (the) person, "^",
+ " (A): ", (A) person, "^",
+ " (a): ", (a) person, "^",
+ " (an): ", (an) person, "^",
+ " (name): ", (name) person, "^",
+ " (object): ", (object) person, "^",
+ " (property): ", (property) alias, "^",
+ " (<routine>): ", (LanguageNumber) 123, "^",
+ " <expression>: ", a * 2 - 1, "^",
+ " (<expression>): ", (a + person), "^";
+ print "Escapes:^",
+ " by mnemonic: @!! @<< @'A @AE @et @:y^",
+ " by decimal value: @@64 @@126^",
+ " by Unicode value: @{DC}@{002b}^",
+ " by string variable: @25^";
+ 'font', 'style':
+ font off; print "font off^";
+ font on; print "font on^";
+ style reverse; print "style reverse^"; style roman;
+ style bold; print "style bold^";
+ style underline; print "style underline^";
+ style fixed; print "style fixed^";
+ style roman; print "style roman^";
+ 'statements':
+ spaces 8;
+ objectloop (o) {
+ print "objectloop (o): ", (the) o, "^";
+ }
+ objectloop (o in compass) { ! 'in' is a keyword
+ print "objectloop (o in compass): ", (the) o, "^";
+ }
+ objectloop (o in compass && true) { ! 'in' is an operator
+ print "objectloop (o in compass && true): ", (the) o, "^";
+ }
+ objectloop (o from se_obj) {
+ print "objectloop (o from se_obj): ", (the) o, "^";
+ }
+ objectloop (o near person) {
+ print "objectloop (o near person): ", (the) o, "^";
+ }
+ #Ifdef TARGET_ZCODE;
+ #Trace assembly on;
+@ ! This is assembly.
+ add -4 ($$1+$3)*2 -> b;
+ @get_sibling test_tube -> b ?saved;
+ @inc [b];
+ @je sp (1+3*0) ? equal;
+ @je 1 ((sp)) ?~ different;
+ .! This is a label:
+ equal;
+ print "sp == 1^";
+ jump label;
+ .different;
+ print "sp @@126= 1^";
+ .label;
+ #Trace off; #Endif; ! TARGET_ZCODE
+ a = random(10);
+ switch (a) {
+ 1, 9:
+ box "Testing oneself is best when done alone."
+ " -- Jimmy Carter";
+ 2, 6, to, 3 to 5, to to to:
+ <Take pigeon>;
+ #Ifdef VN_1633;
+ <Jump, person>;
+ #Endif;
+ a = ##Drop;
+ < ! The angle brackets may be separated by whitespace.
+ < (a) pigeon > >;
+ default:
+ do {
+ give person general ~general;
+ } until (person provides life && ~~false);
+ if (a == 7) a = 4;
+ else a = 5;
+ }
+ 'expressions':
+ a = 1+1-1*1/1%1&1|1&&1||1==(1~=(1>(1<(1>=(1<=1)))));
+ a++; ++a; a--; --a;
+ a = person.life;
+ a = kitchen.&arr;
+ a = kitchen.#arr;
+ a = Bird::wingspan;
+ a = kitchen has general;
+ a = kitchen hasnt general;
+ a = kitchen provides arr;
+ a = person in kitchen;
+ a = person notin kitchen;
+ a = person ofclass Bird;
+ a = a == 0 or 1;
+ a = StubR();
+ a = StubR(a);
+ a = StubR(, a);
+ a = "string";
+ a = 'word';
+ a = '''; ! character
+ a = $09afAF;
+ a = $$01;
+ a = ##Eat; a = #a$Eat;
+ a = #g$self;
+ a = #n$!word;
+ a = #r$StubR;
+ a = #dict_par1;
+ default:
+ for (a = 2, b = a; (a < buffer->1 + 2) && (Bird::wingspan): ++a, b--) {
+ print (char) buffer->a;
+ }
+ new_line;
+ for (::) break;
+ }
+ .saved;;
+];
+
+[ TestNumberSub;
+ print_ret parsed_number, " is ", (number) parsed_number, ".";
+];
+
+[ TestAttributeSub; print_ret (The) noun, " has been reversed."; ];
+
+[ CreatureTest obj; return obj has animate; ];
+
+[ TestCreatureSub; print_ret (The) noun, " is a creature."; ];
+
+[ TestMultiheldSub; print_ret "You are holding ", (the) noun, "."; ];
+
+[ TestMultiexceptSub; "You test ", (the) noun, " with ", (the) second, "."; ];
+
+[ TestMultiinsideSub; "You test ", (the) noun, " from ", (the) second, "."; ];
+
+[ TestMultiSub; print_ret (The) noun, " is a thing."; ];
+
+[ TestNounFilterSub; print_ret (The) noun, " is a bird."; ];
+
+[ TestScopeFilterSub; print_ret (The) noun, " is a direction."; ];
+
+[ TestSpecialSub; "Your lucky number is ", parsed_number, "."; ];
+
+[ TestTopicSub; "You discuss a topic."; ];
+
+[ TestNounSub; "That is ", (a) noun, "."; ];
+
+[ TestHeldSub; "You are holding ", (a) noun, "."; ];
+
+[ NewWaveSub; "That would be foolish."; ];
+
+[ FeelSub; print_ret (The) noun, " feels normal."; ];
+
+[ ReverseSub from;
+ from = parent(noun);
+ move noun to parent(second);
+ if (from == to)
+ move second to to;
+ else
+ move second to from;
+ give noun to;
+ from = to;
+ give second from;
+ "You swap ", (the) noun, " and ", (the) second, ".";
+];
+
+End: The End directive ends the source code.
diff --git a/tests/examplefiles/example.kal b/tests/examplefiles/example.kal
new file mode 100644
index 00000000..c05c14ca
--- /dev/null
+++ b/tests/examplefiles/example.kal
@@ -0,0 +1,75 @@
+#!/usr/bin/env kal
+
+# This demo executes GET requests in parallel and in series
+# using `for` loops and `wait for` statements.
+
+# Notice how the serial GET requests always return in order
+# and take longer in total. Parallel requests come back in
+# order of receipt.
+
+http = require 'http'
+
+urls = ['http://www.google.com'
+ 'http://www.apple.com'
+ 'http://www.microsoft.com'
+ 'http://www.nodejs.org'
+ 'http://www.yahoo.com']
+
+# This function does a GET request for each URL in series
+# It will wait for a response from each request before moving on
+# to the next request. Notice the output will be in the same order as the
+# urls variable every time regardless of response time.
+# It is a task rather than a function because it is called asynchronously
+# This allows us to use `return` to implicitly call back
+task series_demo()
+ # The `series` keyword is optional here (for loops are serial by default)
+ total_time = 0
+
+ for series url in urls
+ timer = new Date
+
+ # we use the `safe` keyword because get is a "nonstandard" task
+ # that does not call back with an error argument
+ safe wait for response from http.get url
+
+ delay = new Date() - timer
+ total_time += delay
+
+ print "GET #{url} - #{response.statusCode} - #{response.connection.bytesRead} bytes - #{delay} ms"
+
+ # because we are in a task rather than a function, this actually exectutes a callback
+ return total_time
+
+# This function does a GET request for each URL in parallel
+# It will NOT wait for a response from each request before moving on
+# to the next request. Notice the output will be determined by the order in which
+# the requests complete!
+task parallel_demo()
+ total_time = 0
+
+ # The `parallel` keyword is only meaningful here because the loop contains
+ # a `wait for` statement (meaning callbacks are used)
+ for parallel url in urls
+ timer = new Date
+
+ # we use the `safe` keyword because get is a "nonstandard" task
+ # that does not call back with an error argument
+ safe wait for response from http.get url
+
+ delay = new Date() - timer
+ total_time += delay
+
+ print "GET #{url} - #{response.statusCode} - #{response.connection.bytesRead} bytes - #{delay}ms"
+
+ # because we are in a task rather than a function, this actually exectutes a callback
+ return total_time
+
+print 'Series Requests...'
+wait for time1 from series_demo()
+print "Total duration #{time1}ms"
+
+print ''
+
+print 'Parallel Requests...'
+wait for time2 from parallel_demo()
+print "Total duration #{time2}ms"
diff --git a/tests/examplefiles/example.ma b/tests/examplefiles/example.ma
new file mode 100644
index 00000000..a8119ea5
--- /dev/null
+++ b/tests/examplefiles/example.ma
@@ -0,0 +1,8 @@
+1 + 1 (* This is a comment *)
+Global`
+SomeNamespace`Foo
+f[x_, y__, 3, z___] := tsneirsnteintie "fosrt" neisnrteiasrn
+E + 3
+Plus[1,Times[2,3]]
+Map[#1 + #2&, SomePairList]
+Plus[1.,-1,-1.,-1.0,] \ No newline at end of file
diff --git a/tests/examplefiles/example.mq4 b/tests/examplefiles/example.mq4
new file mode 100644
index 00000000..54a5fa60
--- /dev/null
+++ b/tests/examplefiles/example.mq4
@@ -0,0 +1,187 @@
+//+------------------------------------------------------------------+
+//| PeriodConverter.mq4 |
+//| Copyright 2006-2014, MetaQuotes Software Corp. |
+//| http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#property copyright "2006-2014, MetaQuotes Software Corp."
+#property link "http://www.mql4.com"
+#property description "Period Converter to updated format of history base"
+#property strict
+#property show_inputs
+#include <WinUser32.mqh>
+
+input int InpPeriodMultiplier=3; // Period multiplier factor
+int ExtHandle=-1;
+//+------------------------------------------------------------------+
+//| script program start function |
+//+------------------------------------------------------------------+
+void OnStart()
+ {
+ datetime time0;
+ ulong last_fpos=0;
+ long last_volume=0;
+ int i,start_pos,periodseconds;
+ int hwnd=0,cnt=0;
+//---- History header
+ int file_version=401;
+ string c_copyright;
+ string c_symbol=Symbol();
+ int i_period=Period()*InpPeriodMultiplier;
+ int i_digits=Digits;
+ int i_unused[13];
+ MqlRates rate;
+//---
+ ExtHandle=FileOpenHistory(c_symbol+(string)i_period+".hst",FILE_BIN|FILE_WRITE|FILE_SHARE_WRITE|FILE_SHARE_READ|FILE_ANSI);
+ if(ExtHandle<0)
+ return;
+ c_copyright="(C)opyright 2003, MetaQuotes Software Corp.";
+ ArrayInitialize(i_unused,0);
+//--- write history file header
+ FileWriteInteger(ExtHandle,file_version,LONG_VALUE);
+ FileWriteString(ExtHandle,c_copyright,64);
+ FileWriteString(ExtHandle,c_symbol,12);
+ FileWriteInteger(ExtHandle,i_period,LONG_VALUE);
+ FileWriteInteger(ExtHandle,i_digits,LONG_VALUE);
+ FileWriteInteger(ExtHandle,0,LONG_VALUE);
+ FileWriteInteger(ExtHandle,0,LONG_VALUE);
+ FileWriteArray(ExtHandle,i_unused,0,13);
+//--- write history file
+ periodseconds=i_period*60;
+ start_pos=Bars-1;
+ rate.open=Open[start_pos];
+ rate.low=Low[start_pos];
+ rate.high=High[start_pos];
+ rate.tick_volume=(long)Volume[start_pos];
+ rate.spread=0;
+ rate.real_volume=0;
+ //--- normalize open time
+ rate.time=Time[start_pos]/periodseconds;
+ rate.time*=periodseconds;
+ for(i=start_pos-1; i>=0; i--)
+ {
+ if(IsStopped())
+ break;
+ time0=Time[i];
+ //--- history may be updated
+ if(i==0)
+ {
+ //--- modify index if history was updated
+ if(RefreshRates())
+ i=iBarShift(NULL,0,time0);
+ }
+ //---
+ if(time0>=rate.time+periodseconds || i==0)
+ {
+ if(i==0 && time0<rate.time+periodseconds)
+ {
+ rate.tick_volume+=(long)Volume[0];
+ if(rate.low>Low[0])
+ rate.low=Low[0];
+ if(rate.high<High[0])
+ rate.high=High[0];
+ rate.close=Close[0];
+ }
+ last_fpos=FileTell(ExtHandle);
+ last_volume=(long)Volume[i];
+ FileWriteStruct(ExtHandle,rate);
+ cnt++;
+ if(time0>=rate.time+periodseconds)
+ {
+ rate.time=time0/periodseconds;
+ rate.time*=periodseconds;
+ rate.open=Open[i];
+ rate.low=Low[i];
+ rate.high=High[i];
+ rate.close=Close[i];
+ rate.tick_volume=last_volume;
+ }
+ }
+ else
+ {
+ rate.tick_volume+=(long)Volume[i];
+ if(rate.low>Low[i])
+ rate.low=Low[i];
+ if(rate.high<High[i])
+ rate.high=High[i];
+ rate.close=Close[i];
+ }
+ }
+ FileFlush(ExtHandle);
+ Print(cnt," record(s) written");
+//--- collect incoming ticks
+ datetime last_time=LocalTime()-5;
+ while(!IsStopped())
+ {
+ datetime cur_time=LocalTime();
+ //--- check for new rates
+ if(RefreshRates())
+ {
+ time0=Time[0];
+ FileSeek(ExtHandle,last_fpos,SEEK_SET);
+ //--- is there current bar?
+ if(time0<rate.time+periodseconds)
+ {
+ rate.tick_volume+=(long)Volume[0]-last_volume;
+ last_volume=(long)Volume[0];
+ if(rate.low>Low[0])
+ rate.low=Low[0];
+ if(rate.high<High[0])
+ rate.high=High[0];
+ rate.close=Close[0];
+ }
+ else
+ {
+ //--- no, there is new bar
+ rate.tick_volume+=(long)Volume[1]-last_volume;
+ if(rate.low>Low[1])
+ rate.low=Low[1];
+ if(rate.high<High[1])
+ rate.high=High[1];
+ //--- write previous bar remains
+ FileWriteStruct(ExtHandle,rate);
+ last_fpos=FileTell(ExtHandle);
+ //----
+ rate.time=time0/periodseconds;
+ rate.time*=periodseconds;
+ rate.open=Open[0];
+ rate.low=Low[0];
+ rate.high=High[0];
+ rate.close=Close[0];
+ rate.tick_volume=(long)Volume[0];
+ last_volume=rate.tick_volume;
+ }
+ //----
+ FileWriteStruct(ExtHandle,rate);
+ FileFlush(ExtHandle);
+ //---
+ if(hwnd==0)
+ {
+ hwnd=WindowHandle(Symbol(),i_period);
+ if(hwnd!=0)
+ Print("Chart window detected");
+ }
+ //--- refresh window not frequently than 1 time in 2 seconds
+ if(hwnd!=0 && cur_time-last_time>=2)
+ {
+ PostMessageA(hwnd,WM_COMMAND,33324,0);
+ last_time=cur_time;
+ }
+ }
+ Sleep(50);
+ }
+//---
+ }
+//+------------------------------------------------------------------+
+//| |
+//+------------------------------------------------------------------+
+void OnDeinit(const int reason)
+ {
+//---
+ if(ExtHandle>=0)
+ {
+ FileClose(ExtHandle);
+ ExtHandle=-1;
+ }
+//---
+ }
+//+------------------------------------------------------------------+ \ No newline at end of file
diff --git a/tests/examplefiles/example.mqh b/tests/examplefiles/example.mqh
new file mode 100644
index 00000000..ee80ed52
--- /dev/null
+++ b/tests/examplefiles/example.mqh
@@ -0,0 +1,123 @@
+//+------------------------------------------------------------------+
+//| Array.mqh |
+//| Copyright 2009-2013, MetaQuotes Software Corp. |
+//| http://www.mql4.com |
+//+------------------------------------------------------------------+
+#include <Object.mqh>
+//+------------------------------------------------------------------+
+//| Class CArray |
+//| Purpose: Base class of dynamic arrays. |
+//| Derives from class CObject. |
+//+------------------------------------------------------------------+
+class CArray : public CObject
+ {
+protected:
+ int m_step_resize; // increment size of the array
+ int m_data_total; // number of elements
+ int m_data_max; // maximmum size of the array without memory reallocation
+ int m_sort_mode; // mode of array sorting
+
+public:
+ CArray(void);
+ ~CArray(void);
+ //--- methods of access to protected data
+ int Step(void) const { return(m_step_resize); }
+ bool Step(const int step);
+ int Total(void) const { return(m_data_total); }
+ int Available(void) const { return(m_data_max-m_data_total); }
+ int Max(void) const { return(m_data_max); }
+ bool IsSorted(const int mode=0) const { return(m_sort_mode==mode); }
+ int SortMode(void) const { return(m_sort_mode); }
+ //--- cleaning method
+ void Clear(void) { m_data_total=0; }
+ //--- methods for working with files
+ virtual bool Save(const int file_handle);
+ virtual bool Load(const int file_handle);
+ //--- sorting method
+ void Sort(const int mode=0);
+
+protected:
+ virtual void QuickSort(int beg,int end,const int mode=0) { }
+ };
+//+------------------------------------------------------------------+
+//| Constructor |
+//+------------------------------------------------------------------+
+CArray::CArray(void) : m_step_resize(16),
+ m_data_total(0),
+ m_data_max(0),
+ m_sort_mode(-1)
+ {
+ }
+//+------------------------------------------------------------------+
+//| Destructor |
+//+------------------------------------------------------------------+
+CArray::~CArray(void)
+ {
+ }
+//+------------------------------------------------------------------+
+//| Method Set for variable m_step_resize |
+//+------------------------------------------------------------------+
+bool CArray::Step(const int step)
+ {
+//--- check
+ if(step>0)
+ {
+ m_step_resize=step;
+ return(true);
+ }
+//--- failure
+ return(false);
+ }
+//+------------------------------------------------------------------+
+//| Sorting an array in ascending order |
+//+------------------------------------------------------------------+
+void CArray::Sort(const int mode)
+ {
+//--- check
+ if(IsSorted(mode))
+ return;
+ m_sort_mode=mode;
+ if(m_data_total<=1)
+ return;
+//--- sort
+ QuickSort(0,m_data_total-1,mode);
+ }
+//+------------------------------------------------------------------+
+//| Writing header of array to file |
+//+------------------------------------------------------------------+
+bool CArray::Save(const int file_handle)
+ {
+//--- check handle
+ if(file_handle!=INVALID_HANDLE)
+ {
+ //--- write start marker - 0xFFFFFFFFFFFFFFFF
+ if(FileWriteLong(file_handle,-1)==sizeof(long))
+ {
+ //--- write array type
+ if(FileWriteInteger(file_handle,Type(),INT_VALUE)==INT_VALUE)
+ return(true);
+ }
+ }
+//--- failure
+ return(false);
+ }
+//+------------------------------------------------------------------+
+//| Reading header of array from file |
+//+------------------------------------------------------------------+
+bool CArray::Load(const int file_handle)
+ {
+//--- check handle
+ if(file_handle!=INVALID_HANDLE)
+ {
+ //--- read and check start marker - 0xFFFFFFFFFFFFFFFF
+ if(FileReadLong(file_handle)==-1)
+ {
+ //--- read and check array type
+ if(FileReadInteger(file_handle,INT_VALUE)==Type())
+ return(true);
+ }
+ }
+//--- failure
+ return(false);
+ }
+//+------------------------------------------------------------------+
diff --git a/tests/examplefiles/example.ni b/tests/examplefiles/example.ni
new file mode 100644
index 00000000..32279e80
--- /dev/null
+++ b/tests/examplefiles/example.ni
@@ -0,0 +1,57 @@
+ | | |
+"Informal by Nature"
+[ * * * ]
+by
+[ * * * ]
+David Corbett
+
+[This is a [nested] comment.]
+
+Section 1 - Use option translation
+
+Use maximum tests of at least 100 translates as (-
+@c
+Constant MAX_TESTS = {N}; —). | Section 2
+
+A room has a number called size.
+
+The Kitchen is a room. "A nondescript kitchen.“ The Kitchen has size 2.
+
+When play begins:
+ say "Testing:[line break]";
+ test 0.
+
+To test (N — number): (—
+ if (Test({N}) == (+size of the Kitchen [this should succeed]+)) {-open—brace}
+ print ”Success.^”;
+ {-close-brace} else {
+ print “Failure.^";
+ }
+]; ! You shouldn't end a routine within a phrase definition, but it works.
+[ Unused;
+ #Include "\
+@p \
+"; ! At signs hold no power here.
+! Of course, the file "@p .h" must exist.
+-).
+
+Include (-!% This is not ICL.
+
+[ Test x;
+ if (x) {x++;}
+ {–! Single line comment.}
+@inc x;
+@p At signs.
+...
+@Purpose: ...
+...
+@-...
+@c ...
+@inc x;
+@c
+@c
+ return x;
+];
+@Purpose: ...
+@-------------------------------------------------------------------------------
+-).
diff --git a/tests/examplefiles/example.nix b/tests/examplefiles/example.nix
new file mode 100644
index 00000000..515b686f
--- /dev/null
+++ b/tests/examplefiles/example.nix
@@ -0,0 +1,80 @@
+{ stdenv, fetchurl, fetchgit, openssl, zlib, pcre, libxml2, libxslt, expat
+, rtmp ? false
+, fullWebDAV ? false
+, syslog ? false
+, moreheaders ? false, ...}:
+
+let
+ version = "1.4.4";
+ mainSrc = fetchurl {
+ url = "http://nginx.org/download/nginx-${version}.tar.gz";
+ sha256 = "1f82845mpgmhvm151fhn2cnqjggw9w7cvsqbva9rb320wmc9m63w";
+ };
+
+ rtmp-ext = fetchgit {
+ url = git://github.com/arut/nginx-rtmp-module.git;
+ rev = "1cfb7aeb582789f3b15a03da5b662d1811e2a3f1";
+ sha256 = "03ikfd2l8mzsjwx896l07rdrw5jn7jjfdiyl572yb9jfrnk48fwi";
+ };
+
+ dav-ext = fetchgit {
+ url = git://github.com/arut/nginx-dav-ext-module.git;
+ rev = "54cebc1f21fc13391aae692c6cce672fa7986f9d";
+ sha256 = "1dvpq1fg5rslnl05z8jc39sgnvh3akam9qxfl033akpczq1bh8nq";
+ };
+
+ syslog-ext = fetchgit {
+ url = https://github.com/yaoweibin/nginx_syslog_patch.git;
+ rev = "165affd9741f0e30c4c8225da5e487d33832aca3";
+ sha256 = "14dkkafjnbapp6jnvrjg9ip46j00cr8pqc2g7374z9aj7hrvdvhs";
+ };
+
+ moreheaders-ext = fetchgit {
+ url = https://github.com/agentzh/headers-more-nginx-module.git;
+ rev = "refs/tags/v0.23";
+ sha256 = "12pbjgsxnvcf2ff2i2qdn39q4cm5czlgrng96j8ml4cgxvnbdh39";
+ };
+in
+
+stdenv.mkDerivation rec {
+ name = "nginx-${version}";
+ src = mainSrc;
+
+ buildInputs = [ openssl zlib pcre libxml2 libxslt
+ ] ++ stdenv.lib.optional fullWebDAV expat;
+
+ patches = if syslog then [ "${syslog-ext}/syslog_1.4.0.patch" ] else [];
+
+ configureFlags = [
+ "--with-http_ssl_module"
+ "--with-http_spdy_module"
+ "--with-http_xslt_module"
+ "--with-http_sub_module"
+ "--with-http_dav_module"
+ "--with-http_gzip_static_module"
+ "--with-http_secure_link_module"
+ "--with-ipv6"
+ # Install destination problems
+ # "--with-http_perl_module"
+ ] ++ stdenv.lib.optional rtmp "--add-module=${rtmp-ext}"
+ ++ stdenv.lib.optional fullWebDAV "--add-module=${dav-ext}"
+ ++ stdenv.lib.optional syslog "--add-module=${syslog-ext}"
+ ++ stdenv.lib.optional moreheaders "--add-module=${moreheaders-ext}";
+
+ preConfigure = ''
+ export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I${libxml2 }/include/libxml2"
+ '';
+
+ # escape example
+ postInstall = ''
+ mv $out/sbin $out/bin ''' ''${
+ ${ if true then ${ "" } else false }
+ '';
+
+ meta = {
+ description = "A reverse proxy and lightweight webserver";
+ maintainers = [ stdenv.lib.maintainers.raskin];
+ platforms = stdenv.lib.platforms.all;
+ inherit version;
+ };
+}
diff --git a/tests/examplefiles/example.stan b/tests/examplefiles/example.stan
index e936f54a..7eb6fdfc 100644
--- a/tests/examplefiles/example.stan
+++ b/tests/examplefiles/example.stan
@@ -19,6 +19,7 @@ data {
positive_ordered[3] wibble;
corr_matrix[3] grault;
cov_matrix[3] garply;
+ cholesky_factor_cov[3] waldo;
real<lower=-1,upper=1> foo1;
real<lower=0> foo2;
@@ -94,6 +95,7 @@ model {
// lp__ should be highlighted
// normal_log as a function
lp__ <- lp__ + normal_log(plugh, 0, 1);
+ increment_log_prob(normal_log(plugh, 0, 1));
// print statement and string literal
print("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_~@#$%^&*`'-+={}[].,;: ");
diff --git a/tests/examplefiles/example.todotxt b/tests/examplefiles/example.todotxt
new file mode 100644
index 00000000..55ee5286
--- /dev/null
+++ b/tests/examplefiles/example.todotxt
@@ -0,0 +1,9 @@
+(A) Call Mom @Phone +Family
+(A) 2014-01-08 Schedule annual checkup +Health
+(B) Outline chapter 5 +Novel @Computer
+(C) Add cover sheets @Office +TPSReports
+Plan backyard herb garden @Home
+Pick up milk @GroceryStore
+Research self-publishing services +Novel @Computer
+x 2014-01-10 Download Todo.txt mobile app @Phone
+x 2014-01-10 2014-01-07 Download Todo.txt CLI @Computer
diff --git a/tests/examplefiles/exampleScript.cfc b/tests/examplefiles/exampleScript.cfc
new file mode 100644
index 00000000..002acbcd
--- /dev/null
+++ b/tests/examplefiles/exampleScript.cfc
@@ -0,0 +1,241 @@
+<cfscript>
+/**
+********************************************************************************
+ContentBox - A Modular Content Platform
+Copyright 2012 by Luis Majano and Ortus Solutions, Corp
+www.gocontentbox.org | www.luismajano.com | www.ortussolutions.com
+********************************************************************************
+Apache License, Version 2.0
+
+Copyright Since [2012] [Luis Majano and Ortus Solutions,Corp]
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+********************************************************************************
+* A generic content service for content objects
+*/
+component extends="coldbox.system.orm.hibernate.VirtualEntityService" singleton{
+
+ // DI
+ property name="settingService" inject="id:settingService@cb";
+ property name="cacheBox" inject="cachebox";
+ property name="log" inject="logbox:logger:{this}";
+ property name="customFieldService" inject="customFieldService@cb";
+ property name="categoryService" inject="categoryService@cb";
+ property name="commentService" inject="commentService@cb";
+ property name="contentVersionService" inject="contentVersionService@cb";
+ property name="authorService" inject="authorService@cb";
+ property name="populator" inject="wirebox:populator";
+ property name="systemUtil" inject="SystemUtil@cb";
+
+ /*
+ * Constructor
+ * @entityName.hint The content entity name to bind this service to.
+ */
+ ContentService function init(entityName="cbContent"){
+ // init it
+ super.init(entityName=arguments.entityName, useQueryCaching=true);
+
+ // Test scope coloring in pygments
+ this.colorTestVar = "Just for testing pygments!";
+ cookie.colorTestVar = "";
+ client.colorTestVar = ""
+ session.colorTestVar = "";
+ application.colorTestVar = "";
+
+ return this;
+ }
+
+ /**
+ * Clear all content caches
+ * @async.hint Run it asynchronously or not, defaults to false
+ */
+ function clearAllCaches(boolean async=false){
+ var settings = settingService.getAllSettings(asStruct=true);
+ // Get appropriate cache provider
+ var cache = cacheBox.getCache( settings.cb_content_cacheName );
+ cache.clearByKeySnippet(keySnippet="cb-content",async=arguments.async);
+ return this;
+ }
+
+ /**
+ * Clear all page wrapper caches
+ * @async.hint Run it asynchronously or not, defaults to false
+ */
+ function clearAllPageWrapperCaches(boolean async=false){
+ var settings = settingService.getAllSettings(asStruct=true);
+ // Get appropriate cache provider
+ var cache = cacheBox.getCache( settings.cb_content_cacheName );
+ cache.clearByKeySnippet(keySnippet="cb-content-pagewrapper",async=arguments.async);
+ return this;
+ }
+
+ /**
+ * Clear all page wrapper caches
+ * @slug.hint The slug partial to clean on
+ * @async.hint Run it asynchronously or not, defaults to false
+ */
+ function clearPageWrapperCaches(required any slug, boolean async=false){
+ var settings = settingService.getAllSettings(asStruct=true);
+ // Get appropriate cache provider
+ var cache = cacheBox.getCache( settings.cb_content_cacheName );
+ cache.clearByKeySnippet(keySnippet="cb-content-pagewrapper-#arguments.slug#",async=arguments.async);
+ return this;
+ }
+
+ /**
+ * Clear a page wrapper cache
+ * @slug.hint The slug to clean
+ * @async.hint Run it asynchronously or not, defaults to false
+ */
+ function clearPageWrapper(required any slug, boolean async=false){
+ var settings = settingService.getAllSettings(asStruct=true);
+ // Get appropriate cache provider
+ var cache = cacheBox.getCache( settings.cb_content_cacheName );
+ cache.clear("cb-content-pagewrapper-#arguments.slug#/");
+ return this;
+ }
+
+ /**
+ * Searches published content with cool paramters, remember published content only
+ * @searchTerm.hint The search term to search
+ * @max.hint The maximum number of records to paginate
+ * @offset.hint The offset in the pagination
+ * @asQuery.hint Return as query or array of objects, defaults to array of objects
+ * @sortOrder.hint The sorting of the search results, defaults to publishedDate DESC
+ * @isPublished.hint Search for published, non-published or both content objects [true, false, 'all']
+ * @searchActiveContent.hint Search only content titles or both title and active content. Defaults to both.
+ */
+ function searchContent(
+ any searchTerm="",
+ numeric max=0,
+ numeric offset=0,
+ boolean asQuery=false,
+ any sortOrder="publishedDate DESC",
+ any isPublished=true,
+ boolean searchActiveContent=true){
+
+ var results = {};
+ var c = newCriteria();
+
+ // only published content
+ if( isBoolean( arguments.isPublished ) ){
+ // Published bit
+ c.isEq( "isPublished", javaCast( "Boolean", arguments.isPublished ) );
+ // Published eq true evaluate other params
+ if( arguments.isPublished ){
+ c.isLt("publishedDate", now() )
+ .$or( c.restrictions.isNull("expireDate"), c.restrictions.isGT("expireDate", now() ) )
+ .isEq("passwordProtection","");
+ }
+ }
+
+ // Search Criteria
+ if( len( arguments.searchTerm ) ){
+ // like disjunctions
+ c.createAlias("activeContent","ac");
+ // Do we search title and active content or just title?
+ if( arguments.searchActiveContent ){
+ c.$or( c.restrictions.like("title","%#arguments.searchTerm#%"),
+ c.restrictions.like("ac.content", "%#arguments.searchTerm#%") );
+ }
+ else{
+ c.like( "title", "%#arguments.searchTerm#%" );
+ }
+ }
+
+ // run criteria query and projections count
+ results.count = c.count( "contentID" );
+ results.content = c.resultTransformer( c.DISTINCT_ROOT_ENTITY )
+ .list(offset=arguments.offset, max=arguments.max, sortOrder=arguments.sortOrder, asQuery=arguments.asQuery);
+
+ return results;
+ }
+
+/********************************************* PRIVATE *********************************************/
+
+
+ /**
+ * Update the content hits
+ * @contentID.hint The content id to update
+ */
+ private function syncUpdateHits(required contentID){
+ var q = new Query(sql="UPDATE cb_content SET hits = hits + 1 WHERE contentID = #arguments.contentID#").execute();
+ return this;
+ }
+
+
+ private function closureTest(){
+ methodCall(
+ param1,
+ function( arg1, required arg2 ){
+ var settings = settingService.getAllSettings(asStruct=true);
+ // Get appropriate cache provider
+ var cache = cacheBox.getCache( settings.cb_content_cacheName );
+ cache.clear("cb-content-pagewrapper-#arguments.slug#/");
+ return this;
+ },
+ param1
+ );
+ }
+
+ private function StructliteralTest(){
+ return {
+ foo = bar,
+ brad = 'Wood',
+ func = function( arg1, required arg2 ){
+ var settings = settingService.getAllSettings(asStruct=true);
+ // Get appropriate cache provider
+ var cache = cacheBox.getCache( settings.cb_content_cacheName );
+ cache.clear("cb-content-pagewrapper-#arguments.slug#/");
+ return this;
+ },
+ array = [
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 'test',
+ 'testing',
+ 'testerton',
+ {
+ foo = true,
+ brad = false,
+ wood = null
+ }
+ ],
+ last = "final"
+ };
+ }
+
+ private function arrayliteralTest(){
+ return [
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 'test',
+ 'testing',
+ 'testerton',
+ {
+ foo = true,
+ brad = false,
+ wood = null
+ },
+ 'testy-von-testavich'
+ ];
+ }
+
+}
+</cfscript> \ No newline at end of file
diff --git a/tests/examplefiles/exampleTag.cfc b/tests/examplefiles/exampleTag.cfc
new file mode 100644
index 00000000..753bb826
--- /dev/null
+++ b/tests/examplefiles/exampleTag.cfc
@@ -0,0 +1,18 @@
+<cfcomponent>
+
+ <cffunction name="init" access="public" returntype="any">
+ <cfargument name="arg1" type="any" required="true">
+ <cfset this.myVariable = arguments.arg1>
+
+ <cfreturn this>
+ </cffunction>
+
+ <cffunction name="testFunc" access="private" returntype="void">
+ <cfargument name="arg1" type="any" required="false">
+
+ <cfif structKeyExists(arguments, "arg1")>
+ <cfset writeoutput("Argument exists")>
+ </cfif>
+ </cffunction>
+
+</cfcomponent> \ No newline at end of file
diff --git a/tests/examplefiles/example_elixir.ex b/tests/examplefiles/example_elixir.ex
index 2e92163d..e3ce7816 100644
--- a/tests/examplefiles/example_elixir.ex
+++ b/tests/examplefiles/example_elixir.ex
@@ -360,4 +360,6 @@ defmodule Module do
raise ArgumentError, message:
"could not call #{fun} on module #{module} because it was already compiled"
end
-end \ No newline at end of file
+end
+
+HashDict.new [{'A', 0}, {'T', 0}, {'C', 0}, {'G', 0}]
diff --git a/tests/examplefiles/function_arrows.coffee b/tests/examplefiles/function_arrows.coffee
new file mode 100644
index 00000000..cd1ef1e8
--- /dev/null
+++ b/tests/examplefiles/function_arrows.coffee
@@ -0,0 +1,11 @@
+methodA:-> 'A'
+methodB:=> 'B'
+methodC:()=> 'C'
+methodD:()-> 'D'
+methodE:(a,b)-> 'E'
+methodF:(c,d)-> 'F'
+-> 'G'
+=> 'H'
+
+(-> 'I')
+(=> 'J')
diff --git a/tests/examplefiles/hash_syntax.rb b/tests/examplefiles/hash_syntax.rb
new file mode 100644
index 00000000..35b27723
--- /dev/null
+++ b/tests/examplefiles/hash_syntax.rb
@@ -0,0 +1,5 @@
+{ :old_syntax => 'ok' }
+{ 'stings as key' => 'should be ok' }
+{ new_syntax: 'broken until now' }
+{ withoutunderscore: 'should be ok' }
+{ _underscoreinfront: 'might be ok, if I understand the pygments code correct' }
diff --git a/tests/examplefiles/hello.at b/tests/examplefiles/hello.at
new file mode 100644
index 00000000..23af2f2d
--- /dev/null
+++ b/tests/examplefiles/hello.at
@@ -0,0 +1,6 @@
+def me := object: {
+ def name := "Kevin";
+ def sayHello(peerName) {
+ system.println(peerName + " says hello!");
+ };
+};
diff --git a/tests/examplefiles/hello.golo b/tests/examplefiles/hello.golo
new file mode 100644
index 00000000..7e8ca214
--- /dev/null
+++ b/tests/examplefiles/hello.golo
@@ -0,0 +1,5 @@
+module hello.World
+
+function main = |args| {
+ println("Hello world!")
+}
diff --git a/tests/examplefiles/hello.lsl b/tests/examplefiles/hello.lsl
new file mode 100644
index 00000000..61697e7f
--- /dev/null
+++ b/tests/examplefiles/hello.lsl
@@ -0,0 +1,12 @@
+default
+{
+ state_entry()
+ {
+ llSay(0, "Hello, Avatar!");
+ }
+
+ touch_start(integer total_number)
+ {
+ llSay(0, "Touched.");
+ }
+}
diff --git a/tests/examplefiles/File.hy b/tests/examplefiles/hybris_File.hy
index 9c86c641..9c86c641 100644
--- a/tests/examplefiles/File.hy
+++ b/tests/examplefiles/hybris_File.hy
diff --git a/tests/examplefiles/mg_sample.pro b/tests/examplefiles/idl_sample.pro
index 814d510d..814d510d 100644
--- a/tests/examplefiles/mg_sample.pro
+++ b/tests/examplefiles/idl_sample.pro
diff --git a/tests/examplefiles/inet_pton6.dg b/tests/examplefiles/inet_pton6.dg
index 4104b3e7..3813d5b8 100644
--- a/tests/examplefiles/inet_pton6.dg
+++ b/tests/examplefiles/inet_pton6.dg
@@ -1,5 +1,5 @@
-re = import!
-sys = import!
+import '/re'
+import '/sys'
# IPv6address = hexpart [ ":" IPv4address ]
@@ -20,7 +20,7 @@ addrv6 = re.compile $ r'(?i)(?:{})(?::{})?$'.format hexpart addrv4
#
# :return: a decimal integer
#
-base_n = (q digits) -> foldl (x y) -> (x * q + y) 0 digits
+base_n = q digits -> foldl (x y -> x * q + y) 0 digits
# Parse a sequence of hexadecimal numbers
@@ -29,7 +29,7 @@ base_n = (q digits) -> foldl (x y) -> (x * q + y) 0 digits
#
# :return: an iterable of Python ints
#
-unhex = q -> q and map p -> (int p 16) (q.split ':')
+unhex = q -> q and map (p -> int p 16) (q.split ':')
# Parse an IPv6 address as specified in RFC 4291.
@@ -39,33 +39,33 @@ unhex = q -> q and map p -> (int p 16) (q.split ':')
# :return: an integer which, written in binary form, points to the same node.
#
inet_pton6 = address ->
- raise $ ValueError 'not a valid IPv6 address' if not (match = addrv6.match address)
+ not (match = addrv6.match address) => raise $ ValueError 'not a valid IPv6 address'
start, end, *ipv4 = match.groups!
is_ipv4 = not $ None in ipv4
shift = (7 - start.count ':' - 2 * is_ipv4) * 16
- raise $ ValueError 'not a valid IPv6 address' if (end is None and shift) or shift < 0
+ (end is None and shift) or shift < 0 => raise $ ValueError 'not a valid IPv6 address'
hexaddr = (base_n 0x10000 (unhex start) << shift) + base_n 0x10000 (unhex $ end or '')
- (hexaddr << 32) + base_n 0x100 (map int ipv4) if is_ipv4 else hexaddr
+ if (is_ipv4 => (hexaddr << 32) + base_n 0x100 (map int ipv4)) (otherwise => hexaddr)
-inet6_type = q -> switch
- not q = 'unspecified'
- q == 1 = 'loopback'
- (q >> 32) == 0x000000000000ffff = 'IPv4-mapped'
- (q >> 64) == 0xfe80000000000000 = 'link-local'
- (q >> 120) != 0x00000000000000ff = 'general unicast'
- (q >> 112) % (1 << 4) == 0x0000000000000000 = 'multicast w/ reserved scope value'
- (q >> 112) % (1 << 4) == 0x000000000000000f = 'multicast w/ reserved scope value'
- (q >> 112) % (1 << 4) == 0x0000000000000001 = 'interface-local multicast'
- (q >> 112) % (1 << 4) == 0x0000000000000004 = 'admin-local multicast'
- (q >> 112) % (1 << 4) == 0x0000000000000005 = 'site-local multicast'
- (q >> 112) % (1 << 4) == 0x0000000000000008 = 'organization-local multicast'
- (q >> 112) % (1 << 4) == 0x000000000000000e = 'global multicast'
- (q >> 112) % (1 << 4) != 0x0000000000000002 = 'multicast w/ unknown scope value'
- (q >> 24) % (1 << 112) == 0x00000000000001ff = 'solicited-node multicast'
- True = 'link-local multicast'
+inet6_type = q -> if
+ q == 0 => 'unspecified'
+ q == 1 => 'loopback'
+ (q >> 32) == 0x000000000000ffff => 'IPv4-mapped'
+ (q >> 64) == 0xfe80000000000000 => 'link-local'
+ (q >> 120) != 0x00000000000000ff => 'general unicast'
+ (q >> 112) % (1 << 4) == 0x0000000000000000 => 'multicast w/ reserved scope value'
+ (q >> 112) % (1 << 4) == 0x000000000000000f => 'multicast w/ reserved scope value'
+ (q >> 112) % (1 << 4) == 0x0000000000000001 => 'interface-local multicast'
+ (q >> 112) % (1 << 4) == 0x0000000000000004 => 'admin-local multicast'
+ (q >> 112) % (1 << 4) == 0x0000000000000005 => 'site-local multicast'
+ (q >> 112) % (1 << 4) == 0x0000000000000008 => 'organization-local multicast'
+ (q >> 112) % (1 << 4) == 0x000000000000000e => 'global multicast'
+ (q >> 112) % (1 << 4) != 0x0000000000000002 => 'multicast w/ unknown scope value'
+ (q >> 24) % (1 << 112) == 0x00000000000001ff => 'solicited-node multicast'
+ otherwise => 'link-local multicast'
-print $ (x -> (inet6_type x, hex x)) $ inet_pton6 $ sys.stdin.read!.strip!
+print $ (x -> inet6_type x, hex x) $ inet_pton6 $ sys.stdin.read!.strip!
diff --git a/tests/examplefiles/language.hy b/tests/examplefiles/language.hy
new file mode 100644
index 00000000..9768c39c
--- /dev/null
+++ b/tests/examplefiles/language.hy
@@ -0,0 +1,165 @@
+;;;; This contains some of the core Hy functions used
+;;;; to make functional programming slightly easier.
+;;;;
+
+
+(defn _numeric-check [x]
+ (if (not (numeric? x))
+ (raise (TypeError (.format "{0!r} is not a number" x)))))
+
+(defn cycle [coll]
+ "Yield an infinite repetition of the items in coll"
+ (setv seen [])
+ (for [x coll]
+ (yield x)
+ (.append seen x))
+ (while seen
+ (for [x seen]
+ (yield x))))
+
+(defn dec [n]
+ "Decrement n by 1"
+ (_numeric-check n)
+ (- n 1))
+
+(defn distinct [coll]
+ "Return a generator from the original collection with duplicates
+ removed"
+ (let [[seen []] [citer (iter coll)]]
+ (for [val citer]
+ (if (not_in val seen)
+ (do
+ (yield val)
+ (.append seen val))))))
+
+(defn drop [count coll]
+ "Drop `count` elements from `coll` and yield back the rest"
+ (let [[citer (iter coll)]]
+ (try (for [i (range count)]
+ (next citer))
+ (catch [StopIteration]))
+ citer))
+
+(defn even? [n]
+ "Return true if n is an even number"
+ (_numeric-check n)
+ (= (% n 2) 0))
+
+(defn filter [pred coll]
+ "Return all elements from `coll` that pass `pred`"
+ (let [[citer (iter coll)]]
+ (for [val citer]
+ (if (pred val)
+ (yield val)))))
+
+(defn inc [n]
+ "Increment n by 1"
+ (_numeric-check n)
+ (+ n 1))
+
+(defn instance? [klass x]
+ (isinstance x klass))
+
+(defn iterable? [x]
+ "Return true if x is iterable"
+ (try (do (iter x) true)
+ (catch [Exception] false)))
+
+(defn iterate [f x]
+ (setv val x)
+ (while true
+ (yield val)
+ (setv val (f val))))
+
+(defn iterator? [x]
+ "Return true if x is an iterator"
+ (try (= x (iter x))
+ (catch [TypeError] false)))
+
+(defn neg? [n]
+ "Return true if n is < 0"
+ (_numeric-check n)
+ (< n 0))
+
+(defn none? [x]
+ "Return true if x is None"
+ (is x None))
+
+(defn numeric? [x]
+ (import numbers)
+ (instance? numbers.Number x))
+
+(defn nth [coll index]
+ "Return nth item in collection or sequence, counting from 0"
+ (if (not (neg? index))
+ (if (iterable? coll)
+ (try (first (list (take 1 (drop index coll))))
+ (catch [IndexError] None))
+ (try (get coll index)
+ (catch [IndexError] None)))
+ None))
+
+(defn odd? [n]
+ "Return true if n is an odd number"
+ (_numeric-check n)
+ (= (% n 2) 1))
+
+(defn pos? [n]
+ "Return true if n is > 0"
+ (_numeric_check n)
+ (> n 0))
+
+(defn remove [pred coll]
+ "Return coll with elements removed that pass `pred`"
+ (let [[citer (iter coll)]]
+ (for [val citer]
+ (if (not (pred val))
+ (yield val)))))
+
+(defn repeat [x &optional n]
+ "Yield x forever or optionally n times"
+ (if (none? n)
+ (setv dispatch (fn [] (while true (yield x))))
+ (setv dispatch (fn [] (for [_ (range n)] (yield x)))))
+ (dispatch))
+
+(defn repeatedly [func]
+ "Yield result of running func repeatedly"
+ (while true
+ (yield (func))))
+
+(defn take [count coll]
+ "Take `count` elements from `coll`, or the whole set if the total
+ number of entries in `coll` is less than `count`."
+ (let [[citer (iter coll)]]
+ (for [_ (range count)]
+ (yield (next citer)))))
+
+(defn take-nth [n coll]
+ "Return every nth member of coll
+ raises ValueError for (not (pos? n))"
+ (if (pos? n)
+ (let [[citer (iter coll)] [skip (dec n)]]
+ (for [val citer]
+ (yield val)
+ (for [_ (range skip)]
+ (next citer))))
+ (raise (ValueError "n must be positive"))))
+
+(defn take-while [pred coll]
+ "Take all elements while `pred` is true"
+ (let [[citer (iter coll)]]
+ (for [val citer]
+ (if (pred val)
+ (yield val)
+ (break)))))
+
+(defn zero? [n]
+ "Return true if n is 0"
+ (_numeric_check n)
+ (= n 0))
+
+(def *exports* ["cycle" "dec" "distinct" "drop" "even?" "filter" "inc"
+ "instance?" "iterable?" "iterate" "iterator?" "neg?"
+ "none?" "nth" "numeric?" "odd?" "pos?" "remove" "repeat"
+ "repeatedly" "take" "take_nth" "take_while" "zero?"])
diff --git a/tests/examplefiles/limbo.b b/tests/examplefiles/limbo.b
new file mode 100644
index 00000000..e55a0a62
--- /dev/null
+++ b/tests/examplefiles/limbo.b
@@ -0,0 +1,456 @@
+implement Ninewin;
+include "sys.m";
+ sys: Sys;
+include "draw.m";
+ draw: Draw;
+ Image, Display, Pointer: import draw;
+include "arg.m";
+include "keyboard.m";
+include "tk.m";
+include "wmclient.m";
+ wmclient: Wmclient;
+ Window: import wmclient;
+include "sh.m";
+ sh: Sh;
+
+# run a p9 graphics program (default rio) under inferno wm,
+# making available to it:
+# /dev/winname - naming the current inferno window (changing on resize)
+# /dev/mouse - pointer file + resize events; write to change position
+# /dev/cursor - change appearance of cursor.
+# /dev/draw - inferno draw device
+# /dev/cons - read keyboard events, write to 9win stdout.
+
+Ninewin: module {
+ init: fn(ctxt: ref Draw->Context, argv: list of string);
+};
+winname: string;
+
+init(ctxt: ref Draw->Context, argv: list of string)
+{
+ size := Draw->Point(500, 500);
+ sys = load Sys Sys->PATH;
+ draw = load Draw Draw->PATH;
+ wmclient = load Wmclient Wmclient->PATH;
+ wmclient->init();
+ sh = load Sh Sh->PATH;
+
+ buts := Wmclient->Resize;
+ if(ctxt == nil){
+ ctxt = wmclient->makedrawcontext();
+ buts = Wmclient->Plain;
+ }
+ arg := load Arg Arg->PATH;
+ arg->init(argv);
+ arg->setusage("9win [-s] [-x width] [-y height]");
+ exportonly := 0;
+ while(((opt := arg->opt())) != 0){
+ case opt {
+ 's' =>
+ exportonly = 1;
+ 'x' =>
+ size.x = int arg->earg();
+ 'y' =>
+ size.y = int arg->earg();
+ * =>
+ arg->usage();
+ }
+ }
+ if(size.x < 1 || size.y < 1)
+ arg->usage();
+ argv = arg->argv();
+ if(argv != nil && hd argv == "-s"){
+ exportonly = 1;
+ argv = tl argv;
+ }
+ if(argv == nil && !exportonly)
+ argv = "rio" :: nil;
+ if(argv != nil && exportonly){
+ sys->fprint(sys->fildes(2), "9win: no command allowed with -s flag\n");
+ raise "fail:usage";
+ }
+ title := "9win";
+ if(!exportonly)
+ title += " " + hd argv;
+ w := wmclient->window(ctxt, title, buts);
+ w.reshape(((0, 0), size));
+ w.onscreen(nil);
+ if(w.image == nil){
+ sys->fprint(sys->fildes(2), "9win: cannot get image to draw on\n");
+ raise "fail:no window";
+ }
+
+ sys->pctl(Sys->FORKNS|Sys->NEWPGRP, nil);
+ ld := "/n/9win";
+ if(sys->bind("#s", ld, Sys->MREPL) == -1 &&
+ sys->bind("#s", ld = "/n/local", Sys->MREPL) == -1){
+ sys->fprint(sys->fildes(2), "9win: cannot bind files: %r\n");
+ raise "fail:error";
+ }
+ w.startinput("kbd" :: "ptr" :: nil);
+ spawn ptrproc(rq := chan of Sys->Rread, ptr := chan[10] of ref Pointer, reshape := chan[1] of int);
+
+
+ fwinname := sys->file2chan(ld, "winname");
+ fconsctl := sys->file2chan(ld, "consctl");
+ fcons := sys->file2chan(ld, "cons");
+ fmouse := sys->file2chan(ld, "mouse");
+ fcursor := sys->file2chan(ld, "cursor");
+ if(!exportonly){
+ spawn run(sync := chan of string, w.ctl, ld, argv);
+ if((e := <-sync) != nil){
+ sys->fprint(sys->fildes(2), "9win: %s", e);
+ raise "fail:error";
+ }
+ }
+ spawn serveproc(w, rq, fwinname, fconsctl, fcons, fmouse, fcursor);
+ if(!exportonly){
+ # handle events synchronously so that we don't get a "killed" message
+ # from the shell.
+ handleevents(w, ptr, reshape);
+ }else{
+ spawn handleevents(w, ptr, reshape);
+ sys->bind(ld, "/dev", Sys->MBEFORE);
+ export(sys->fildes(0), w.ctl);
+ }
+}
+
+handleevents(w: ref Window, ptr: chan of ref Pointer, reshape: chan of int)
+{
+ for(;;)alt{
+ c := <-w.ctxt.ctl or
+ c = <-w.ctl =>
+ e := w.wmctl(c);
+ if(e != nil)
+ sys->fprint(sys->fildes(2), "9win: ctl error: %s\n", e);
+ if(e == nil && c != nil && c[0] == '!'){
+ alt{
+ reshape <-= 1 =>
+ ;
+ * =>
+ ;
+ }
+ winname = nil;
+ }
+ p := <-w.ctxt.ptr =>
+ if(w.pointer(*p) == 0){
+ # XXX would block here if client isn't reading mouse... but we do want to
+ # extert back-pressure, which conflicts.
+ alt{
+ ptr <-= p =>
+ ;
+ * =>
+ ; # sys->fprint(sys->fildes(2), "9win: discarding mouse event\n");
+ }
+ }
+ }
+}
+
+serveproc(w: ref Window, mouserq: chan of Sys->Rread, fwinname, fconsctl, fcons, fmouse, fcursor: ref Sys->FileIO)
+{
+ winid := 0;
+ krc: list of Sys->Rread;
+ ks: string;
+
+ for(;;)alt {
+ c := <-w.ctxt.kbd =>
+ ks[len ks] = inf2p9key(c);
+ if(krc != nil){
+ hd krc <-= (array of byte ks, nil);
+ ks = nil;
+ krc = tl krc;
+ }
+ (nil, d, nil, wc) := <-fcons.write =>
+ if(wc != nil){
+ sys->write(sys->fildes(1), d, len d);
+ wc <-= (len d, nil);
+ }
+ (nil, nil, nil, rc) := <-fcons.read =>
+ if(rc != nil){
+ if(ks != nil){
+ rc <-= (array of byte ks, nil);
+ ks = nil;
+ }else
+ krc = rc :: krc;
+ }
+ (offset, nil, nil, rc) := <-fwinname.read =>
+ if(rc != nil){
+ if(winname == nil){
+ winname = sys->sprint("noborder.9win.%d", winid++);
+ if(w.image.name(winname, 1) == -1){
+ sys->fprint(sys->fildes(2), "9win: namewin %q failed: %r", winname);
+ rc <-= (nil, "namewin failure");
+ break;
+ }
+ }
+ d := array of byte winname;
+ if(offset < len d)
+ d = d[offset:];
+ else
+ d = nil;
+ rc <-= (d, nil);
+ }
+ (nil, nil, nil, wc) := <-fwinname.write =>
+ if(wc != nil)
+ wc <-= (-1, "permission denied");
+ (nil, nil, nil, rc) := <-fconsctl.read =>
+ if(rc != nil)
+ rc <-= (nil, "permission denied");
+ (nil, d, nil, wc) := <-fconsctl.write =>
+ if(wc != nil){
+ if(string d != "rawon")
+ wc <-= (-1, "cannot change console mode");
+ else
+ wc <-= (len d, nil);
+ }
+ (nil, nil, nil, rc) := <-fmouse.read =>
+ if(rc != nil)
+ mouserq <-= rc;
+ (nil, d, nil, wc) := <-fmouse.write =>
+ if(wc != nil){
+ e := cursorset(w, string d);
+ if(e == nil)
+ wc <-= (len d, nil);
+ else
+ wc <-= (-1, e);
+ }
+ (nil, nil, nil, rc) := <-fcursor.read =>
+ if(rc != nil)
+ rc <-= (nil, "permission denied");
+ (nil, d, nil, wc) := <-fcursor.write =>
+ if(wc != nil){
+ e := cursorswitch(w, d);
+ if(e == nil)
+ wc <-= (len d, nil);
+ else
+ wc <-= (-1, e);
+ }
+ }
+}
+
+ptrproc(rq: chan of Sys->Rread, ptr: chan of ref Pointer, reshape: chan of int)
+{
+ rl: list of Sys->Rread;
+ c := ref Pointer(0, (0, 0), 0);
+ for(;;){
+ ch: int;
+ alt{
+ p := <-ptr =>
+ ch = 'm';
+ c = p;
+ <-reshape =>
+ ch = 'r';
+ rc := <-rq =>
+ rl = rc :: rl;
+ continue;
+ }
+ if(rl == nil)
+ rl = <-rq :: rl;
+ hd rl <-= (sys->aprint("%c%11d %11d %11d %11d ", ch, c.xy.x, c.xy.y, c.buttons, c.msec), nil);
+ rl = tl rl;
+ }
+}
+
+cursorset(w: ref Window, m: string): string
+{
+ if(m == nil || m[0] != 'm')
+ return "invalid mouse message";
+ x := int m[1:];
+ for(i := 1; i < len m; i++)
+ if(m[i] == ' '){
+ while(m[i] == ' ')
+ i++;
+ break;
+ }
+ if(i == len m)
+ return "invalid mouse message";
+ y := int m[i:];
+ return w.wmctl(sys->sprint("ptr %d %d", x, y));
+}
+
+cursorswitch(w: ref Window, d: array of byte): string
+{
+ Hex: con "0123456789abcdef";
+ if(len d != 2*4+64)
+ return w.wmctl("cursor");
+ hot := Draw->Point(bglong(d, 0*4), bglong(d, 1*4));
+ s := sys->sprint("cursor %d %d 16 32 ", hot.x, hot.y);
+ for(i := 2*4; i < len d; i++){
+ c := int d[i];
+ s[len s] = Hex[c >> 4];
+ s[len s] = Hex[c & 16rf];
+ }
+ return w.wmctl(s);
+}
+
+run(sync, ctl: chan of string, ld: string, argv: list of string)
+{
+ Rcmeta: con "|<>&^*[]?();";
+ sys->pctl(Sys->FORKNS, nil);
+ if(sys->bind("#₪", "/srv", Sys->MCREATE) == -1){
+ sync <-= sys->sprint("cannot bind srv device: %r");
+ exit;
+ }
+ srvname := "/srv/9win."+string sys->pctl(0, nil); # XXX do better.
+ fd := sys->create(srvname, Sys->ORDWR, 8r600);
+ if(fd == nil){
+ sync <-= sys->sprint("cannot create %s: %r", srvname);
+ exit;
+ }
+ sync <-= nil;
+ spawn export(fd, ctl);
+ sh->run(nil, "os" ::
+ "rc" :: "-c" ::
+ "mount "+srvname+" /mnt/term;"+
+ "rm "+srvname+";"+
+ "bind -b /mnt/term"+ld+" /dev;"+
+ "bind /mnt/term/dev/draw /dev/draw ||"+
+ "bind -a /mnt/term/dev /dev;"+
+ quotedc("cd"::"/mnt/term"+cwd()::nil, Rcmeta)+";"+
+ quotedc(argv, Rcmeta)+";"::
+ nil
+ );
+}
+
+export(fd: ref Sys->FD, ctl: chan of string)
+{
+ sys->export(fd, "/", Sys->EXPWAIT);
+ ctl <-= "exit";
+}
+
+inf2p9key(c: int): int
+{
+ KF: import Keyboard;
+
+ P9KF: con 16rF000;
+ Spec: con 16rF800;
+ Khome: con P9KF|16r0D;
+ Kup: con P9KF|16r0E;
+ Kpgup: con P9KF|16r0F;
+ Kprint: con P9KF|16r10;
+ Kleft: con P9KF|16r11;
+ Kright: con P9KF|16r12;
+ Kdown: con Spec|16r00;
+ Kview: con Spec|16r00;
+ Kpgdown: con P9KF|16r13;
+ Kins: con P9KF|16r14;
+ Kend: con P9KF|16r18;
+ Kalt: con P9KF|16r15;
+ Kshift: con P9KF|16r16;
+ Kctl: con P9KF|16r17;
+
+ case c {
+ Keyboard->LShift =>
+ return Kshift;
+ Keyboard->LCtrl =>
+ return Kctl;
+ Keyboard->LAlt =>
+ return Kalt;
+ Keyboard->Home =>
+ return Khome;
+ Keyboard->End =>
+ return Kend;
+ Keyboard->Up =>
+ return Kup;
+ Keyboard->Down =>
+ return Kdown;
+ Keyboard->Left =>
+ return Kleft;
+ Keyboard->Right =>
+ return Kright;
+ Keyboard->Pgup =>
+ return Kpgup;
+ Keyboard->Pgdown =>
+ return Kpgdown;
+ Keyboard->Ins =>
+ return Kins;
+
+ # function keys
+ KF|1 or
+ KF|2 or
+ KF|3 or
+ KF|4 or
+ KF|5 or
+ KF|6 or
+ KF|7 or
+ KF|8 or
+ KF|9 or
+ KF|10 or
+ KF|11 or
+ KF|12 =>
+ return (c - KF) + P9KF;
+ }
+ return c;
+}
+
+cwd(): string
+{
+ return sys->fd2path(sys->open(".", Sys->OREAD));
+}
+
+# from string.b, waiting for declaration to be uncommented.
+quotedc(argv: list of string, cl: string): string
+{
+ s := "";
+ while (argv != nil) {
+ arg := hd argv;
+ for (i := 0; i < len arg; i++) {
+ c := arg[i];
+ if (c == ' ' || c == '\t' || c == '\n' || c == '\'' || in(c, cl))
+ break;
+ }
+ if (i < len arg || arg == nil) {
+ s += "'" + arg[0:i];
+ for (; i < len arg; i++) {
+ if (arg[i] == '\'')
+ s[len s] = '\'';
+ s[len s] = arg[i];
+ }
+ s[len s] = '\'';
+ } else
+ s += arg;
+ if (tl argv != nil)
+ s[len s] = ' ';
+ argv = tl argv;
+ }
+ return s;
+}
+
+in(c: int, s: string): int
+{
+ n := len s;
+ if(n == 0)
+ return 0;
+ ans := 0;
+ negate := 0;
+ if(s[0] == '^') {
+ negate = 1;
+ s = s[1:];
+ n--;
+ }
+ for(i := 0; i < n; i++) {
+ if(s[i] == '-' && i > 0 && i < n-1) {
+ if(c >= s[i-1] && c <= s[i+1]) {
+ ans = 1;
+ break;
+ }
+ i++;
+ }
+ else
+ if(c == s[i]) {
+ ans = 1;
+ break;
+ }
+ }
+ if(negate)
+ ans = !ans;
+
+ # just to showcase labels
+skip:
+ return ans;
+}
+
+bglong(d: array of byte, i: int): int
+{
+ return int d[i] | (int d[i+1]<<8) | (int d[i+2]<<16) | (int d[i+3]<<24);
+}
diff --git a/tests/examplefiles/livescript-demo.ls b/tests/examplefiles/livescript-demo.ls
index 2ff68c63..16d1894a 100644
--- a/tests/examplefiles/livescript-demo.ls
+++ b/tests/examplefiles/livescript-demo.ls
@@ -9,6 +9,8 @@ underscores_i$d = ->
//regexp2//g
'strings' and "strings" and \strings
+another-word-list = <[ more words ]>
+
[2 til 10]
|> map (* 2)
|> filter (> 5)
diff --git a/tests/examplefiles/objc_example.m b/tests/examplefiles/objc_example.m
index 67b33022..f4f27170 100644
--- a/tests/examplefiles/objc_example.m
+++ b/tests/examplefiles/objc_example.m
@@ -30,3 +30,6 @@ NSDictionary *d = @{ @"key": @"value" };
NSNumber *n1 = @( 1 );
NSNumber *n2 = @( [a length] );
+
++ (void)f1:(NSString *)s1;
++ (void)f2:(NSString *) s2;
diff --git a/tests/examplefiles/robotframework.txt b/tests/examplefiles/robotframework_test.txt
index 63ba63e6..63ba63e6 100644
--- a/tests/examplefiles/robotframework.txt
+++ b/tests/examplefiles/robotframework_test.txt
diff --git a/tests/examplefiles/rql-queries.rql b/tests/examplefiles/rql-queries.rql
new file mode 100644
index 00000000..1d86df3c
--- /dev/null
+++ b/tests/examplefiles/rql-queries.rql
@@ -0,0 +1,34 @@
+Any N, N2 where N is Note, N2 is Note, N a_faire_par P1, P1 nom 'john', N2 a_faire_par P2, P2 nom 'jane' ;
+DISTINCT Any N, D, C, T, A ORDERBY D DESC LIMIT 40 where N is Note, N diem D, W is Workcase, W concerned_by N, N cost C, N text T, N author A, N diem <= today
+Bookmark B WHERE B owned_by G, G eid 5;
+Any X WHERE E eid 22762, NOT E is_in X, X modification_date D ORDERBY D DESC LIMIT 41;
+Any A, R, SUB ORDERBY R WHERE A is "Workcase", S is Division, S concerned_by A, A subject SUB, S eid 85, A ref R;
+Any D, T, L WHERE D is Document, A concerned_by D,A eid 14533, D title T, D location L;
+Any N,A,B,C,D ORDERBY A DESC WHERE N is Note, W concerned_by N, W eid 14533, N diem A,N author B,N text C,N cost D;
+Any X ORDERBY D DESC LIMIT 41 WHERE E eid 18134, NOT E concerned_by X, X modification_date D
+DISTINCT Any N, D, C, T, A ORDERBY D ASC LIMIT 40 WHERE N is Note, N diem D, P is Person, N to_be_contacted_by G, N cost C, N text T, N author A, G login "john";
+INSERT Person X: X surname "Doe", X firstname "John";
+Workcase W where W ref "ABCD12";
+Workcase W where W ref LIKE "AB%";
+Any X WHERE X X eid 53
+Any X WHERE X Document X occurence_of F, F class C, C name 'Comics' X owned_by U, U login 'syt' X available true
+Person P WHERE P work_for P, S name 'Acme', P interested_by T, T name 'training'
+Note N WHERE N written_on D, D day> (today -10), N written_by P, P name 'joe' or P name 'jack'
+Person P WHERE (P interested_by T, T name 'training') or (P city 'Paris')
+Any N, P WHERE X is Person, X name N, X first_name P
+String N, P WHERE X is Person, X name N, X first_name P
+INSERT Person X: X name 'widget'
+INSERT Person X, Person Y: X name 'foo', Y name 'nice', X friend Y
+INSERT Person X: X name 'foo', X friend Y WHERE name 'nice'
+SET X name 'bar', X first_name 'original' where X is Person X name 'foo'
+SET X know Y WHERE X friend Y
+DELETE Person X WHERE X name 'foo'
+DELETE X friend Y WHERE X is Person, X name 'foo'
+Any X WHERE X name LIKE '%lt'
+Any X WHERE X name IN ( 'joe', 'jack', 'william', 'averell')
+Any X, V WHERE X concerns P, P eid 42, X corrected_in V?
+Any C, P WHERE C is Card, P? documented_by C
+Point P where P abs X, P ord Y, P value X+Y
+Document X where X class C, C name 'Cartoon', X owned_by U, U login 'joe', X available true
+(Any X WHERE X is Document) UNION (Any X WHERE X is File)
+Any A,B WHERE A creation_date B WITH A BEING (Any X WHERE X is Document) UNION (Any X WHERE X is File)
diff --git a/tests/examplefiles/scope.cirru b/tests/examplefiles/scope.cirru
new file mode 100644
index 00000000..728bcabf
--- /dev/null
+++ b/tests/examplefiles/scope.cirru
@@ -0,0 +1,43 @@
+
+-- https://github.com/Cirru/cirru-gopher/blob/master/code/scope.cr
+
+set a (int 2)
+
+print (self)
+
+set c (child)
+
+under c
+ under parent
+ print a
+
+print $ get c a
+
+set c x (int 3)
+print $ get c x
+
+set just-print $ code
+ print a
+
+print just-print
+
+eval (self) just-print
+eval just-print
+
+print (string "string with space")
+print (string "escapes \n \"\\")
+
+brackets ((((()))))
+
+"eval" $ string "eval"
+
+print (add $ (int 1) (int 2))
+
+print $ unwrap $
+ map (a $ int 1) (b $ int 2)
+
+print a
+ int 1
+ , b c
+ int 2
+ , d \ No newline at end of file
diff --git a/tests/examplefiles/sparql.rq b/tests/examplefiles/sparql.rq
new file mode 100644
index 00000000..caedfd14
--- /dev/null
+++ b/tests/examplefiles/sparql.rq
@@ -0,0 +1,23 @@
+# This is a test SPARQL query
+
+PREFIX foaf: <http://xmlns.com/foaf/0.1/>
+PREFIX ex: <http://example.org/>
+PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
+PREFIX dcterms: <http://purl.org/dc/terms/>
+
+SELECT ?person (COUNT(?nick) AS ?nickCount) {
+ ?person foaf:nick ?nick ;
+ foaf:lastName "Smith" ;
+ foaf:age "21"^^xsd:int ;
+ ex:title 'Mr' ; # single-quoted string
+ ex:height 1.80 ; # float
+ ex:distanceToSun +1.4e8 ; # float with exponent
+ ex:ownsACat true ;
+ dcterms:description "Someone with a cat called \"cat\"."@en .
+ OPTIONAL { ?person foaf:isPrimaryTopicOf ?page }
+ OPTIONAL { ?person foaf:name ?name
+ { ?person foaf:depiction ?img }
+ UNION
+ { ?person foaf:firstName ?firstN } }
+ FILTER ( bound(?page) || bound(?img) || bound(?firstN) )
+} GROUP BY ?person ORDER BY ?img
diff --git a/tests/examplefiles/test.R b/tests/examplefiles/test.R
index 54325339..1dd8f64b 100644
--- a/tests/examplefiles/test.R
+++ b/tests/examplefiles/test.R
@@ -33,10 +33,11 @@ NA_foo_ <- NULL
123456.78901
123e3
123E3
-1.23e-3
-1.23e3
-1.23e-3
-## integer constants
+6.02e23
+1.6e-35
+1.E12
+.1234
+## integers
123L
1.23L
## imaginary numbers
@@ -80,7 +81,7 @@ repeat {1+1}
## Switch
x <- 3
switch(x, 2+2, mean(1:10), rnorm(5))
-## Function, dot-dot-dot, return
+## Function, dot-dot-dot, return, sum
foo <- function(...) {
return(sum(...))
}
@@ -151,3 +152,34 @@ world!'
## Backtick strings
`foo123 +!"bar'baz` <- 2 + 2
+
+## Builtin funcitons
+file.create()
+gamma()
+grep()
+paste()
+rbind()
+rownames()
+R.Version()
+R.version.string()
+sample()
+sapply()
+save.image()
+seq()
+setwd()
+sin()
+
+## Data structures
+servo <- matrix(1:25, nrow = 5)
+numeric()
+vector(servo)
+data.frame()
+list1 <- list(time = 1:40)
+# multidimensional array
+array(c(c(c(2,300,4),c(8,9,0)),c(c(5,60,0),c(66,7,847))), dim=c(3,2,2))
+
+## Namespace
+library(ggplot2)
+require(plyr)
+attach(cars)
+source("test.R")
diff --git a/tests/examplefiles/test.apl b/tests/examplefiles/test.apl
new file mode 100644
index 00000000..26ecf971
--- /dev/null
+++ b/tests/examplefiles/test.apl
@@ -0,0 +1,26 @@
+∇ R←M COMBIN N;D;E;F;G;P
+ ⍝ Returns a matrix of every possible
+ ⍝ combination of M elements from the
+ ⍝ vector ⍳N. That is, returns a
+ ⍝ matrix with M!N rows and N columns.
+ ⍝
+ E←(⍳P←N-R←M-1)-⎕IO
+ D←R+⍳P
+ R←(P,1)⍴D
+ P←P⍴1
+ L1:→(⎕IO>1↑D←D-1)⍴0
+ P←+\P
+ G←+\¯1↓0,F←⌽P
+ E←F/E-G
+ R←(F/D),R[E+⍳⍴E;]
+ E←G
+ →L1
+∇
+
+∇ R←M QUICKEXP N
+ ⍝ Matrix exponentiation
+ B ← ⌊ 1 + 2 ⍟ N
+ V ← (B ⍴ 2) ⊤ N
+ L ← ⊂ M
+ R ← ⊃ +.× / V / L ⊣ { L ← (⊂ A +.× A ← ↑L) , L }¨ ⍳ B-1
+∇
diff --git a/tests/examplefiles/test.idr b/tests/examplefiles/test.idr
new file mode 100644
index 00000000..f0e96d88
--- /dev/null
+++ b/tests/examplefiles/test.idr
@@ -0,0 +1,93 @@
+module Main
+
+data Ty = TyInt | TyBool | TyFun Ty Ty
+
+interpTy : Ty -> Type
+interpTy TyInt = Int
+interpTy TyBool = Bool
+interpTy (TyFun s t) = interpTy s -> interpTy t
+
+using (G : Vect n Ty)
+
+ data Env : Vect n Ty -> Type where
+ Nil : Env Nil
+ (::) : interpTy a -> Env G -> Env (a :: G)
+
+ data HasType : (i : Fin n) -> Vect n Ty -> Ty -> Type where
+ stop : HasType fZ (t :: G) t
+ pop : HasType k G t -> HasType (fS k) (u :: G) t
+
+ lookup : HasType i G t -> Env G -> interpTy t
+ lookup stop (x :: xs) = x
+ lookup (pop k) (x :: xs) = lookup k xs
+
+ data Expr : Vect n Ty -> Ty -> Type where
+ Var : HasType i G t -> Expr G t
+ Val : (x : Int) -> Expr G TyInt
+ Lam : Expr (a :: G) t -> Expr G (TyFun a t)
+ App : Expr G (TyFun a t) -> Expr G a -> Expr G t
+ Op : (interpTy a -> interpTy b -> interpTy c) -> Expr G a -> Expr G b ->
+ Expr G c
+ If : Expr G TyBool -> Expr G a -> Expr G a -> Expr G a
+ Bind : Expr G a -> (interpTy a -> Expr G b) -> Expr G b
+
+ dsl expr
+ lambda = Lam
+ variable = Var
+ index_first = stop
+ index_next = pop
+
+ (<$>) : |(f : Expr G (TyFun a t)) -> Expr G a -> Expr G t
+ (<$>) = \f, a => App f a
+
+ pure : Expr G a -> Expr G a
+ pure = id
+
+ syntax IF [x] THEN [t] ELSE [e] = If x t e
+
+ (==) : Expr G TyInt -> Expr G TyInt -> Expr G TyBool
+ (==) = Op (==)
+
+ (<) : Expr G TyInt -> Expr G TyInt -> Expr G TyBool
+ (<) = Op (<)
+
+ instance Num (Expr G TyInt) where
+ (+) x y = Op (+) x y
+ (-) x y = Op (-) x y
+ (*) x y = Op (*) x y
+
+ abs x = IF (x < 0) THEN (-x) ELSE x
+
+ fromInteger = Val . fromInteger
+
+ interp : Env G -> {static} Expr G t -> interpTy t
+ interp env (Var i) = lookup i env
+ interp env (Val x) = x
+ interp env (Lam sc) = \x => interp (x :: env) sc
+ interp env (App f s) = (interp env f) (interp env s)
+ interp env (Op op x y) = op (interp env x) (interp env y)
+ interp env (If x t e) = if (interp env x) then (interp env t) else (interp env e)
+ interp env (Bind v f) = interp env (f (interp env v))
+
+ eId : Expr G (TyFun TyInt TyInt)
+ eId = expr (\x => x)
+
+ eTEST : Expr G (TyFun TyInt (TyFun TyInt TyInt))
+ eTEST = expr (\x, y => y)
+
+ eAdd : Expr G (TyFun TyInt (TyFun TyInt TyInt))
+ eAdd = expr (\x, y => Op (+) x y)
+
+ eDouble : Expr G (TyFun TyInt TyInt)
+ eDouble = expr (\x => App (App eAdd x) (Var stop))
+
+ eFac : Expr G (TyFun TyInt TyInt)
+ eFac = expr (\x => IF x == 0 THEN 1 ELSE [| eFac (x - 1) |] * x)
+
+testFac : Int
+testFac = interp [] eFac 4
+
+main : IO ()
+main = print testFac
+
+
diff --git a/tests/examplefiles/test.mask b/tests/examplefiles/test.mask
new file mode 100644
index 00000000..39134d74
--- /dev/null
+++ b/tests/examplefiles/test.mask
@@ -0,0 +1,41 @@
+
+// comment
+h4.class-1#id.class-2.other checked='true' disabled name = x param > 'Enter ..'
+input placeholder=Password type=password >
+ :dualbind x-signal='dom:create' value=user.passord;
+% each='flowers' >
+ div style='
+ position: absolute;
+ display: inline-block;
+ background: url("image.png") center center no-repeat;
+ ';
+#skippedDiv.other {
+ img src='~[url]';
+ div style="text-align:center;" {
+ '~[: $obj.foo("username", name) + 2]'
+ "~[Localize: stringId]"
+ }
+
+ p > """
+
+ Hello "world"
+ """
+
+ p > '
+ Hello "world"
+ '
+
+ p > "Hello 'world'"
+
+ :customComponent x-value='tt';
+ /* footer > '(c) 2014' */
+}
+
+.skippedDiv >
+ span >
+ #skipped >
+ table >
+ td >
+ tr > ';)'
+
+br; \ No newline at end of file
diff --git a/tests/examplefiles/test.php b/tests/examplefiles/test.php
index 97e21f73..218892fe 100644
--- a/tests/examplefiles/test.php
+++ b/tests/examplefiles/test.php
@@ -1,5 +1,7 @@
<?php
+$disapproval_ಠ_ಠ_of_php = 'unicode var';
+
$test = function($a) { $lambda = 1; }
/**
@@ -16,7 +18,7 @@ if(!defined('UNLOCK') || !UNLOCK)
// Load the parent archive class
require_once(ROOT_PATH.'/classes/archive.class.php');
-class Zip\Zipp {
+class Zip\Zippಠ_ಠ_ {
}
diff --git a/tests/examplefiles/test.pig b/tests/examplefiles/test.pig
new file mode 100644
index 00000000..f67b0268
--- /dev/null
+++ b/tests/examplefiles/test.pig
@@ -0,0 +1,148 @@
+/**
+ * This script is an example recommender (using made up data) showing how you might modify item-item links
+ * by defining similar relations between items in a dataset and customizing the change in weighting.
+ * This example creates metadata by using the genre field as the metadata_field. The items with
+ * the same genre have it's weight cut in half in order to boost the signals of movies that do not have the same genre.
+ * This technique requires a customization of the standard GetItemItemRecommendations macro
+ */
+import 'recommenders.pig';
+
+
+
+%default INPUT_PATH_PURCHASES '../data/retail/purchases.json'
+%default INPUT_PATH_WISHLIST '../data/retail/wishlists.json'
+%default INPUT_PATH_INVENTORY '../data/retail/inventory.json'
+%default OUTPUT_PATH '../data/retail/out/modify_item_item'
+
+
+/******** Custom GetItemItemRecommnedations *********/
+define recsys__GetItemItemRecommendations_ModifyCustom(user_item_signals, metadata) returns item_item_recs {
+
+ -- Convert user_item_signals to an item_item_graph
+ ii_links_raw, item_weights = recsys__BuildItemItemGraph(
+ $user_item_signals,
+ $LOGISTIC_PARAM,
+ $MIN_LINK_WEIGHT,
+ $MAX_LINKS_PER_USER
+ );
+ -- NOTE this function is added in order to combine metadata with item-item links
+ -- See macro for more detailed explination
+ ii_links_metadata = recsys__AddMetadataToItemItemLinks(
+ ii_links_raw,
+ $metadata
+ );
+
+ /********* Custom Code starts here ********/
+
+ --The code here should adjust the weights based on an item-item link and the equality of metadata.
+ -- In this case, if the metadata is the same, the weight is reduced. Otherwise the weight is left alone.
+ ii_links_adjusted = foreach ii_links_metadata generate item_A, item_B,
+ -- the amount of weight adjusted is dependant on the domain of data and what is expected
+ -- It is always best to adjust the weight by multiplying it by a factor rather than addition with a constant
+ (metadata_B == metadata_A ? (weight * 0.5): weight) as weight;
+
+
+ /******** Custom Code stops here *********/
+
+ -- remove negative numbers just incase
+ ii_links_adjusted_filt = foreach ii_links_adjusted generate item_A, item_B,
+ (weight <= 0 ? 0: weight) as weight;
+ -- Adjust the weights of the graph to improve recommendations.
+ ii_links = recsys__AdjustItemItemGraphWeight(
+ ii_links_adjusted_filt,
+ item_weights,
+ $BAYESIAN_PRIOR
+ );
+
+ -- Use the item-item graph to create item-item recommendations.
+ $item_item_recs = recsys__BuildItemItemRecommendationsFromGraph(
+ ii_links,
+ $NUM_RECS_PER_ITEM,
+ $NUM_RECS_PER_ITEM
+ );
+};
+
+
+/******* Load Data **********/
+
+--Get purchase signals
+purchase_input = load '$INPUT_PATH_PURCHASES' using org.apache.pig.piggybank.storage.JsonLoader(
+ 'row_id: int,
+ movie_id: chararray,
+ movie_name: chararray,
+ user_id: chararray,
+ purchase_price: int');
+
+--Get wishlist signals
+wishlist_input = load '$INPUT_PATH_WISHLIST' using org.apache.pig.piggybank.storage.JsonLoader(
+ 'row_id: int,
+ movie_id: chararray,
+ movie_name: chararray,
+ user_id: chararray');
+
+
+/******* Convert Data to Signals **********/
+
+-- Start with choosing 1 as max weight for a signal.
+purchase_signals = foreach purchase_input generate
+ user_id as user,
+ movie_name as item,
+ 1.0 as weight;
+
+
+-- Start with choosing 0.5 as weight for wishlist items because that is a weaker signal than
+-- purchasing an item.
+wishlist_signals = foreach wishlist_input generate
+ user_id as user,
+ movie_name as item,
+ 0.5 as weight;
+
+user_signals = union purchase_signals, wishlist_signals;
+
+
+/******** Changes for Modifying item-item links ******/
+inventory_input = load '$INPUT_PATH_INVENTORY' using org.apache.pig.piggybank.storage.JsonLoader(
+ 'movie_title: chararray,
+ genres: bag{tuple(content:chararray)}');
+
+
+metadata = foreach inventory_input generate
+ FLATTEN(genres) as metadata_field,
+ movie_title as item;
+-- requires the macro to be written seperately
+ --NOTE this macro is defined within this file for clarity
+item_item_recs = recsys__GetItemItemRecommendations_ModifyCustom(user_signals, metadata);
+/******* No more changes ********/
+
+
+user_item_recs = recsys__GetUserItemRecommendations(user_signals, item_item_recs);
+
+--Completely unrelated code stuck in the middle
+data = LOAD 's3n://my-s3-bucket/path/to/responses'
+ USING org.apache.pig.piggybank.storage.JsonLoader();
+responses = FOREACH data GENERATE object#'response' AS response: map[];
+out = FOREACH responses
+ GENERATE response#'id' AS id: int, response#'thread' AS thread: chararray,
+ response#'comments' AS comments: {t: (comment: chararray)};
+STORE out INTO 's3n://path/to/output' USING PigStorage('|');
+
+
+/******* Store recommendations **********/
+
+-- If your output folder exists already, hadoop will refuse to write data to it.
+
+rmf $OUTPUT_PATH/item_item_recs;
+rmf $OUTPUT_PATH/user_item_recs;
+
+store item_item_recs into '$OUTPUT_PATH/item_item_recs' using PigStorage();
+store user_item_recs into '$OUTPUT_PATH/user_item_recs' using PigStorage();
+
+-- STORE the item_item_recs into dynamo
+STORE item_item_recs
+ INTO '$OUTPUT_PATH/unused-ii-table-data'
+USING com.mortardata.pig.storage.DynamoDBStorage('$II_TABLE', '$AWS_ACCESS_KEY_ID', '$AWS_SECRET_ACCESS_KEY');
+
+-- STORE the user_item_recs into dynamo
+STORE user_item_recs
+ INTO '$OUTPUT_PATH/unused-ui-table-data'
+USING com.mortardata.pig.storage.DynamoDBStorage('$UI_TABLE', '$AWS_ACCESS_KEY_ID', '$AWS_SECRET_ACCESS_KEY');
diff --git a/tests/examplefiles/test.pwn b/tests/examplefiles/test.pwn
new file mode 100644
index 00000000..d6468617
--- /dev/null
+++ b/tests/examplefiles/test.pwn
@@ -0,0 +1,253 @@
+#include <core>
+
+// Single line comment
+/* Multi line
+ comment */
+
+/// documentation
+/**
+
+ documentation multi line
+
+**/
+
+public OnGameModeInit() {
+ printf("Hello, World!");
+}
+
+enum info {
+ Float:ex;
+ exa,
+ exam[5],
+}
+new arr[5][info];
+
+stock Float:test_func()
+{
+ new a = 5, Float:b = 10.3;
+ if (a == b) {
+
+ } else {
+
+ }
+
+ for (new i = 0; i < 10; i++) {
+ continue;
+ }
+
+ do {
+ a--;
+ } while (a > 0);
+
+ while (a < 5) {
+ a++;
+ break;
+ }
+
+ switch (a) {
+ case 0: {
+ }
+ case 0..4: {
+ }
+ case 5, 6: {
+ }
+ }
+
+ static x;
+ new xx = a > 5 ? 5 : 0;
+ new array[sizeof arr] = {0};
+ tagof a;
+ state a;
+ goto label;
+ new byte[2 char];
+ byte{0} = 'a';
+
+ return (float(a) + b);
+}
+
+
+// float.inc
+/* Float arithmetic
+ *
+ * (c) Copyright 1999, Artran, Inc.
+ * Written by Greg Garner (gmg@artran.com)
+ * Modified in March 2001 to include user defined
+ * operators for the floating point functions.
+ *
+ * This file is provided as is (no warranties).
+ */
+#if defined _Float_included
+ #endinput
+#endif
+#define _Float_included
+#pragma library Float
+
+/* Different methods of rounding */
+enum floatround_method {
+ floatround_round,
+ floatround_floor,
+ floatround_ceil,
+ floatround_tozero,
+ floatround_unbiased
+}
+enum anglemode {
+ radian,
+ degrees,
+ grades
+}
+
+/**************************************************/
+/* Convert an integer into a floating point value */
+native Float:float(value);
+
+/**************************************************/
+/* Convert a string into a floating point value */
+native Float:floatstr(const string[]);
+
+/**************************************************/
+/* Multiple two floats together */
+native Float:floatmul(Float:oper1, Float:oper2);
+
+/**************************************************/
+/* Divide the dividend float by the divisor float */
+native Float:floatdiv(Float:dividend, Float:divisor);
+
+/**************************************************/
+/* Add two floats together */
+native Float:floatadd(Float:oper1, Float:oper2);
+
+/**************************************************/
+/* Subtract oper2 float from oper1 float */
+native Float:floatsub(Float:oper1, Float:oper2);
+
+/**************************************************/
+/* Return the fractional part of a float */
+native Float:floatfract(Float:value);
+
+/**************************************************/
+/* Round a float into a integer value */
+native floatround(Float:value, floatround_method:method=floatround_round);
+
+/**************************************************/
+/* Compare two integers. If the two elements are equal, return 0.
+ If the first argument is greater than the second argument, return 1,
+ If the first argument is less than the second argument, return -1. */
+native floatcmp(Float:oper1, Float:oper2);
+
+/**************************************************/
+/* Return the square root of the input value, same as floatpower(value, 0.5) */
+native Float:floatsqroot(Float:value);
+
+/**************************************************/
+/* Return the value raised to the power of the exponent */
+native Float:floatpower(Float:value, Float:exponent);
+
+/**************************************************/
+/* Return the logarithm */
+native Float:floatlog(Float:value, Float:base=10.0);
+
+/**************************************************/
+/* Return the sine, cosine or tangent. The input angle may be in radian,
+ degrees or grades. */
+native Float:floatsin(Float:value, anglemode:mode=radian);
+native Float:floatcos(Float:value, anglemode:mode=radian);
+native Float:floattan(Float:value, anglemode:mode=radian);
+
+/**************************************************/
+/* Return the absolute value */
+native Float:floatabs(Float:value);
+
+
+/**************************************************/
+#pragma rational Float
+
+/* user defined operators */
+native Float:operator*(Float:oper1, Float:oper2) = floatmul;
+native Float:operator/(Float:oper1, Float:oper2) = floatdiv;
+native Float:operator+(Float:oper1, Float:oper2) = floatadd;
+native Float:operator-(Float:oper1, Float:oper2) = floatsub;
+native Float:operator=(oper) = float;
+
+stock Float:operator++(Float:oper)
+ return oper+1.0;
+
+stock Float:operator--(Float:oper)
+ return oper-1.0;
+
+stock Float:operator-(Float:oper)
+ return oper^Float:cellmin; /* IEEE values are sign/magnitude */
+
+stock Float:operator*(Float:oper1, oper2)
+ return floatmul(oper1, float(oper2)); /* "*" is commutative */
+
+stock Float:operator/(Float:oper1, oper2)
+ return floatdiv(oper1, float(oper2));
+
+stock Float:operator/(oper1, Float:oper2)
+ return floatdiv(float(oper1), oper2);
+
+stock Float:operator+(Float:oper1, oper2)
+ return floatadd(oper1, float(oper2)); /* "+" is commutative */
+
+stock Float:operator-(Float:oper1, oper2)
+ return floatsub(oper1, float(oper2));
+
+stock Float:operator-(oper1, Float:oper2)
+ return floatsub(float(oper1), oper2);
+
+stock bool:operator==(Float:oper1, Float:oper2)
+ return floatcmp(oper1, oper2) == 0;
+
+stock bool:operator==(Float:oper1, oper2)
+ return floatcmp(oper1, float(oper2)) == 0; /* "==" is commutative */
+
+stock bool:operator!=(Float:oper1, Float:oper2)
+ return floatcmp(oper1, oper2) != 0;
+
+stock bool:operator!=(Float:oper1, oper2)
+ return floatcmp(oper1, float(oper2)) != 0; /* "!=" is commutative */
+
+stock bool:operator>(Float:oper1, Float:oper2)
+ return floatcmp(oper1, oper2) > 0;
+
+stock bool:operator>(Float:oper1, oper2)
+ return floatcmp(oper1, float(oper2)) > 0;
+
+stock bool:operator>(oper1, Float:oper2)
+ return floatcmp(float(oper1), oper2) > 0;
+
+stock bool:operator>=(Float:oper1, Float:oper2)
+ return floatcmp(oper1, oper2) >= 0;
+
+stock bool:operator>=(Float:oper1, oper2)
+ return floatcmp(oper1, float(oper2)) >= 0;
+
+stock bool:operator>=(oper1, Float:oper2)
+ return floatcmp(float(oper1), oper2) >= 0;
+
+stock bool:operator<(Float:oper1, Float:oper2)
+ return floatcmp(oper1, oper2) < 0;
+
+stock bool:operator<(Float:oper1, oper2)
+ return floatcmp(oper1, float(oper2)) < 0;
+
+stock bool:operator<(oper1, Float:oper2)
+ return floatcmp(float(oper1), oper2) < 0;
+
+stock bool:operator<=(Float:oper1, Float:oper2)
+ return floatcmp(oper1, oper2) <= 0;
+
+stock bool:operator<=(Float:oper1, oper2)
+ return floatcmp(oper1, float(oper2)) <= 0;
+
+stock bool:operator<=(oper1, Float:oper2)
+ return floatcmp(float(oper1), oper2) <= 0;
+
+stock bool:operator!(Float:oper)
+ return (_:oper & cellmax) == 0;
+
+/* forbidden operations */
+forward operator%(Float:oper1, Float:oper2);
+forward operator%(Float:oper1, oper2);
+forward operator%(oper1, Float:oper2);
+
diff --git a/tests/examplefiles/test.zep b/tests/examplefiles/test.zep
new file mode 100644
index 00000000..4724d4c4
--- /dev/null
+++ b/tests/examplefiles/test.zep
@@ -0,0 +1,33 @@
+namespace Test;
+
+use Test\Foo;
+
+class Bar
+{
+ protected a;
+ private b;
+ public c {set, get};
+
+ public function __construct(string str, boolean bool)
+ {
+ let this->c = str;
+ this->setC(bool);
+ let this->b = [];
+ }
+
+ public function sayHello(string name)
+ {
+ echo "Hello " . name;
+ }
+
+ protected function loops()
+ {
+ for a in b {
+ echo a;
+ }
+ loop {
+ return "boo!";
+ }
+ }
+
+} \ No newline at end of file
diff --git a/tests/examplefiles/test.bas b/tests/examplefiles/vbnet_test.bas
index af5f2574..af5f2574 100644
--- a/tests/examplefiles/test.bas
+++ b/tests/examplefiles/vbnet_test.bas
diff --git a/tests/examplefiles/vctreestatus_hg b/tests/examplefiles/vctreestatus_hg
new file mode 100644
index 00000000..193ed803
--- /dev/null
+++ b/tests/examplefiles/vctreestatus_hg
@@ -0,0 +1,4 @@
+M LICENSE
+M setup.py
+! setup.cfg
+? vctreestatus_hg
diff --git a/tests/old_run.py b/tests/old_run.py
deleted file mode 100644
index 4f7cef16..00000000
--- a/tests/old_run.py
+++ /dev/null
@@ -1,138 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- Pygments unit tests
- ~~~~~~~~~~~~~~~~~~
-
- Usage::
-
- python run.py [testfile ...]
-
-
- :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
- :license: BSD, see LICENSE for details.
-"""
-
-import sys, os
-import unittest
-
-from os.path import dirname, basename, join, abspath
-
-import pygments
-
-try:
- import coverage
-except ImportError:
- coverage = None
-
-testdir = abspath(dirname(__file__))
-
-failed = []
-total_test_count = 0
-error_test_count = 0
-
-
-def err(file, what, exc):
- print >>sys.stderr, file, 'failed %s:' % what,
- print >>sys.stderr, exc
- failed.append(file[:-3])
-
-
-class QuietTestRunner(object):
- """Customized test runner for relatively quiet output"""
-
- def __init__(self, testname, stream=sys.stderr):
- self.testname = testname
- self.stream = unittest._WritelnDecorator(stream)
-
- def run(self, test):
- global total_test_count
- global error_test_count
- result = unittest._TextTestResult(self.stream, True, 1)
- test(result)
- if not result.wasSuccessful():
- self.stream.write(' FAIL:')
- result.printErrors()
- failed.append(self.testname)
- else:
- self.stream.write(' ok\n')
- total_test_count += result.testsRun
- error_test_count += len(result.errors) + len(result.failures)
- return result
-
-
-def run_tests(with_coverage=False):
- # needed to avoid confusion involving atexit handlers
- import logging
-
- if sys.argv[1:]:
- # test only files given on cmdline
- files = [entry + '.py' for entry in sys.argv[1:] if entry.startswith('test_')]
- else:
- files = [entry for entry in os.listdir(testdir)
- if (entry.startswith('test_') and entry.endswith('.py'))]
- files.sort()
-
- WIDTH = 85
-
- print >>sys.stderr, \
- ('Pygments %s Test Suite running%s, stand by...' %
- (pygments.__version__,
- with_coverage and " with coverage analysis" or "")).center(WIDTH)
- print >>sys.stderr, ('(using Python %s)' % sys.version.split()[0]).center(WIDTH)
- print >>sys.stderr, '='*WIDTH
-
- if with_coverage:
- coverage.erase()
- coverage.start()
-
- for testfile in files:
- globs = {'__file__': join(testdir, testfile)}
- try:
- execfile(join(testdir, testfile), globs)
- except Exception, exc:
- raise
- err(testfile, 'execfile', exc)
- continue
- sys.stderr.write(testfile[:-3] + ': ')
- try:
- runner = QuietTestRunner(testfile[:-3])
- # make a test suite of all TestCases in the file
- tests = []
- for name, thing in globs.iteritems():
- if name.endswith('Test'):
- tests.append((name, unittest.makeSuite(thing)))
- tests.sort()
- suite = unittest.TestSuite()
- suite.addTests([x[1] for x in tests])
- runner.run(suite)
- except Exception, exc:
- err(testfile, 'running test', exc)
-
- print >>sys.stderr, '='*WIDTH
- if failed:
- print >>sys.stderr, '%d of %d tests failed.' % \
- (error_test_count, total_test_count)
- print >>sys.stderr, 'Tests failed in:', ', '.join(failed)
- ret = 1
- else:
- if total_test_count == 1:
- print >>sys.stderr, '1 test happy.'
- else:
- print >>sys.stderr, 'All %d tests happy.' % total_test_count
- ret = 0
-
- if with_coverage:
- coverage.stop()
- modules = [mod for name, mod in sys.modules.iteritems()
- if name.startswith('pygments.') and mod]
- coverage.report(modules)
-
- return ret
-
-
-if __name__ == '__main__':
- with_coverage = False
- if sys.argv[1:2] == ['-C']:
- with_coverage = bool(coverage)
- del sys.argv[1]
- sys.exit(run_tests(with_coverage))
diff --git a/tests/run.py b/tests/run.py
index 18a1d824..e87837e5 100644
--- a/tests/run.py
+++ b/tests/run.py
@@ -8,42 +8,37 @@
python run.py [testfile ...]
- :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
+from __future__ import print_function
+
import sys, os
-if sys.version_info >= (3,):
- # copy test suite over to "build/lib" and convert it
- print ('Copying and converting sources to build/lib/test...')
- from distutils.util import copydir_run_2to3
- testroot = os.path.dirname(__file__)
- newroot = os.path.join(testroot, '..', 'build/lib/test')
- copydir_run_2to3(testroot, newroot)
- # make nose believe that we run from the converted dir
- os.chdir(newroot)
-else:
- # only find tests in this directory
- if os.path.dirname(__file__):
- os.chdir(os.path.dirname(__file__))
+# only find tests in this directory
+if os.path.dirname(__file__):
+ os.chdir(os.path.dirname(__file__))
try:
import nose
except ImportError:
- print ('nose is required to run the Pygments test suite')
+ print('nose is required to run the Pygments test suite')
sys.exit(1)
try:
# make sure the current source is first on sys.path
sys.path.insert(0, '..')
import pygments
-except ImportError:
- print ('Cannot find Pygments to test: %s' % sys.exc_info()[1])
+except SyntaxError as err:
+ print('Syntax error: %s' % err)
+ sys.exit(1)
+except ImportError as err:
+ print('Cannot find Pygments to test: %s' % err)
sys.exit(1)
else:
- print ('Pygments %s test suite running (Python %s)...' %
- (pygments.__version__, sys.version.split()[0]))
+ print('Pygments %s test suite running (Python %s)...' %
+ (pygments.__version__, sys.version.split()[0]))
nose.main()
diff --git a/tests/test_basic_api.py b/tests/test_basic_api.py
index 18ed8d64..be7a4747 100644
--- a/tests/test_basic_api.py
+++ b/tests/test_basic_api.py
@@ -3,11 +3,12 @@
Pygments basic API tests
~~~~~~~~~~~~~~~~~~~~~~~~
- :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
-import os
+from __future__ import print_function
+
import random
import unittest
@@ -15,7 +16,7 @@ from pygments import lexers, formatters, filters, format
from pygments.token import _TokenType, Text
from pygments.lexer import RegexLexer
from pygments.formatters.img import FontNotFound
-from pygments.util import BytesIO, StringIO, bytes, b
+from pygments.util import text_type, StringIO, xrange, ClassNotFound
import support
@@ -28,7 +29,7 @@ test_content = ''.join(test_content) + '\n'
def test_lexer_import_all():
# instantiate every lexer, to see if the token type defs are correct
- for x in lexers.LEXERS.keys():
+ for x in lexers.LEXERS:
c = getattr(lexers, x)()
@@ -45,6 +46,8 @@ def test_lexer_classes():
result = cls.analyse_text(".abc")
assert isinstance(result, float) and 0.0 <= result <= 1.0
+ assert all(al.lower() == al for al in cls.aliases)
+
inst = cls(opt1="val1", opt2="val2")
if issubclass(cls, RegexLexer):
if not hasattr(cls, '_tokens'):
@@ -60,14 +63,17 @@ def test_lexer_classes():
if cls.name in ['XQuery', 'Opa']: # XXX temporary
return
- tokens = list(inst.get_tokens(test_content))
+ try:
+ tokens = list(inst.get_tokens(test_content))
+ except KeyboardInterrupt:
+ raise KeyboardInterrupt('interrupted %s.get_tokens(): test_content=%r' % (cls.__name__, test_content))
txt = ""
for token in tokens:
assert isinstance(token, tuple)
assert isinstance(token[0], _TokenType)
if isinstance(token[1], str):
- print repr(token[1])
- assert isinstance(token[1], unicode)
+ print(repr(token[1]))
+ assert isinstance(token[1], text_type)
txt += token[1]
assert txt == test_content, "%s lexer roundtrip failed: %r != %r" % \
(cls.name, test_content, txt)
@@ -94,7 +100,8 @@ def test_lexer_options():
'SqliteConsoleLexer', 'MatlabSessionLexer', 'ErlangShellLexer',
'BashSessionLexer', 'LiterateHaskellLexer', 'LiterateAgdaLexer',
'PostgresConsoleLexer', 'ElixirConsoleLexer', 'JuliaConsoleLexer',
- 'RobotFrameworkLexer', 'DylanConsoleLexer', 'ShellSessionLexer'):
+ 'RobotFrameworkLexer', 'DylanConsoleLexer', 'ShellSessionLexer',
+ 'LiterateIdrisLexer'):
inst = cls(ensurenl=False)
ensure(inst.get_tokens('a\nb'), 'a\nb')
inst = cls(ensurenl=False, stripall=True)
@@ -122,7 +129,7 @@ def test_get_lexers():
]:
yield verify, func, args
- for cls, (_, lname, aliases, _, mimetypes) in lexers.LEXERS.iteritems():
+ for cls, (_, lname, aliases, _, mimetypes) in lexers.LEXERS.items():
assert cls == lexers.find_lexer_class(lname).__name__
for alias in aliases:
@@ -131,6 +138,13 @@ def test_get_lexers():
for mimetype in mimetypes:
assert cls == lexers.get_lexer_for_mimetype(mimetype).__class__.__name__
+ try:
+ lexers.get_lexer_by_name(None)
+ except ClassNotFound:
+ pass
+ else:
+ raise Exception
+
def test_formatter_public_api():
ts = list(lexers.PythonLexer().get_tokens("def f(): pass"))
@@ -157,7 +171,7 @@ def test_formatter_public_api():
pass
inst.format(ts, out)
- for formatter, info in formatters.FORMATTERS.iteritems():
+ for formatter, info in formatters.FORMATTERS.items():
yield verify, formatter, info
def test_formatter_encodings():
@@ -167,7 +181,7 @@ def test_formatter_encodings():
fmt = HtmlFormatter()
tokens = [(Text, u"ä")]
out = format(tokens, fmt)
- assert type(out) is unicode
+ assert type(out) is text_type
assert u"ä" in out
# encoding option
@@ -196,7 +210,7 @@ def test_formatter_unicode_handling():
if formatter.name != 'Raw tokens':
out = format(tokens, inst)
if formatter.unicodeoutput:
- assert type(out) is unicode
+ assert type(out) is text_type
inst = formatter(encoding='utf-8')
out = format(tokens, inst)
@@ -208,7 +222,7 @@ def test_formatter_unicode_handling():
out = format(tokens, inst)
assert type(out) is bytes, '%s: %r' % (formatter, out)
- for formatter, info in formatters.FORMATTERS.iteritems():
+ for formatter, info in formatters.FORMATTERS.items():
yield verify, formatter
@@ -236,7 +250,7 @@ class FiltersTest(unittest.TestCase):
'whitespace': {'spaces': True, 'tabs': True, 'newlines': True},
'highlight': {'names': ['isinstance', 'lexers', 'x']},
}
- for x in filters.FILTERS.keys():
+ for x in filters.FILTERS:
lx = lexers.PythonLexer()
lx.add_filter(x, **filter_args.get(x, {}))
fp = open(TESTFILE, 'rb')
diff --git a/tests/test_clexer.py b/tests/test_clexer.py
index 8b37bf57..c995bb2b 100644
--- a/tests/test_clexer.py
+++ b/tests/test_clexer.py
@@ -3,7 +3,7 @@
Basic CLexer Test
~~~~~~~~~~~~~~~~~
- :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/tests/test_cmdline.py b/tests/test_cmdline.py
index 5ad815c0..ef14661c 100644
--- a/tests/test_cmdline.py
+++ b/tests/test_cmdline.py
@@ -3,17 +3,18 @@
Command line test
~~~~~~~~~~~~~~~~~
- :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
# Test the command line interface
-import sys, os
+import io
+import sys
import unittest
-import StringIO
from pygments import highlight
+from pygments.util import StringIO
from pygments.cmdline import main as cmdline_main
import support
@@ -24,8 +25,8 @@ TESTFILE, TESTDIR = support.location(__file__)
def run_cmdline(*args):
saved_stdout = sys.stdout
saved_stderr = sys.stderr
- new_stdout = sys.stdout = StringIO.StringIO()
- new_stderr = sys.stderr = StringIO.StringIO()
+ new_stdout = sys.stdout = StringIO()
+ new_stderr = sys.stderr = StringIO()
try:
ret = cmdline_main(["pygmentize"] + list(args))
finally:
diff --git a/tests/test_examplefiles.py b/tests/test_examplefiles.py
index d785cf3b..0547ffd3 100644
--- a/tests/test_examplefiles.py
+++ b/tests/test_examplefiles.py
@@ -3,18 +3,20 @@
Pygments tests with example files
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
+from __future__ import print_function
+
import os
import pprint
import difflib
-import cPickle as pickle
+import pickle
from pygments.lexers import get_lexer_for_filename, get_lexer_by_name
from pygments.token import Error
-from pygments.util import ClassNotFound, b
+from pygments.util import ClassNotFound
STORE_OUTPUT = False
@@ -31,21 +33,30 @@ def test_example_files():
absfn = os.path.join(testdir, 'examplefiles', fn)
if not os.path.isfile(absfn):
continue
- outfn = os.path.join(outdir, fn)
+ print(absfn)
+ code = open(absfn, 'rb').read()
try:
- lx = get_lexer_for_filename(absfn)
- except ClassNotFound:
- if "_" not in fn:
+ code = code.decode('utf-8')
+ except UnicodeError:
+ code = code.decode('latin1')
+
+ outfn = os.path.join(outdir, fn)
+
+ lx = None
+ if '_' in fn:
+ try:
+ lx = get_lexer_by_name(fn.split('_')[0])
+ except ClassNotFound:
+ pass
+ if lx is None:
+ try:
+ lx = get_lexer_for_filename(absfn, code=code)
+ except ClassNotFound:
raise AssertionError('file %r has no registered extension, '
'nor is of the form <lexer>_filename '
'for overriding, thus no lexer found.'
- % fn)
- try:
- name, rest = fn.split("_", 1)
- lx = get_lexer_by_name(name)
- except ClassNotFound:
- raise AssertionError('no lexer found for file %r' % fn)
+ % fn)
yield check_lexer, lx, absfn, outfn
def check_lexer(lx, absfn, outfn):
@@ -54,8 +65,8 @@ def check_lexer(lx, absfn, outfn):
text = fp.read()
finally:
fp.close()
- text = text.replace(b('\r\n'), b('\n'))
- text = text.strip(b('\n')) + b('\n')
+ text = text.replace(b'\r\n', b'\n')
+ text = text.strip(b'\n') + b'\n'
try:
text = text.decode('utf-8')
if text.startswith(u'\ufeff'):
@@ -71,8 +82,8 @@ def check_lexer(lx, absfn, outfn):
(lx, absfn, val, len(u''.join(ntext)))
tokens.append((type, val))
if u''.join(ntext) != text:
- print '\n'.join(difflib.unified_diff(u''.join(ntext).splitlines(),
- text.splitlines()))
+ print('\n'.join(difflib.unified_diff(u''.join(ntext).splitlines(),
+ text.splitlines())))
raise AssertionError('round trip failed for ' + absfn)
# check output against previous run if enabled
@@ -94,6 +105,6 @@ def check_lexer(lx, absfn, outfn):
if stored_tokens != tokens:
f1 = pprint.pformat(stored_tokens)
f2 = pprint.pformat(tokens)
- print '\n'.join(difflib.unified_diff(f1.splitlines(),
- f2.splitlines()))
+ print('\n'.join(difflib.unified_diff(f1.splitlines(),
+ f2.splitlines())))
assert False, absfn
diff --git a/tests/test_html_formatter.py b/tests/test_html_formatter.py
index f7e7a542..91225cd3 100644
--- a/tests/test_html_formatter.py
+++ b/tests/test_html_formatter.py
@@ -3,27 +3,29 @@
Pygments HTML formatter tests
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
+from __future__ import print_function
+
+import io
import os
import re
import unittest
-import StringIO
import tempfile
from os.path import join, dirname, isfile
+from pygments.util import StringIO
from pygments.lexers import PythonLexer
from pygments.formatters import HtmlFormatter, NullFormatter
from pygments.formatters.html import escape_html
-from pygments.util import uni_open
import support
TESTFILE, TESTDIR = support.location(__file__)
-fp = uni_open(TESTFILE, encoding='utf-8')
+fp = io.open(TESTFILE, encoding='utf-8')
try:
tokensource = list(PythonLexer().get_tokens(fp.read()))
finally:
@@ -33,11 +35,11 @@ finally:
class HtmlFormatterTest(unittest.TestCase):
def test_correct_output(self):
hfmt = HtmlFormatter(nowrap=True)
- houtfile = StringIO.StringIO()
+ houtfile = StringIO()
hfmt.format(tokensource, houtfile)
nfmt = NullFormatter()
- noutfile = StringIO.StringIO()
+ noutfile = StringIO()
nfmt.format(tokensource, noutfile)
stripped_html = re.sub('<.*?>', '', houtfile.getvalue())
@@ -74,13 +76,13 @@ class HtmlFormatterTest(unittest.TestCase):
dict(linenos=True, full=True),
dict(linenos=True, full=True, noclasses=True)]:
- outfile = StringIO.StringIO()
+ outfile = StringIO()
fmt = HtmlFormatter(**optdict)
fmt.format(tokensource, outfile)
def test_linenos(self):
optdict = dict(linenos=True)
- outfile = StringIO.StringIO()
+ outfile = StringIO()
fmt = HtmlFormatter(**optdict)
fmt.format(tokensource, outfile)
html = outfile.getvalue()
@@ -88,7 +90,7 @@ class HtmlFormatterTest(unittest.TestCase):
def test_linenos_with_startnum(self):
optdict = dict(linenos=True, linenostart=5)
- outfile = StringIO.StringIO()
+ outfile = StringIO()
fmt = HtmlFormatter(**optdict)
fmt.format(tokensource, outfile)
html = outfile.getvalue()
@@ -96,7 +98,7 @@ class HtmlFormatterTest(unittest.TestCase):
def test_lineanchors(self):
optdict = dict(lineanchors="foo")
- outfile = StringIO.StringIO()
+ outfile = StringIO()
fmt = HtmlFormatter(**optdict)
fmt.format(tokensource, outfile)
html = outfile.getvalue()
@@ -104,7 +106,7 @@ class HtmlFormatterTest(unittest.TestCase):
def test_lineanchors_with_startnum(self):
optdict = dict(lineanchors="foo", linenostart=5)
- outfile = StringIO.StringIO()
+ outfile = StringIO()
fmt = HtmlFormatter(**optdict)
fmt.format(tokensource, outfile)
html = outfile.getvalue()
@@ -132,7 +134,7 @@ class HtmlFormatterTest(unittest.TestCase):
pass
else:
if ret:
- print output
+ print(output)
self.assertFalse(ret, 'nsgmls run reported errors')
os.unlink(pathname)
@@ -172,7 +174,7 @@ class HtmlFormatterTest(unittest.TestCase):
# anymore in the actual source
fmt = HtmlFormatter(tagsfile='support/tags', lineanchors='L',
tagurlformat='%(fname)s%(fext)s')
- outfile = StringIO.StringIO()
+ outfile = StringIO()
fmt.format(tokensource, outfile)
self.assertTrue('<a href="test_html_formatter.py#L-165">test_ctags</a>'
in outfile.getvalue())
diff --git a/tests/test_latex_formatter.py b/tests/test_latex_formatter.py
index 06a74c3d..13ae87cd 100644
--- a/tests/test_latex_formatter.py
+++ b/tests/test_latex_formatter.py
@@ -3,10 +3,12 @@
Pygments LaTeX formatter tests
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
+from __future__ import print_function
+
import os
import unittest
import tempfile
@@ -48,7 +50,7 @@ class LatexFormatterTest(unittest.TestCase):
pass
else:
if ret:
- print output
+ print(output)
self.assertFalse(ret, 'latex run reported errors')
os.unlink(pathname)
diff --git a/tests/test_lexers_other.py b/tests/test_lexers_other.py
index d3cfa246..1e420c77 100644
--- a/tests/test_lexers_other.py
+++ b/tests/test_lexers_other.py
@@ -3,7 +3,7 @@
Tests for other lexers
~~~~~~~~~~~~~~~~~~~~~~
- :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
@@ -28,7 +28,7 @@ class AnalyseTextTest(unittest.TestCase):
for exampleFilePath in glob.glob(exampleFilesPattern):
exampleFile = open(exampleFilePath, 'rb')
try:
- text = exampleFile.read()
+ text = exampleFile.read().decode('utf-8')
probability = lexer.analyse_text(text)
self.assertTrue(probability > 0,
'%s must recognize %r' % (
diff --git a/tests/test_perllexer.py b/tests/test_perllexer.py
index 315b20e3..bfa3aeb8 100644
--- a/tests/test_perllexer.py
+++ b/tests/test_perllexer.py
@@ -3,7 +3,7 @@
Pygments regex lexer tests
~~~~~~~~~~~~~~~~~~~~~~~~~~
- :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/tests/test_regexlexer.py b/tests/test_regexlexer.py
index 28d9689b..b12dce0a 100644
--- a/tests/test_regexlexer.py
+++ b/tests/test_regexlexer.py
@@ -3,7 +3,7 @@
Pygments regex lexer tests
~~~~~~~~~~~~~~~~~~~~~~~~~~
- :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/tests/test_token.py b/tests/test_token.py
index 6a5b00b7..c5cc4990 100644
--- a/tests/test_token.py
+++ b/tests/test_token.py
@@ -3,7 +3,7 @@
Test suite for the token module
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
@@ -36,11 +36,11 @@ class TokenTest(unittest.TestCase):
stp = token.STANDARD_TYPES.copy()
stp[token.Token] = '---' # Token and Text do conflict, that is okay
t = {}
- for k, v in stp.iteritems():
+ for k, v in stp.items():
t.setdefault(v, []).append(k)
if len(t) == len(stp):
return # Okay
- for k, v in t.iteritems():
+ for k, v in t.items():
if len(v) > 1:
self.fail("%r has more than one key: %r" % (k, v))
diff --git a/tests/test_using_api.py b/tests/test_using_api.py
index bb89d1e2..9e53c206 100644
--- a/tests/test_using_api.py
+++ b/tests/test_using_api.py
@@ -3,7 +3,7 @@
Pygments tests for using()
~~~~~~~~~~~~~~~~~~~~~~~~~~
- :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/tests/test_util.py b/tests/test_util.py
index dbbc66ce..59ecf14f 100644
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -3,7 +3,7 @@
Test suite for the util module
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""