File tree 1 file changed +36
-0
lines changed
handlebars/src/test/java/com/github/jknack/handlebars/issues
1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .github .jknack .handlebars .issues ;
2
+
3
+ import com .github .jknack .handlebars .Handlebars ;
4
+ import com .github .jknack .handlebars .cache .ConcurrentMapTemplateCache ;
5
+ import com .github .jknack .handlebars .io .StringTemplateSource ;
6
+ import com .github .jknack .handlebars .io .TemplateSource ;
7
+ import com .github .jknack .handlebars .io .URLTemplateSource ;
8
+ import org .junit .Test ;
9
+
10
+ import java .io .IOException ;
11
+
12
+ import static org .junit .Assert .assertEquals ;
13
+
14
+ public class Issue686 {
15
+
16
+ @ Test
17
+ public void compileStringsWithSameHashCode () throws IOException {
18
+ Handlebars handlebars = new Handlebars ().with (new ConcurrentMapTemplateCache ());
19
+
20
+ // Strings "Aa" and "BB" have same hashCode
21
+ assertEquals ("Aa" , handlebars .compileInline ("Aa" ).apply (new Object ()));
22
+ assertEquals ("BB" , handlebars .compileInline ("BB" ).apply (new Object ()));
23
+ }
24
+
25
+ @ Test
26
+ public void compileTemplateSourcesWithSameFilename () throws IOException {
27
+ Handlebars handlebars = new Handlebars ().with (new ConcurrentMapTemplateCache ());
28
+
29
+ TemplateSource stringTemplateSource = new StringTemplateSource ("filename" , "string" );
30
+ TemplateSource urlTemplateSource = new URLTemplateSource ("filename" , getClass ().getResource (
31
+ "/template.hbs" ));
32
+
33
+ assertEquals ("string" , handlebars .compile (stringTemplateSource ).apply (new Object ()));
34
+ assertEquals ("template.hbs" , handlebars .compile (urlTemplateSource ).apply (new Object ()));
35
+ }
36
+ }
You can’t perform that action at this time.
0 commit comments