public void TestPartIntWithLeadingZero() { // ECMAScript 5 forbids a leading 0 denoting an octal number, and it should be interpreted as base-10. // All major browsers follow this convention. Assert.AreEqual(123, JsGlobal.ParseInt("0123")); }
public void TestDecodeUri() { // Example from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURI Assert.AreEqual("https://developer.mozilla.org/ru/docs/JavaScript_шеллы", JsGlobal.DecodeUri("https://developer.mozilla.org/ru/docs/JavaScript_%D1%88%D0%B5%D0%BB%D0%BB%D1%8B")); }
public static JsObject BuildDelegateFunction(JsGlobal global, Delegate @delegate) { if (global == null) throw new ArgumentNullException("global"); if (@delegate == null) throw new ArgumentNullException("delegate"); return global.CreateFunction( @delegate.Method.Name, WrapDelegate(@delegate), @delegate.Method.GetParameters().Length ); }
public static JsObject BuildMethodFunction(JsGlobal global, MethodInfo method) { if (method == null) throw new ArgumentNullException("method"); if (global == null) throw new ArgumentNullException("global"); if (method.ContainsGenericParameters) throw new InvalidOperationException("Can't wrap an unclosed generic"); return global.CreateFunction( method.Name, WrapMethod(method), method.GetParameters().Length ); }
public NativeMethodOverload(JsGlobal global, IEnumerable<MethodInfo> methods) { if (global == null) throw new ArgumentNullException("global"); if (methods == null) throw new ArgumentNullException("methods"); foreach (var method in methods) { if (method.IsGenericMethodDefinition) _generics.Add(method); else if (!method.ContainsGenericParameters) _methods.Add(method); } _overloads = new NativeOverloadImpl<MethodInfo, JsFunction>( global, GetMembers, ProxyHelper.WrapMethod ); }
public NativePropertyStore(JsObject owner, MethodInfo[] getters, MethodInfo[] setters) : base((DictionaryPropertyStore)owner.PropertyStore) { if (getters == null) throw new ArgumentNullException("getters"); if (setters == null) throw new ArgumentNullException("setters"); _global = owner.Global; _getOverload = new NativeOverloadImpl<MethodInfo, WrappedIndexerGetter>( _global, (genericArgs, length) => Array.FindAll(getters, mi => mi.GetParameters().Length == length), ProxyHelper.WrapIndexerGetter ); _setOverload = new NativeOverloadImpl<MethodInfo, WrappedIndexerSetter>( _global, (genericArgs, length) => Array.FindAll(setters, mi => mi.GetParameters().Length == length), ProxyHelper.WrapIndexerSetter ); }
public void Setup() { _target = new JsGlobal(new StubVisitor(), Jint.Options.Strict); _accessor = new PrivateObject(_target, new PrivateType(typeof(JsGlobal))); }
public void TestUnescapeWithUriEncoding() { // Example from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/unescape Assert.AreEqual("äöü", JsGlobal.Unescape("%E4%F6%FC")); }
public void TestUnescapeWithAsciiString() { // Example from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/unescape Assert.AreEqual("abc123", JsGlobal.Unescape("abc123")); }
public void TestPartIntWithBase16() { Assert.AreEqual(291, JsGlobal.ParseInt("0x123")); }
public void TestPartIntWithBase10() { Assert.AreEqual(123, JsGlobal.ParseInt("123", 10)); }
public void TestEncodeUriComponentWithAlphanumericCharactersAndWhitespace() { // Example from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI Assert.AreEqual("ABC%20abc%20123", JsGlobal.EncodeUriComponent("ABC abc 123")); }
public void TestEncodeUriComponentWithUnreservedCharacters() { // Example from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI Assert.AreEqual("-_.!~*'()", JsGlobal.EncodeUriComponent("-_.!~*'()")); }
public void TestEncodeUriComponentWithReservedCharacters() { // Example from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI Assert.AreEqual("%3B%2C%2F%3F%3A%40%26%3D%2B%24%23", JsGlobal.EncodeUriComponent(";,/?:@&=+$#")); }
public void TestEncodeUriWithReservedCharacters() { // Example from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI Assert.AreEqual(";,/?:@&=+$#", JsGlobal.EncodeUri(";,/?:@&=+$#")); }
public EVisitor() { obj = new JsGlobal(this, "aaa"); }