Mercurial Hosting > luan
view scripts/test.luan @ 608:d2e0855b3105
minor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 07 Dec 2015 16:04:01 -0700 |
parents | 195a64f948f2 |
children | ca169567ce07 |
line wrap: on
line source
local Binary = require "luan:Binary" local Html = require "luan:Html" local Io = require "luan:Io" local Luan = require "luan:Luan" local Math = require "luan:Math" local Package = require "luan:Package" local String = require "luan:String" local Table = require "luan:Table" local Thread = require "luan:Thread" local Time = require "luan:Time" local Hosting = require "luan:host/Hosting" local Http = require "luan:http/Http" local Http_test = require "luan:http/Http_test" local Server = require "luan:http/Server" local Lucene = require "luan:lucene/Lucene" local Versioning = require "luan:lucene/Versioning" local Mail = require "luan:mail/Mail" local Stripe = require "luan:stripe/Stripe" 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" local function print(...) Io.print_to(Io.stderr,...) end function Io.schemes.site(path,add_extension) return Io.uri( "luan:http"..path, add_extension ) end local page init() Http.request.parameter.code = "require('luan:Io').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" 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,add_extension) return Io.uri( "file:../website/src"..path, add_extension ) 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"