From 58daab21cd043e1dc37024a7f99b396788372918 Mon Sep 17 00:00:00 2001
From: Daniel Baumann <daniel.baumann@progress-linux.org>
Date: Sat, 9 Mar 2024 14:19:48 +0100
Subject: Merging upstream version 1.44.3.

Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
---
 .../misc/oktavia/test/test-oktavia-stemming.jsx    | 55 ++++++++++++++++++++++
 1 file changed, 55 insertions(+)
 create mode 100644 web/server/h2o/libh2o/misc/oktavia/test/test-oktavia-stemming.jsx

(limited to 'web/server/h2o/libh2o/misc/oktavia/test/test-oktavia-stemming.jsx')

diff --git a/web/server/h2o/libh2o/misc/oktavia/test/test-oktavia-stemming.jsx b/web/server/h2o/libh2o/misc/oktavia/test/test-oktavia-stemming.jsx
new file mode 100644
index 000000000..d8d1d74eb
--- /dev/null
+++ b/web/server/h2o/libh2o/misc/oktavia/test/test-oktavia-stemming.jsx
@@ -0,0 +1,55 @@
+import "test-case.jsx";
+import "oktavia.jsx";
+import "metadata.jsx";
+import "stemmer/english-stemmer.jsx";
+import "console.jsx";
+
+class _Test extends TestCase
+{
+    var oktavia : Oktavia;
+    var section : Section;
+
+    override function setUp () : void
+    {
+        this.oktavia = new Oktavia();
+        this.oktavia.setStemmer(new EnglishStemmer());
+        this.section = this.oktavia.addSection('document');
+        this.oktavia.addWord("stemming baby", true);
+        this.section.setTail("doc1");
+        this.oktavia.addWord("stemmed babies", true);
+        this.section.setTail("doc2");
+        this.oktavia.build();
+    }
+
+    function test_search_without_stemming () : void
+    {
+        var results = this.oktavia.rawSearch('baby', false);
+        this.expect(results.length).toBe(1);
+    }
+
+    function test_search_with_stemming () : void
+    {
+        var results = this.oktavia.rawSearch('baby', true);
+        this.expect(results.length).toBe(1);
+    }
+
+    function test_load_dump_and_search_without_stemming () : void
+    {
+        var dump = this.oktavia.dump();
+        var oktavia = new Oktavia();
+        oktavia.setStemmer(new EnglishStemmer());
+        oktavia.load(dump);
+        var results = oktavia.rawSearch('baby', false);
+        this.expect(results.length).toBe(1);
+    }
+
+    function test_load_dump_and_search_with_stemming () : void
+    {
+        var dump = this.oktavia.dump();
+        var oktavia = new Oktavia();
+        oktavia.setStemmer(new EnglishStemmer());
+        oktavia.load(dump);
+        var results = oktavia.rawSearch('baby', true);
+        this.expect(results.length).toBe(1);
+    }
+}
-- 
cgit v1.2.3

