PluralNet
PluralNet copied to clipboard
Looks like an issue in FilipinoProvider
if (imod10 != 4 && imod10 != 6 || imod10 != 9) return PluralType.ONE;
this if statement always evaluates to true.. should it be
if (imod10 != 4 && imod10 != 6 && imod10 != 9) return PluralType.ONE;
BTW, here's my test code
public interface IPluralProvider
{
float[] GetSampleValues();
PluralType GetPluralType(float n);
}
public static void Test()
{
var interfacetype = typeof(IPluralProvider);
foreach (var type in Assembly.GetExecutingAssembly().GetTypes())
{
if (interfacetype.IsAssignableFrom(type) && !type.IsInterface)
{
var instance = (IPluralProvider)Activator.CreateInstance(type);
var values = instance.GetSampleValues();
var found = new HashSet<PluralType>();
foreach (var value in values)
{
var ptype = instance.GetPluralType(value);
if (!found.Add(ptype))
{
Console.WriteLine($"{type.Name} Duplicate type {ptype}: {value}");
foreach (var v2 in values)
if (instance.GetPluralType(v2) == ptype)
Console.WriteLine($"\t({v2})");
}
}
for (float i = 0; i < 200; i++)
{
var ptype = instance.GetPluralType(i);
if (found.Add(ptype)) Console.WriteLine($"{type.Name} Missing sample type {ptype}: {i}");
ptype = instance.GetPluralType(i + .1f);
if (found.Add(ptype)) Console.WriteLine($"{type.Name} Missing sample type {ptype}: {i + .1f}");
ptype = instance.GetPluralType(i + .12f);
if (found.Add(ptype)) Console.WriteLine($"{type.Name} Missing sample type {ptype}: {i + .12f}");
ptype = instance.GetPluralType(i + .1243f);
if (found.Add(ptype)) Console.WriteLine($"{type.Name} Missing sample type {ptype}: {i + .1243f}");
}
}
}
}