Unit tests for ipairs and pairs, as well as changing how they handle null. ipairs now breaks at first nil value, pairs skips it

This commit is contained in:
2018-11-24 14:39:53 +01:00
parent 13ac6f2754
commit 194e7236c4
2 changed files with 22 additions and 4 deletions

View File

@@ -46,10 +46,10 @@ namespace Upsilon.BaseTypes
while (baseEnumerator.MoveNext())
{
var key = baseEnumerator.Current;
if (key == null)
if (key.Type == Type.Nil)
break;
var value = BaseIterator.GetValueFromIndex(key);
if (value == null)
if (value.Type == Type.Nil)
break;
yield return new SimpleScriptTable(new List<ScriptType>(){key, value});
}
@@ -71,7 +71,8 @@ namespace Upsilon.BaseTypes
{
var key = baseEnumerator.Current;
var value = BaseIterator.GetValueFromIndex(key);
yield return new SimpleScriptTable(new List<ScriptType>(){key, value});
if (value.Type != Type.Nil)
yield return new SimpleScriptTable(new List<ScriptType>(){key, value});
}
}
}