Mercurial Hosting > luan
view scripts/test.luan @ 972:5ee36654b383
simplify AbstractHttpConnection
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sat, 15 Oct 2016 22:42:05 -0600 |
parents | 86e477945676 |
children | 21d157b153fe |
line wrap: on
line source
local Binary = require "luan:Binary.luan" local Html = require "luan:Html.luan" local Io = require "luan:Io.luan" local Luan = require "luan:Luan.luan" local Math = require "luan:Math.luan" local Package = require "luan:Package.luan" local String = require "luan:String.luan" local Table = require "luan:Table.luan" local Thread = require "luan:Thread.luan" local Time = require "luan:Time.luan" local Hosting = require "luan:host/Hosting.luan" local Http = require "luan:http/Http.luan" local Http_test = require "luan:http/Http_test.luan" local Server = require "luan:http/Server.luan" local Lucene = require "luan:lucene/Lucene.luan" local Versioning = require "luan:lucene/Versioning.luan" local Mail = require "luan:mail/Mail.luan" local error = Luan.error local range = Luan.range or error() local trim = String.trim or error() local find = String.find or error() local init = Http_test.init or error() local get_page = Http_test.get_page or error() local Ab_testing = require "luan:lucene/Ab_testing.luan" local function print(...) Io.print_to(Io.stderr,...) end function Io.schemes.site(path) return Io.uri( "luan:http/tools"..path ) end local page init() Http.request.parameter.code = "require('luan:Io.luan').print 'hi'" page = get_page "/run" trim(page) == "hi" or error "failed" init() Http.request.parameter.cmd = "'ab'..'cd'" page = get_page "/shell" find(page,"abcd") or error "failed" init() page = get_page "/dump" -- lucene local this_file = Io.schemes.file(Luan.arg[0]) local this_dir = this_file.parent() local lucene_dir = this_dir.parent().child("build").child("lucene_test") --print(lucene_dir.to_string()) local db = Lucene.index(lucene_dir.to_string()) db.delete_all() local ab_testing = Ab_testing.of(db) local test_events = {"all"} local aggregator_factories = { all = Ab_testing.count_all; } ab_testing.test{ name="All", values={"all"}, events=test_events, aggregator_factories=aggregator_factories } ab_testing.test{ name="null", values={"A","B"}, events=test_events, aggregator_factories=aggregator_factories } for record in range(1,10) do local doc = {type="test"} ab_testing.to_doc(doc) db.save(doc) end init() ab_testing.web_page{"All","null"}() local Web_search = require "luan:lucene/Web_search.luan" local web_search = Web_search.of(db) init() web_search() init() Http.request.parameter.query = "" Http.request.parameter.rows = "100" Http.request.parameter.sort = "" web_search() -- website function Io.schemes.site(path) return Io.uri( "file:../website/src"..path ) end init(); get_page "/" init(); get_page "/docs.html" init(); get_page "/tutorial.html" init(); get_page "/pil.html" init(); get_page "/manual.html" init(); get_page "/diff.html" init(); get_page "/examples/hi" init(); get_page "/examples/hi2" init(); get_page "/examples/shell" init() Http.request.parameter.name = "bob" page = get_page "/examples/hi2" find(page,"bob") or error "failed" print "done"