Skip to content

Commit

Permalink
Add currently failing tests for issue jknack#686
Browse files Browse the repository at this point in the history
  • Loading branch information
yohannrub committed Jan 28, 2022
1 parent ef79693 commit c29e7f0
Showing 1 changed file with 36 additions and 0 deletions.
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()));
}
}

0 comments on commit c29e7f0

Please sign in to comment.