2016-03-21 08:21:11 +01:00
|
|
|
// Copyright (C) 2016 Michael Ficarra. All rights reserved.
|
|
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
|
|
|
|
|
|
/*---
|
|
|
|
description: >
|
2016-04-21 21:55:54 +02:00
|
|
|
Ensure that the regular expression generally distinguishes between valid
|
|
|
|
and invalid forms of the NativeFunction grammar production.
|
|
|
|
includes: [nativeFunctionMatcher.js]
|
2016-03-21 08:21:11 +01:00
|
|
|
---*/
|
|
|
|
|
2016-04-21 21:55:54 +02:00
|
|
|
if (!NATIVE_FUNCTION_RE.test('function(){[native code]}')) {
|
|
|
|
$ERROR('expected string to pass: "function(){[native code]}"');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!NATIVE_FUNCTION_RE.test('function(){ [native code] }')) {
|
|
|
|
$ERROR('expected string to pass: "function(){ [native code] }"');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!NATIVE_FUNCTION_RE.test('function ( ) { [ native code ] }')) {
|
|
|
|
$ERROR('expected string to pass: "function ( ) { [ native code ] }"');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!NATIVE_FUNCTION_RE.test('function a(){ [native code] }')) {
|
|
|
|
$ERROR('expected string to pass: "function a(){ [native code] }"');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!NATIVE_FUNCTION_RE.test('function a(){ /* } */ [native code] }')) {
|
|
|
|
$ERROR('expected string to pass: "function a(){ /* } */ [native code] }"');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NATIVE_FUNCTION_RE.test('')) {
|
|
|
|
$ERROR('expected string to fail: ""');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NATIVE_FUNCTION_RE.test('native code')) {
|
|
|
|
$ERROR('expected string to fail: "native code"');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NATIVE_FUNCTION_RE.test('function(){}')) {
|
|
|
|
$ERROR('expected string to fail: "function(){}"');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NATIVE_FUNCTION_RE.test('function(){ "native code" }')) {
|
|
|
|
$ERROR('expected string to fail: "function(){ "native code" }"');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NATIVE_FUNCTION_RE.test('function(){ [] native code }')) {
|
|
|
|
$ERROR('expected string to fail: "function(){ [] native code }"');
|
|
|
|
}
|