Mercurial Hosting > luan
view scripts/test.luan @ 544:c5a93767cc5c
lucene overhaul, untested
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 12 Jun 2015 19:11:44 -0600 |
parents | 473e456444ff |
children | 0be287ab0309 |
line wrap: on
line source
local Binary = require "luan:Binary" local Debug = require "luan:Debug" 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 Mail = require "luan:mail/Mail" local Stripe = require "luan:stripe/Stripe" local error = Luan.error local range = Luan.range local trim = String.trim local find = String.find local init = Http_test.init local get_page = Http_test.get_page 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_document(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/hi2_simply_html" init(); get_page "/examples/shell" init() Http.request.parameter.name = "bob" page = get_page "/examples/hi2" find(page,"bob") or error "failed" init() Http.request.parameter.name = "bob" page = get_page "/examples/hi2_simply_html" find(page,"bob") or error "failed" print "done"