forked from jknack/handlebars.java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add currently failing tests for issue jknack#686
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
handlebars/src/test/java/com/github/jknack/handlebars/issues/Issue686.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.github.jknack.handlebars.issues; | ||
|
||
import com.github.jknack.handlebars.Handlebars; | ||
import com.github.jknack.handlebars.cache.ConcurrentMapTemplateCache; | ||
import com.github.jknack.handlebars.io.StringTemplateSource; | ||
import com.github.jknack.handlebars.io.TemplateSource; | ||
import com.github.jknack.handlebars.io.URLTemplateSource; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class Issue686 { | ||
|
||
@Test | ||
public void compileStringsWithSameHashCode() throws IOException { | ||
Handlebars handlebars = new Handlebars().with(new ConcurrentMapTemplateCache()); | ||
|
||
// Strings "Aa" and "BB" have same hashCode | ||
assertEquals("Aa", handlebars.compileInline("Aa").apply(new Object())); | ||
assertEquals("BB", handlebars.compileInline("BB").apply(new Object())); | ||
} | ||
|
||
@Test | ||
public void compileTemplateSourcesWithSameFilename() throws IOException { | ||
Handlebars handlebars = new Handlebars().with(new ConcurrentMapTemplateCache()); | ||
|
||
TemplateSource stringTemplateSource = new StringTemplateSource("filename", "string"); | ||
TemplateSource urlTemplateSource = new URLTemplateSource("filename", getClass().getResource( | ||
"/template.hbs")); | ||
|
||
assertEquals("string", handlebars.compile(stringTemplateSource).apply(new Object())); | ||
assertEquals("template.hbs", handlebars.compile(urlTemplateSource).apply(new Object())); | ||
} | ||
} |