Mercurial Hosting > luan
annotate scripts/test.luan @ 1248:475905984870
improve lucene highlighter and allow bbcode_to_text quoter to be nil
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 18 Jul 2018 01:38:53 -0600 |
parents | 0f2890e2ba16 |
children | bcb39089e899 |
rev | line source |
---|---|
693
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
563
diff
changeset
|
1 local Binary = require "luan:Binary.luan" |
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
563
diff
changeset
|
2 local Html = require "luan:Html.luan" |
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
563
diff
changeset
|
3 local Io = require "luan:Io.luan" |
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
563
diff
changeset
|
4 local Luan = require "luan:Luan.luan" |
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
563
diff
changeset
|
5 local Math = require "luan:Math.luan" |
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
563
diff
changeset
|
6 local Package = require "luan:Package.luan" |
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
563
diff
changeset
|
7 local String = require "luan:String.luan" |
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
563
diff
changeset
|
8 local Table = require "luan:Table.luan" |
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
563
diff
changeset
|
9 local Thread = require "luan:Thread.luan" |
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
563
diff
changeset
|
10 local Time = require "luan:Time.luan" |
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
563
diff
changeset
|
11 local Hosting = require "luan:host/Hosting.luan" |
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
563
diff
changeset
|
12 local Http = require "luan:http/Http.luan" |
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
563
diff
changeset
|
13 local Http_test = require "luan:http/Http_test.luan" |
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
563
diff
changeset
|
14 local Server = require "luan:http/Server.luan" |
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
563
diff
changeset
|
15 local Lucene = require "luan:lucene/Lucene.luan" |
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
563
diff
changeset
|
16 local Versioning = require "luan:lucene/Versioning.luan" |
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
563
diff
changeset
|
17 local Mail = require "luan:mail/Mail.luan" |
503 | 18 |
497
55f9f74f1e55
Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
495
diff
changeset
|
19 local error = Luan.error |
554
18504c41b0be
move debug() to Io and remove Debug module;
Franklin Schmidt <fschmidt@gmail.com>
parents:
548
diff
changeset
|
20 local range = Luan.range or error() |
18504c41b0be
move debug() to Io and remove Debug module;
Franklin Schmidt <fschmidt@gmail.com>
parents:
548
diff
changeset
|
21 local trim = String.trim or error() |
18504c41b0be
move debug() to Io and remove Debug module;
Franklin Schmidt <fschmidt@gmail.com>
parents:
548
diff
changeset
|
22 local find = String.find or error() |
18504c41b0be
move debug() to Io and remove Debug module;
Franklin Schmidt <fschmidt@gmail.com>
parents:
548
diff
changeset
|
23 local init = Http_test.init or error() |
18504c41b0be
move debug() to Io and remove Debug module;
Franklin Schmidt <fschmidt@gmail.com>
parents:
548
diff
changeset
|
24 local get_page = Http_test.get_page or error() |
693
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
563
diff
changeset
|
25 local Ab_testing = require "luan:lucene/Ab_testing.luan" |
323
cd2924a1052c
improve testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
321
diff
changeset
|
26 |
cd2924a1052c
improve testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
321
diff
changeset
|
27 |
cd2924a1052c
improve testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
321
diff
changeset
|
28 local function print(...) |
cd2924a1052c
improve testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
321
diff
changeset
|
29 Io.print_to(Io.stderr,...) |
cd2924a1052c
improve testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
321
diff
changeset
|
30 end |
cd2924a1052c
improve testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
321
diff
changeset
|
31 |
693
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
563
diff
changeset
|
32 function Io.schemes.site(path) |
797 | 33 return Io.uri( "luan:http/tools"..path ) |
323
cd2924a1052c
improve testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
321
diff
changeset
|
34 end |
cd2924a1052c
improve testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
321
diff
changeset
|
35 |
503 | 36 local page |
323
cd2924a1052c
improve testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
321
diff
changeset
|
37 |
503 | 38 init() |
1152
21d157b153fe
change http parameters interface
Franklin Schmidt <fschmidt@gmail.com>
parents:
797
diff
changeset
|
39 Http.request.parameters.code = "require('luan:Io.luan').print 'hi'" |
503 | 40 page = get_page "/run" |
539
473e456444ff
Remove object-oriented primitive methods for string and binary
Franklin Schmidt <fschmidt@gmail.com>
parents:
519
diff
changeset
|
41 trim(page) == "hi" or error "failed" |
323
cd2924a1052c
improve testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
321
diff
changeset
|
42 |
503 | 43 init() |
1152
21d157b153fe
change http parameters interface
Franklin Schmidt <fschmidt@gmail.com>
parents:
797
diff
changeset
|
44 Http.request.parameters.cmd = "'ab'..'cd'" |
503 | 45 page = get_page "/shell" |
539
473e456444ff
Remove object-oriented primitive methods for string and binary
Franklin Schmidt <fschmidt@gmail.com>
parents:
519
diff
changeset
|
46 find(page,"abcd") or error "failed" |
323
cd2924a1052c
improve testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
321
diff
changeset
|
47 |
321
7f7708e8fdd4
remove import statement
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
308
diff
changeset
|
48 |
323
cd2924a1052c
improve testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
321
diff
changeset
|
49 -- lucene |
cd2924a1052c
improve testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
321
diff
changeset
|
50 |
503 | 51 local this_file = Io.schemes.file(Luan.arg[0]) |
52 local this_dir = this_file.parent() | |
53 local lucene_dir = this_dir.parent().child("build").child("lucene_test") | |
323
cd2924a1052c
improve testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
321
diff
changeset
|
54 --print(lucene_dir.to_string()) |
503 | 55 local db = Lucene.index(lucene_dir.to_string()) |
323
cd2924a1052c
improve testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
321
diff
changeset
|
56 db.delete_all() |
cd2924a1052c
improve testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
321
diff
changeset
|
57 |
503 | 58 local ab_testing = Ab_testing.of(db) |
59 local test_events = {"all"} | |
60 local aggregator_factories = { | |
323
cd2924a1052c
improve testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
321
diff
changeset
|
61 all = Ab_testing.count_all; |
cd2924a1052c
improve testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
321
diff
changeset
|
62 } |
cd2924a1052c
improve testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
321
diff
changeset
|
63 ab_testing.test{ name="All", values={"all"}, events=test_events, aggregator_factories=aggregator_factories } |
cd2924a1052c
improve testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
321
diff
changeset
|
64 ab_testing.test{ name="null", values={"A","B"}, events=test_events, aggregator_factories=aggregator_factories } |
cd2924a1052c
improve testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
321
diff
changeset
|
65 |
cd2924a1052c
improve testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
321
diff
changeset
|
66 for record in range(1,10) do |
cd2924a1052c
improve testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
321
diff
changeset
|
67 local doc = {type="test"} |
cd2924a1052c
improve testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
321
diff
changeset
|
68 ab_testing.to_doc(doc) |
547
0be287ab0309
add lucene/Versioning and simplify Lucene fn names
Franklin Schmidt <fschmidt@gmail.com>
parents:
544
diff
changeset
|
69 db.save(doc) |
323
cd2924a1052c
improve testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
321
diff
changeset
|
70 end |
cd2924a1052c
improve testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
321
diff
changeset
|
71 |
503 | 72 init() |
505
7bc63886d4f2
web page modules now return a function
Franklin Schmidt <fschmidt@gmail.com>
parents:
503
diff
changeset
|
73 ab_testing.web_page{"All","null"}() |
323
cd2924a1052c
improve testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
321
diff
changeset
|
74 |
693
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
563
diff
changeset
|
75 local Web_search = require "luan:lucene/Web_search.luan" |
497
55f9f74f1e55
Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
495
diff
changeset
|
76 local web_search = Web_search.of(db) |
55f9f74f1e55
Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
495
diff
changeset
|
77 |
503 | 78 init() |
505
7bc63886d4f2
web page modules now return a function
Franklin Schmidt <fschmidt@gmail.com>
parents:
503
diff
changeset
|
79 web_search() |
497
55f9f74f1e55
Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
495
diff
changeset
|
80 |
503 | 81 init() |
1152
21d157b153fe
change http parameters interface
Franklin Schmidt <fschmidt@gmail.com>
parents:
797
diff
changeset
|
82 Http.request.parameters.query = "" |
21d157b153fe
change http parameters interface
Franklin Schmidt <fschmidt@gmail.com>
parents:
797
diff
changeset
|
83 Http.request.parameters.rows = "100" |
21d157b153fe
change http parameters interface
Franklin Schmidt <fschmidt@gmail.com>
parents:
797
diff
changeset
|
84 Http.request.parameters.sort = "" |
505
7bc63886d4f2
web page modules now return a function
Franklin Schmidt <fschmidt@gmail.com>
parents:
503
diff
changeset
|
85 web_search() |
497
55f9f74f1e55
Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
495
diff
changeset
|
86 |
55f9f74f1e55
Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
495
diff
changeset
|
87 |
55f9f74f1e55
Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
495
diff
changeset
|
88 -- website |
55f9f74f1e55
Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
495
diff
changeset
|
89 |
693
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
563
diff
changeset
|
90 function Io.schemes.site(path) |
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
563
diff
changeset
|
91 return Io.uri( "file:../website/src"..path ) |
497
55f9f74f1e55
Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
495
diff
changeset
|
92 end |
55f9f74f1e55
Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
495
diff
changeset
|
93 |
503 | 94 init(); get_page "/" |
95 init(); get_page "/docs.html" | |
96 init(); get_page "/tutorial.html" | |
97 init(); get_page "/pil.html" | |
98 init(); get_page "/manual.html" | |
99 init(); get_page "/diff.html" | |
100 init(); get_page "/examples/hi" | |
101 init(); get_page "/examples/hi2" | |
102 init(); get_page "/examples/shell" | |
497
55f9f74f1e55
Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
495
diff
changeset
|
103 |
503 | 104 init() |
1152
21d157b153fe
change http parameters interface
Franklin Schmidt <fschmidt@gmail.com>
parents:
797
diff
changeset
|
105 Http.request.parameters.name = "bob" |
503 | 106 page = get_page "/examples/hi2" |
539
473e456444ff
Remove object-oriented primitive methods for string and binary
Franklin Schmidt <fschmidt@gmail.com>
parents:
519
diff
changeset
|
107 find(page,"bob") or error "failed" |
497
55f9f74f1e55
Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
495
diff
changeset
|
108 |
323
cd2924a1052c
improve testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
321
diff
changeset
|
109 |
cd2924a1052c
improve testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
321
diff
changeset
|
110 print "done" |