public void GetEnumerator() { var compiler = new Mock <ICompilerServices>(); var vm = new VirtualMachine(compiler.Object); var proto = new JSUnenumerableObject(vm, null); proto.OwnMembers.Add("a", true); var enumerator = proto.GetEnumerator(); Assert.IsFalse(enumerator.MoveNext()); }
public VirtualMachine(ICompilerServices compiler) { Contract.Requires <ArgumentNullException>(compiler != null, "compiler"); Compiler = compiler; // Создать глобальный объект GlobalObject = new JSObject(this); // Создать прототипы встроенных объектов Object = new JSObjectPrototype(this); Boolean = new JSBooleanPrototype(this, Object); Number = new JSNumberPrototype(this, Object); String = new JSStringPrototype(this, Object); Array = new JSArrayPrototype(this, Object); Function = new JSFunctionPrototype(this, Object); Error = new JSUnenumerableObject(this, Object); ReferenceError = new JSUnenumerableObject(this, Error); SyntaxError = new JSUnenumerableObject(this, Error); TypeError = new JSUnenumerableObject(this, Error); RangeError = new JSUnenumerableObject(this, Error); InternalError = new JSUnenumerableObject(this, Error); // Инициализировать глобальный объект GlobalObject.OwnMembers.Add("Object", new JSObjectConstructor(this, Function)); GlobalObject.OwnMembers.Add("Boolean", new JSBooleanConstructor(this, Function)); GlobalObject.OwnMembers.Add("Number", new JSNumberConstructor(this, Function)); GlobalObject.OwnMembers.Add("String", new JSStringConstructor(this, Function)); GlobalObject.OwnMembers.Add("Array", new JSArrayConstructor(this, Function)); GlobalObject.OwnMembers.Add("Function", new JSFunctionConstructor(this, Function)); GlobalObject.OwnMembers.Add("Error", new JSErrorConstructor(this, Function)); GlobalObject.OwnMembers.Add("InternalError", new JSInternalErrorConstructor(this, Function)); GlobalObject.OwnMembers.Add("ReferenceError", new JSReferenceErrorConstructor(this, Function)); GlobalObject.OwnMembers.Add("SyntaxError", new JSSyntaxErrorConstructor(this, Function)); GlobalObject.OwnMembers.Add("TypeError", new JSTypeErrorConstructor(this, Function)); GlobalObject.OwnMembers.Add("RangeError", new JSRangeErrorConstructor(this, Function)); }