text:
/* $Id: tif_win32.c,v 1.35 2011/04/10 17:14:09 drolon Exp $ */

/*
 * Copyright (c) 1988-1997 Sam Leffler
 * Copyright (c) 1991-1997 Silicon Graphics, Inc.
 *
 * Permission to use, copy, modify, distribute, and sell this software and
 * its documentation for any purpose is hereby granted without fee, provided
 * that (i) the above copyright notices and this permission notice appear in
 * all copies of the software and related documentation, and (ii) the names of
 * Sam Leffler and Silicon Graphics may not be used in any advertising or
 * publicity relating to the software without the specific, prior written
 * permission of Sam Leffler and Silicon Graphics.
 *
 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
 *
 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
 * OF THIS SOFTWARE.
 */

/*
 * TIFF Library Win32-specific Routines.  Adapted from tif_unix.c 4/5/95 by
 * Scott Wagner (wagner@itek.com), Itek Graphix, Rochester, NY USA
 */
#include "tiffiop.h"

#include <windows.h>

static tsize_t
_tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size)
{
	DWORD dwSizeRead;
	if (!ReadFile(fd, buf, size, &dwSizeRead, NULL))
		return(0);
	return ((tsize_t) dwSizeRead);
}

static tsize_t
_tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size)
{
	DWORD dwSizeWritten;
	if (!WriteFile(fd, buf, size, &dwSizeWritten, NULL))
		return(0);
	return ((tsize_t) dwSizeWritten);
}

static toff_t
_tiffSeekProc(thandle_t fd, toff_t off, int whence)
{
        ULARGE_INTEGER li;
	DWORD dwMoveMethod;

	li.QuadPart = off;

	switch(whence)
	{
	case SEEK_SET:
		dwMoveMethod = FILE_BEGIN;
		break;
	case SEEK_CUR:
		dwMoveMethod = FILE_CURRENT;
		break;
	case SEEK_END:
		dwMoveMethod = FILE_END;
		break;
	default:
		dwMoveMethod = FILE_BEGIN;
		break;
	}
	return ((toff_t)SetFilePointer(fd, (LONG) li.LowPart,
				       (PLONG)&li.HighPart, dwMoveMethod));
}

static int
_tiffCloseProc(thandle_t fd)
{
	return (CloseHandle(fd) ? 0 : -1);
}

static toff_t
_tiffSizeProc(thandle_t fd)
{
	return ((toff_t)GetFileSize(fd, NULL));
}

static int
_tiffDummyMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize)
{
	(void) fd;
	(void) pbase;
	(void) psize;
	return (0);
}

/*
 * From "Hermann Josef Hill" <lhill@rhein-zeitung.de>:
 *
 * Windows uses both a handle and a pointer for file mapping,
 * but according to the SDK documentation and Richter's book
 * "Advanced Windows Programming" it is safe to free the handle
 * after obtaining the file mapping pointer
 *
 * This removes a nasty OS dependency and cures a problem
 * with Visual C++ 5.0
 */
static int
_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize)
{
	toff_t size;
	HANDLE hMapFile;

	if ((size = _tiffSizeProc(fd)) == 0xFFFFFFFF)
		return (0);
	hMapFile = CreateFileMapping(fd, NULL, PAGE_READONLY, 0, size, NULL);
	if (hMapFile == NULL)
		return (0);
	*pbase = MapViewOfFile(hMapFile, FILE_MAP_READ, 0, 0, 0);
	CloseHandle(hMapFile);
	if (*pbase == NULL)
		return (0);
	*psize = size;
	return(1);
}

static void
_tiffDummyUnmapProc(thandle_t fd, tdata_t base, toff_t size)
{
	(void) fd;
	(void) base;
	(void) size;
}

static void
_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size)
{
	UnmapViewOfFile(base);
}

/*
 * Open a TIFF file descriptor for read/writing.
 * Note that TIFFFdOpen and TIFFOpen recognise the character 'u' in the mode
 * string, which forces the file to be opened unmapped.
 */
TIFF*
TIFFFdOpen(int ifd, const char* name, const char* mode)
{
	TIFF* tif;
	BOOL fSuppressMap = (mode[1] == 'u' || (mode[1]!=0 && mode[2] == 'u'));

	tif = TIFFClientOpen(name, mode, (thandle_t)ifd,
			_tiffReadProc, _tiffWriteProc,
			_tiffSeekProc, _tiffCloseProc, _tiffSizeProc,
			fSuppressMap ? _tiffDummyMapProc : _tiffMapProc,
			fSuppressMap ? _tiffDummyUnmapProc : _tiffUnmapProc);
	if (tif)
		tif->tif_fd = ifd;
	return (tif);
}

#ifndef _WIN32_WCE

/*
 * Open a TIFF file for read/writing.
 */
TIFF*
TIFFOpen(const char* name, const char* mode)
{
	static const char module[] = "TIFFOpen";
	thandle_t fd;
	int m;
	DWORD dwMode;
	TIFF* tif;

	m = _TIFFgetMode(mode, module);

	switch(m)
	{
	case O_RDONLY:
		dwMode = OPEN_EXISTING;
		break;
	case O_RDWR:
		dwMode = OPEN_ALWAYS;
		break;
	case O_RDWR|O_CREAT:
		dwMode = OPEN_ALWAYS;
		break;
	case O_RDWR|O_TRUNC:
		dwMode = CREATE_ALWAYS;
		break;
	case O_RDWR|O_CREAT|O_TRUNC:
		dwMode = CREATE_ALWAYS;
		break;
	default:
		return ((TIFF*)0);
	}
	fd = (thandle_t)CreateFileA(name,
		(m == O_RDONLY)?GENERIC_READ:(GENERIC_READ | GENERIC_WRITE),
		FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, dwMode,
		(m == O_RDONLY)?FILE_ATTRIBUTE_READONLY:FILE_ATTRIBUTE_NORMAL,
		NULL);
	if (fd == INVALID_HANDLE_VALUE) {
		TIFFErrorExt(0, module, "%s: Cannot open", name);
		return ((TIFF *)0);
	}

	tif = TIFFFdOpen((int)fd, name, mode);
	if(!tif)
		CloseHandle(fd);
	return tif;
}

/*
 * Open a TIFF file with a Unicode filename, for read/writing.
 */
TIFF*
TIFFOpenW(const wchar_t* name, const char* mode)
{
	static const char module[] = "TIFFOpenW";
	thandle_t fd;
	int m;
	DWORD dwMode;
	int mbsize;
	char *mbname;
	TIFF *tif;

	m = _TIFFgetMode(mode, module);

	switch(m) {
		case O_RDONLY:			dwMode = OPEN_EXISTING; break;
		case O_RDWR:			dwMode = OPEN_ALWAYS;   break;
		case O_RDWR|O_CREAT:		dwMode = OPEN_ALWAYS;   break;
		case O_RDWR|O_TRUNC:		dwMode = CREATE_ALWAYS; break;
		case O_RDWR|O_CREAT|O_TRUNC:	dwMode = CREATE_ALWAYS; break;
		default:			return ((TIFF*)0);
	}

	fd = (thandle_t)CreateFileW(name,
		(m == O_RDONLY)?GENERIC_READ:(GENERIC_READ|GENERIC_WRITE),
		FILE_SHARE_READ, NULL, dwMode,
		(m == O_RDONLY)?FILE_ATTRIBUTE_READONLY:FILE_ATTRIBUTE_NORMAL,
		NULL);
	if (fd == INVALID_HANDLE_VALUE) {
		TIFFErrorExt(0, module, "%S: Cannot open", name);
		return ((TIFF *)0);
	}

	mbname = NULL;
	mbsize = WideCharToMultiByte(CP_ACP, 0, name, -1, NULL, 0, NULL, NULL);
	if (mbsize > 0) {
		mbname = (char *)_TIFFmalloc(mbsize);
		if (!mbname) {
			TIFFErrorExt(0, module,
			"Can't allocate space for filename conversion buffer");
			return ((TIFF*)0);
		}

		WideCharToMultiByte(CP_ACP, 0, name, -1, mbname, mbsize,
				    NULL, NULL);
	}

	tif = TIFFFdOpen((int)fd,
			 (mbname != NULL) ? mbname : "<unknown>", mode);
	if(!tif)
		CloseHandle(fd);

	_TIFFfree(mbname);

	return tif;
}

#endif /* ndef _WIN32_WCE */

tdata_t
_TIFFmalloc(tsize_t s)
{
	return ((tdata_t)GlobalAlloc(GMEM_FIXED, s));
}

void
_TIFFfree(tdata_t p)
{
	GlobalFree(p);
	return;
}

tdata_t
_TIFFrealloc(tdata_t p, tsize_t s)
{
	void* pvTmp;
	tsize_t old;

	if(p == NULL)
		return ((tdata_t)GlobalAlloc(GMEM_FIXED, s));

	old = GlobalSize(p);

	if (old>=s) {
		if ((pvTmp = GlobalAlloc(GMEM_FIXED, s)) != NULL) {
			CopyMemory(pvTmp, p, s);
			GlobalFree(p);
		}
	} else {
		if ((pvTmp = GlobalAlloc(GMEM_FIXED, s)) != NULL) {
			CopyMemory(pvTmp, p, old);
			GlobalFree(p);
		}
	}
	return ((tdata_t)pvTmp);
}

void
_TIFFmemset(void* p, int v, tsize_t c)
{
	FillMemory(p, c, (BYTE)v);
}

void
_TIFFmemcpy(void* d, const tdata_t s, tsize_t c)
{
	CopyMemory(d, s, c);
}

int
_TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c)
{
	register const BYTE *pb1 = (const BYTE *) p1;
	register const BYTE *pb2 = (const BYTE *) p2;
	register DWORD dwTmp = c;
	register int iTmp;
	for (iTmp = 0; dwTmp-- && !iTmp; iTmp = (int)*pb1++ - (int)*pb2++)
		;
	return (iTmp);
}

#ifndef _WIN32_WCE

static void
Win32WarningHandler(const char* module, const char* fmt, va_list ap)
{
#ifndef TIF_PLATFORM_CONSOLE
	LPTSTR szTitle;
	LPTSTR szTmp;
	LPCTSTR szTitleText = "%s Warning";
	LPCTSTR szDefaultModule = "LIBTIFF";
	LPCTSTR szTmpModule = (module == NULL) ? szDefaultModule : module;
	if ((szTitle = (LPTSTR)LocalAlloc(LMEM_FIXED, (strlen(szTmpModule) +
		strlen(szTitleText) + strlen(fmt) + 128)*sizeof(char))) == NULL)
		return;
	sprintf(szTitle, szTitleText, szTmpModule);
	szTmp = szTitle + (strlen(szTitle)+2)*sizeof(char);
	vsprintf(szTmp, fmt, ap);
	MessageBoxA(GetFocus(), szTmp, szTitle, MB_OK | MB_ICONINFORMATION);
	LocalFree(szTitle);
	return;
#else
	if (module != NULL)
		fprintf(stderr, "%s: ", module);
	fprintf(stderr, "Warning, ");
	vfprintf(stderr, fmt, ap);
	fprintf(stderr, ".\n");
#endif
}
TIFFErrorHandler _TIFFwarningHandler = Win32WarningHandler;

static void
Win32ErrorHandler(const char* module, const char* fmt, va_list ap)
{
#ifndef TIF_PLATFORM_CONSOLE
	LPTSTR szTitle;
	LPTSTR szTmp;
	LPCTSTR szTitleText = "%s Error";
	LPCTSTR szDefaultModule = "LIBTIFF";
	LPCTSTR szTmpModule = (module == NULL) ? szDefaultModule : module;
	if ((szTitle = (LPTSTR)LocalAlloc(LMEM_FIXED, (strlen(szTmpModule) +
		strlen(szTitleText) + strlen(fmt) + 128)*sizeof(char))) == NULL)
		return;
	sprintf(szTitle, szTitleText, szTmpModule);
	szTmp = szTitle + (strlen(szTitle)+2)*sizeof(char);
	vsprintf(szTmp, fmt, ap);
	MessageBoxA(GetFocus(), szTmp, szTitle, MB_OK | MB_ICONEXCLAMATION);
	LocalFree(szTitle);
	return;
#else
	if (module != NULL)
		fprintf(stderr, "%s: ", module);
	vfprintf(stderr, fmt, ap);
	fprintf(stderr, ".\n");
#endif
}
TIFFErrorHandler _TIFFerrorHandler = Win32ErrorHandler;

#endif /* ndef _WIN32_WCE */

/* vim: set ts=8 sts=8 sw=8 noet: */
/*
 * Local Variables:
 * mode: c
 * c-basic-offset: 8
 * fill-column: 78
 * End:
 */


text:
[![Build Status](https://api.travis-ci.com/dereuromark/cakephp-hashid.svg?branch=master)](https://travis-ci.com/dereuromark/cakephp-hashid)
[![Coverage Status](https://codecov.io/gh/dereuromark/cakephp-hashid/branch/master/graph/badge.svg)](https://codecov.io/gh/dereuromark/cakephp-hashid)
[![Latest Stable Version](https://poser.pugx.org/dereuromark/cakephp-hashid/v/stable.svg)](https://packagist.org/packages/dereuromark/cakephp-hashid)
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg)](https://php.net/)
[![License](https://poser.pugx.org/dereuromark/cakephp-hashid/license)](https://packagist.org/packages/dereuromark/cakephp-hashid)
[![Total Downloads](https://poser.pugx.org/dereuromark/cakephp-hashid/d/total.svg)](https://packagist.org/packages/dereuromark/cakephp-hashid)
[![Coding Standards](https://img.shields.io/badge/cs-PSR--2--R-yellow.svg)](https://github.com/php-fig-rectified/fig-rectified-standards)

Exposes [hashids](https://github.com/ivanakimov/hashids.php) as drop-in replacement for your numeric primary keys.

**DEPRECATED** This plugin is deprecated in favor of the more robust and future proof solution through exposing a dedicated field. See **[Expose plugin](https://github.com/dereuromark/cakephp-expose)**.

## A CakePHP plugin to
- cloak the actual numeric primary key behind the record (assuming you use a non public salt) for URLs, APIs and alike
- build short unique IDs (Even PHP_INT_MAX `2.147.483.647` becomes `lXQAALg` for example, so `length <= 7` for the hashid)

This branch is for use with **CakePHP 3.6+**. See [version map](https://github.com/dereuromark/cakephp-hashid/wiki#cakephp-version-map) for details.

### Why hashids?
- They are super short, especially for the URL
- They are lightweight and [fast](https://github.com/ivanakimov/hashids.php#speed). They work on the fly and require no table fields, no code changes. No overhead involved except for enabling the behavior.
- You do not lose sorting capability as with UUIDs.
- You can use hashids if you do not want to expose your database ids to the user - while not compromising speed - as a balance trait-off.

### Why not UUIDS?
- UUIDs can be up to 200x slower with growing DB tables, complex or heavy joins and especially with CakePHP default char(36). But even with the recommended binary(16) it would not be ideal.
- UUIDS often times completely replace the primary key, making it impossible to sort anymore on those records. This is especially problematic with data that gets inserted
at the same time (same datetime for created).
- UUIDS are often used to just cloak the numeric primary keys visibility of how much gets inserted over time. But that is not what they should be used for.
If you want to synch data across DBs, then they are useful. But they should not be abused for other things.

**UPDATE** This is actually not true if you combine both AIID and UUIDs and use UUIDs only for external lookup but keep AIID for all internal joins and operations. As such the Expose plugin fully replaces this now.

## Demo
See https://sandbox3.dereuromark.de/sandbox/hashids

## Setup
```
composer require dereuromark/cakephp-hashid
```
and
```
bin/cake plugin load Hashid
```

## Usage
See [Documentation](docs).

## Alternatives

See [this nice article](https://tomharrisonjr.com/uuid-or-guid-as-primary-keys-be-careful-7b2aa3dcb439) on a different approach that would use both -allowing "int" for internal and "uuid" for external reference.

redpajama_set_name: RedPajamaGithub


text:
using System;
using System.Diagnostics;
using System.Windows.Input;

namespace CoreLibrary
{
    /// <summary>
    /// This class allows delegating the commanding logic to methods passed as parameters,
    /// and enables a View to bind commands to objects that are not part of the element tree.
    /// </summary>
    public class DelegateCommand : ICommand
    {
        #region fields

        private readonly Action<object> _execute;
        private readonly Predicate<object> _canExecute;

        #endregion // fields

        #region ctor

        /// <summary>
        /// Execute the parameter method when called
        /// </summary>
        /// <param name="execute"></param>
        public DelegateCommand(Action<object> execute)
            : this(execute, null)
        {
        }

        /// <summary>
        /// Execute the parameter method when called and when the parameter predicate is satisfied
        /// </summary>
        public DelegateCommand(Action<object> execute, Predicate<object> canExecute)
        {
            if (execute == null) throw new ArgumentNullException("execute");

            _execute = execute;
            _canExecute = canExecute;
        }

        #endregion // ctor

        #region events

        /// <summary>
        /// Event raised when the predicate change
        /// </summary>
        public event EventHandler CanExecuteChanged
        {
            add { CommandManager.RequerySuggested += value; }
            remove { CommandManager.RequerySuggested -= value; }
        }

        #endregion // events

        #region methods

        /// <summary>
        /// Check the value of the predicate
        /// </summary>
        [DebuggerStepThrough]
        public bool CanExecute(object parameter)
        {
            return _canExecute == null ? true : _canExecute(parameter);
        }

        /// <summary>
        /// Execute the method
        /// </summary>
        public void Execute(object parameter)
        {
            _execute(parameter);
        }

        #endregion // methods
    }
}


text:
name: "\U0001F41B Bug report"
about: Create a report to help make fp-ts better
---

## 🐛 Bug report

### Current Behavior

<!-- If applicable, add screenshots to help explain your problem. -->

### Expected behavior

<!-- A clear and concise description of what you expected to happen. -->

### Reproducible example

### Suggested solution(s)

<!-- How could we solve this bug? What changes would need to made to fp-ts? -->

### Additional context

<!-- Add any other context about the problem here.  -->

### Your environment

Which versions of fp-ts are affected by this issue? Did this work in previous versions of fp-ts?

<!-- PLEASE FILL THIS OUT -->

| Software   | Version(s) |
| ---------- | ---------- |
| fp-ts      |            |
| TypeScript |            |


text:
//
//  ThumbnailCell.m
//  QuranShortJourney
//
//  Created by Tabish Mufti on 2/2/14.
//  Copyright (c) 2014 Tabish Fayyaz Mufti. All rights reserved.
//

#import "ThumbnailCell.h"

@implementation ThumbnailCell

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end


text:
*{margin:0;padding:0;-webkit-tap-highlight-color:rgba(0,0,0,0);-webkit-text-size-adjust:none;-webkit-user-select:none;-ms-user-select:none;user-select:none;font-family:Arial, "微软雅黑";}
img{border:none;max-width:100%;vertical-align:middle;}
body,p,form,input,button,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6{margin:0;padding:0;list-style:none;overflow-x:hidden}
h1 {font-size: 4rem; line-height: 5.6rem;}
h2 {font-size: 3rem; line-height: 4rem;}
h3 {font-size: 2.2rem; line-height: 3rem;}
h4 {font-size: 1.4rem; font-weight: normal; line-height: 2.2rem;}
h5,h6 {font-size: 1rem; line-height: 1.4rem;}
input,textarea{-webkit-user-select:text;-ms-user-select:text;user-select:text;-webkit-appearance:none;font-size:1em;line-height:1.5em;}
table{border-collapse:collapse;}
input,select,textarea{outline:none;border:none;background:none;}
button{outline:none;}
a{outline:0;cursor:pointer;}
a:link,a:active{text-decoration:none;}
a:visited{color: transparent; text-decoration:none;}
a:hover{color:#ffa42f;text-decoration:none;}
a{text-decoration:none;-webkit-touch-callout:none;}
em,i{font-style:normal;}
li,ol{list-style:none;}
html{font-size:10px;}
:global .clear{clear:both;height:0;font-size:0;line-height:0;visibility:hidden; overflow:hidden;}
:global .fl{float:left;}
:global .fr{float:right;}
body{ margin:0 auto; min-width:320px;color:#666;background:#f6f6f6;height:100%;}

@media screen and (max-width:320px){body,input,select{font-size:10px}}
@media screen and (min-width:320px){body,input,select{font-size:11.25px}}
@media screen and (min-width:400px){body,input,select{font-size:12.5px}}
@media screen and (min-width:480px){body,input,select{font-size:13.75px}}
@media screen and (min-width:560px){body,input,select{font-size:15px}}
@media screen and (min-width:600px){body,input,select{font-size:16.25px}}
@media screen and (min-width:640px){body,input,select{font-size:18px}}


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

    <title>presentacio Class Hierarchy</title>
    <meta name="date" content="2015-11-11">
    <link rel="stylesheet" type="text/css" href="../stylesheet.css" title="Style">

JavaScript is disabled on your browser.

Skip navigation links

Overview

Package

Class

Tree

Deprecated

Index

Help

Prev

Next

Frames

No Frames

All Classes

Hierarchy For Package presentacio

    Package Hierarchies:

All Packages

Class Hierarchy

java.lang.Object

presentacio.DriverAdminPlayers
                    (implements domini.Basic.Driver)

presentacio.DriverBoardCreator

presentacio.DriverCell

presentacio.DriverColumn

presentacio.DriverKKBoard (implements domini.Basic.Driver)

presentacio.DriverKKBoardPrinter
                    (implements domini.Basic.Driver)

presentacio.DriverMatch

presentacio.DriverRegion

Skip navigation links

Overview

Package

Class

Tree

Deprecated

Index

Help

Prev

Next

Frames

No Frames

All Classes


text:
import pytest
from funcy.decorators import *

def test_decorator_no_args():
    @decorator
    def inc(call):
        return call() + 1

    @inc
    def ten():
        return 10

    assert ten() == 11

def test_decorator_with_args():
    @decorator
    def add(call, n):
        return call() + n

    @add(2)
    def ten():
        return 10

    assert ten() == 12

def test_decorator_access_arg():
    @decorator
    def multiply(call):
        return call() * call.n

    @multiply
    def square(n):
        return n

    assert square(5) == 25

def test_decorator_access_nonexistent_arg():
    @decorator
    def return_x(call):
        return call.x

    @return_x
    def f():
        pass

    with pytest.raises(AttributeError): f()

def test_decorator_with_method():
    @decorator
    def inc(call):
        return call() + 1

    class A(object):
        def ten(self):
            return 10

        @classmethod
        def ten_cls(cls):
            return 10

        @staticmethod
        def ten_static():
            return 10

    assert inc(A().ten)() == 11
    assert inc(A.ten_cls)() == 11
    assert inc(A.ten_cls)() == 11
    assert inc(A.ten_static)() == 11

def test_decorator_with_method_descriptor():
    @decorator
    def exclaim(call):
        return call() + '!'

    assert exclaim(str.upper)('hi') == 'HI!'

def test_chain_arg_access():
    @decorator
    def decor(call):
        return call.x + call()

    @decor
    @decor
    def func(x):
        return x

    assert func(2) == 6

def test_meta_attribtes():
    @decorator
    def decor(call):
        return call()

    def func(x):
        "Some doc"
        return x

    decorated = decor(func)
    double_decorated = decor(decorated)

    assert decorated.__name__ == 'func'
    assert decorated.__module__ == __name__
    assert decorated.__doc__ == "Some doc"
    assert decorated.__wrapped__ is func
    assert decorated.__original__ is func

    assert double_decorated.__wrapped__ is decorated
    assert double_decorated.__original__ is func


text:
YUI.add('querystring-parse-simple', function (Y, NAME) {

// @TODO this looks like we are requiring the user to extract the querystring
// portion of the url, which isn't good.  The majority use case will be to
// extract querystring from the document configured for this YUI instance.
// This should be the default if qs is not supplied.

/*global Y */
/**
 *
Provides Y.QueryString.parse method for converting Query Strings to an object.
 * This is a simpler implementation than the full querystring-parse.

 *
Because some things may require basic query string escaping functionality,
 * this module provides the bare minimum functionality (decoding a hash of simple values),
 * without the additional support for arrays, objects, and so on.

 *
This provides a friendly way to deserialize basic query strings, without necessitating
 * a lot of code for simple use-cases.

 *
 * @module querystring
 * @submodule querystring-parse-simple
 */

var QueryString = Y.namespace("QueryString");

QueryString.parse = function (qs, sep, eq) {
    sep = sep || "&";
    eq = eq || "=";
    for (
        var obj = {},
            i = 0,
            pieces = qs.split(sep),
            l = pieces.length,
            tuple;
        i < l;
        i ++
    ) {
        tuple = pieces[i].split(eq);
        if (tuple.length > 0) {
            obj[QueryString.unescape(tuple.shift())] = QueryString.unescape(tuple.join(eq));
        }
    }
    return obj;
};

QueryString.unescape = function (s) {
    return decodeURIComponent(s.replace(/\+/g, ' '));
};

}, '3.17.1', {"requires": ["yui-base"]});


text:
using Ocaramba;
using Ocaramba.Extensions;
using Ocaramba.Types;
using Ocaramba.Tests.PageObjects;

namespace Ocaramba.Tests.Angular.PageObjects
{
    using System.Globalization;
    using NLog;
    using System;

    public class ProtractorHomePage : ProjectPageBase
    {
#if net47
        private static readonly NLog.Logger Logger = LogManager.GetCurrentClassLogger();
#endif
#if netcoreapp3_1
        private static readonly NLog.Logger Logger = NLog.Web.NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger();
#endif

        /// <summary>
        /// Locators for elements
        /// </summary>
        private readonly ElementLocator
            QuickStart = new ElementLocator(Locator.Id, "drop1"),
            Tutorial = new ElementLocator(Locator.CssSelector, "li[class*='open']>ul>li>a[href*='tutorial']");

        public ProtractorHomePage OpenProtractorHomePage()
        {
            var url = BaseConfiguration.GetUrlValue;
            this.Driver.SynchronizeWithAngular(true);
            this.Driver.NavigateTo(new Uri(url));
            Logger.Info(CultureInfo.CurrentCulture, "Opening page {0}", url);
            return this;
        }

        public ProtractorHomePage(DriverContext driverContext) : base(driverContext)
        {
        }

        public ProtractorHomePage ClickQuickStart()
        {
            this.Driver.GetElement(this.QuickStart).JavaScriptClick();
            return this;
        }

        public TutorialPage ClickTutorial()
        {
            this.Driver.GetElement(this.Tutorial).Click();
            return new TutorialPage(this.DriverContext);
        }
    }
}


text:
package org.jamocha.dn.memory.javaimpl;

import org.apache.commons.lang3.tuple.Pair;
import org.jamocha.dn.memory.FactIdentifier;
import org.jamocha.dn.memory.MemoryFact;
import org.jamocha.dn.memory.Template;
import org.jamocha.dn.nodes.CouldNotAcquireLockException;
import org.jamocha.dn.nodes.Edge;
import org.jamocha.dn.nodes.Node;
import org.jamocha.filter.AddressNodeFilterSet;

/**
 * @author Fabian Ohler <fabian.ohler1@rwth-aachen.de>
 */
public class MemoryHandlerMainWithExistentials extends MemoryHandlerMain {

    final boolean[] existential;
    JamochaArray<Row> allRows = new JamochaArray<>();

    MemoryHandlerMainWithExistentials(final Template[] template, final Counter counter, final FactAddress[] addresses,
            final boolean[] existential) {
        super(template, counter, addresses);
        this.existential = existential;
    }

    @Override
    public Row newRow(final Fact[] factTuple) {
        assert factTuple.length == this.template.length;
        return new RowWithCounters(factTuple, new int[this.counter.getColumns().length]);
    }

    @Override
    public Row newRow() {
        return newRow(new Fact[template.length]);
    }

    @Override
    public org.jamocha.dn.memory.MemoryHandlerTemp processTokenInBeta(
            final org.jamocha.dn.memory.MemoryHandlerTemp token, final Edge originIncomingEdge,
            final AddressNodeFilterSet filter) throws CouldNotAcquireLockException {
        return ((MemoryHandlerTemp) token).newBetaTemp(this, originIncomingEdge, filter);
    }

    @Override
    public org.jamocha.dn.memory.MemoryHandlerTemp processTokenInAlpha(
            final org.jamocha.dn.memory.MemoryHandlerTemp token, final Edge originIncomingEdge,
            final AddressNodeFilterSet filter) throws CouldNotAcquireLockException {
        return ((MemoryHandlerTemp) token).newAlphaTemp(this, originIncomingEdge, filter);
    }

    @Override
    public Pair<? extends org.jamocha.dn.memory.MemoryHandlerPlusTemp, MemoryFact[]> newPlusToken(final Node otn,
            final org.jamocha.dn.memory.Fact... facts) {
        return MemoryHandlerPlusTemp.newRootTemp(this, otn, facts);
    }

    @Override
    public org.jamocha.dn.memory.MemoryHandlerMinusTemp newMinusToken(final MemoryFact... facts) {
        return MemoryHandlerMinusTemp.newRootTemp(this, facts);
    }

    @Override
    public FactIdentifier[] getFactIdentifiers(final int row) {
        final FactIdentifier[] factIdentifiers = super.getFactIdentifiers(row);
        for (int i = 0; i < existential.length; i++) {
            if (existential[i]) {
                factIdentifiers[i] = null;
            }
        }
        return factIdentifiers;
    }
}


text:
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.168039.svg)](https://doi.org/10.5281/zenodo.168039)

## Survey of macroinvertebrates found in Bromeliads
Study location: Ilha do Cardoso, São Paulo, Brasil, (25° 03' S, 47° 53' W)

**If re-using this data, please cite the version which is [archived on Zenodo](https://doi.org/10.5281/zenodo.168039)**

### Data format

The data is in the [data directory](data/), stored as rectangular CSV files. There are four files with data, and a fifth containing the metadata:

* **`abundance.csv`**: Abundances of species in bromeliads. Data is in a "long" format, with one row for every bromeliad x species combination.
* **`environmental_variables.csv`**: Environmental variables measured on each bromeliad. One row per bromeliad species.
* **`macroinvertebrate_names_mass.csv`**: Traits and notes at the level of each morphospecies. One row for every distinct morphospecies found.
* **`predator_names.csv`**: A list of all taxa known to be predators. This also maps morphospecies to higher taxonomic levels, where that is necessary.
* **`metadata_dictionary.csv`**: describes the variables in each dataset in detail
### Methods

In 2008, each bromeliad was dissected and washed to remove invertebrates. We passed this water through two sieves (150 and 850 µm), which removed
particulate organic matter without losing any invertebrates. All invertebrates
were counted and identified to the lowest taxonomic level possible. The body
length of all individuals was measured when possible for small and medium-sized
taxa (< 1cm final instar) and always for large-bodied taxa (> 1 cm final
instar).

_**Acknowledgements**: GQR is grateful to the Brazilian Council for Research, Development and Innovation (CNPq) and São Paulo Research Foundation (FAPESP) for research fund and productivity grant. DSS was supported by a NSERC Discovery grants and an E.W.R. Steacie Memorial fellowship._


text:
@interface PartnerDataViewController ()<UITableViewDelegate,UITableViewDataSource,EditingControllerBackStringDelegate,UIGestureRecognizerDelegate>

@property (nonatomic,strong) UITableView *tableView;

@property (strong,nonatomic) UIView *footerView;

@property (strong,nonatomic) NSMutableArray *titleAry;
@property (strong,nonatomic) NSMutableArray *sLabAry;

@end

@implementation PartnerDataViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.navigationItem.title = @"合伙人资料";
    self.view.backgroundColor = whiteC;
    [self.view addSubview:self.tableView];

    self.titleAry = [NSMutableArray arrayWithObjects:@"投资领域",@"投资区域",@"合伙方式",@"投资额度",@"个人简介",@"合伙期望",nil];
    self.sLabAry = [NSMutableArray arrayWithObjects:@"请选择",@"请选择",@"请选择",@"请填写(单位万元)",@"请填写",@"请填写", nil];

    self.navigationController.interactivePopGestureRecognizer.delegate = self;
}

-(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{
    if (self.navigationController.viewControllers.count == 1) {
        return NO;
    }
    else{
        return YES;
    }
}

#pragma mark /--------懒加载--------/
-(UIView *)footerView{
    if (!_footerView) {
        _footerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 120)];
        _footerView.backgroundColor = whiteC;

        UIButton *saveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [saveBtn setTitle:@"保存" forState:UIControlStateNormal];
        saveBtn.backgroundColor = blueC;
        saveBtn.layer.masksToBounds = YES;
        saveBtn.layer.cornerRadius = 3;
        [saveBtn addTarget:self action:@selector(saveBtnClick) forControlEvents:UIControlEventTouchUpInside];
        [_footerView addSubview:saveBtn];
        [saveBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.and.bottom.equalTo(_footerView);
            make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH-30, formBtnHeight));
        }];
    }
    return _footerView;
}

-(void)saveBtnClick{

}

#pragma mark /--------tableView--------/
-(UITableView *)tableView{
    if (!_tableView) {
        _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-64) style:UITableViewStyleGrouped];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.tableFooterView = self.footerView;
        _tableView.tableFooterView.height = self.footerView.height;
        _tableView.backgroundColor = whiteC;
        _tableView.sectionFooterHeight = 0;
        _tableView.separatorStyle = NO;
    }
    return _tableView;
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0) {
        return 1;
    }
    return 6;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    return formCellHeight;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{

    UIView *headView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, topToMargin)];
    headView.backgroundColor = grayC;

    return headView;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if (section==0) {
        return topToMargin;
    }
    return leftToMargin;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    YCYMFormTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ca"];
    if (cell == nil) {
        cell = [[YCYMFormTableViewCell alloc]initWithFrame:cell.bounds];
        cell.selectLabel.text = indexPath.section==0?@"":self.sLabAry[indexPath.row];

        NSMutableAttributedString *attributedStr = [[NSMutableAttributedString alloc]initWithString:indexPath.section==0?@"   我要创业":self.titleAry[indexPath.row]];
        [attributedStr addAttribute:NSForegroundColorAttributeName value:indexPath.section==0?MainColor:redC range:NSMakeRange(0, 1)];
        if (indexPath.section==0) {
            cell.titleLabel.text = @"   我要创业";
        }else{
            cell.titleLabel.attributedText = [self attributedStr:self.titleAry[indexPath.row]];
        }
    }
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (indexPath.section==0) {
        VtPersonFormViewController *vc = [VtPersonFormViewController new];
        [self.navigationController pushViewController:vc animated:YES];
    }
    else{
        if (indexPath.row==0||indexPath.row==1||indexPath.row==2) {
            NSArray *fieldAry = @[@"移动互联网",@"金融",@"企业服务",@"教育",@"医疗健康",@"旅游"];
            NSArray *zoneAry = @[@"北京",@"上海",@"广州",@"深圳",@"杭州",@"西安"];
            NSArray *modeAry = @[@"战略联盟",@"业务外包"];
            NSArray *arr = [NSArray arrayWithObjects:fieldAry,zoneAry,modeAry, nil];

            SingleSelectView *single = [[SingleSelectView alloc]initWithFrame:SCREEN_BOUNDS SelectTtitle:self.titleAry[indexPath.row] TitleArr:arr[indexPath.row]];
            [single showView:^(NSString *singleStr) {
                [self.sLabAry replaceObjectAtIndex:indexPath.row withObject:singleStr];
                [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:indexPath.row inSection:1], nil] withRowAnimation:UITableViewRowAnimationNone];
            }];
        }
        else{
            EditingController *editVc = [[EditingController alloc]init];
            editVc.kindTitle = self.titleAry[indexPath.row];
            editVc.selectIndex = indexPath.row;
            editVc.delegate = self;
            MainNavigationController *vc = [[MainNavigationController alloc]initWithRootViewController:editVc];
            [self presentViewController:vc animated:YES completion:nil];
        }
    }
}

-(void)backStringToComeViewWith:(EditingController *)editVc andTag:(NSInteger)index{
//    if (index==3||index==4||index==5) {
//        if (![editVc.editText isEqualToString:@""]) {
//            [self.sLabAry replaceObjectAtIndex:index withObject:editVc.editText];
//            [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:index inSection:1], nil] withRowAnimation:UITableViewRowAnimationNone];
//        }
//    }
}

//红色星星✨
-(NSMutableAttributedString *)attributedStr:(NSString *)str{
    NSMutableAttributedString *attributedStr = [[NSMutableAttributedString alloc]initWithString:[@"* "stringByAppendingString:str]];
    [attributedStr addAttribute:NSForegroundColorAttributeName value:redC range:NSMakeRange(0, 1)];
    return attributedStr;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end


text:
// This code was stolen from
// https://github.com/google/googletest/blob/master/googletest/docs/Primer.md
// and adopted
#include "gtest/gtest.h"

#include <boost/filesystem.hpp>

#include <fstream>
#include <iostream>
#include <string>

class Foo {
 public:
  int Bar(const std::string &input_filepath,
          const std::string output_filepath) {
    std::cout << "I: " << input_filepath << std::endl;
    std::cout << "O: " << output_filepath << std::endl;

    if (boost::filesystem::exists(input_filepath) &&
        boost::filesystem::exists(output_filepath)) {
      return 0;
    }

    return 1;
  }
};

namespace {

/*
// In C++17, you can use string_view:
using namespace std::string_view_literals;
constexpr std::string_view sv = "hello, world"sv;
*/
static constexpr auto input_filepath = "myinputfile.dat";
static constexpr auto output_filepath = "myoutputfile.dat";

// The fixture for testing class Foo.
class FooTest : public ::testing::Test {
 protected:
  // You can remove any or all of the following functions if its body
  // is empty.

  FooTest() {
    // You can do set-up work for each test here.
    std::ofstream input_file{input_filepath};
    input_file << "Some Test Data";
    std::ofstream output_file{output_filepath};
    input_file << "Some Test Data";
  }

  virtual ~FooTest() {
    try {
      // You can do clean-up work that doesn't throw exceptions here.
      boost::filesystem::remove(input_filepath);
      boost::filesystem::remove(output_filepath);
    } catch (...) {
      std::cerr << "Nothing to remove here." << std::endl;
    }
  }

  // If the constructor and destructor are not enough for setting up
  // and cleaning up each test, you can define the following methods:

  virtual void SetUp() {
    // Code here will be called immediately after the constructor (right
    // before each test).
  }

  virtual void TearDown() {
    // Code here will be called immediately after each test (right
    // before the destructor).
  }

  // Objects declared here can be used by all tests in the test case for Foo.
};

// Tests that the Foo::Bar() method does Abc.
TEST_F(FooTest, MethodBarDoesAbc) {
  Foo f;
  EXPECT_EQ(0, f.Bar(input_filepath, output_filepath));
}

}  // namespace


text:
TOKEN=`curl -X PUT "http://169.254.169.254/latest/api/token" -v -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"`

while read common specific; do
    value=`curl -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/${specific}`
    echo ${common}=\"${value}\"
done << EOF
    Image ami-id
    VMType instance-type
    Zone placement/availability-zone
    Region placement/region
    InstanceID instance-id
EOF

echo 'Provider="AWS"'
echo 'Platform="EC2"'

interruptible="False"
ilc=`curl -H "X-aws-ec2-metadata-token: $TOKEN" -v http://169.254.169.254/latest/meta-data/instance-life-cycle`
if [[ $ilc == "spot" ]]; then
    interruptible="True"
fi
echo "Interruptible=${interruptible}"

echo "- update:true"


text:
/**
 * @fileoverview Tests for config object.
 * @author Seth McLaughlin
 */
"use strict";

//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------

const assert = require("chai").assert,
    path = require("path"),
    fs = require("fs"),
    os = require("os"),
    Config = require("../../lib/config"),
    Linter = require("../../lib/linter"),
    environments = require("../../conf/environments"),
    sinon = require("sinon"),
    mockFs = require("mock-fs");

const DIRECTORY_CONFIG_HIERARCHY = require("../fixtures/config-hierarchy/file-structure.json");

const linter = new Linter();

require("shelljs/global");

const proxyquire = require("proxyquire").noCallThru().noPreserveCache();

/* global mkdir, rm, cp */

/**
 * Creates a stubbed Config object that will bypass normal require() to load
 * plugins by name from the objects specified.
 * @param {Object} plugins The keys are the package names, values are plugin objects.
 * @returns {Config} The stubbed instance of Config.
 * @private
 */
function createStubbedConfigWithPlugins(plugins) {

    // stub out plugins
    const StubbedPlugins = proxyquire("../../lib/config/plugins", plugins);

    // stub out config file to use stubbed plugins
    const StubbedConfigFile = proxyquire("../../lib/config/config-file", {
        "./plugins": StubbedPlugins
    });

    // stub out Config to use stub config file
    return proxyquire("../../lib/config", {
        "./config/config-file": StubbedConfigFile,
        "./config/plugins": StubbedPlugins
    });
}

/**
 * Asserts that two configs are equal. This is necessary because assert.deepEqual()
 * gets confused when properties are in different orders.
 * @param {Object} actual The config object to check.
 * @param {Object} expected What the config object should look like.
 * @returns {void}
 * @private
 */
function assertConfigsEqual(actual, expected) {
    if (actual.env && expected.env) {
        assert.deepEqual(actual.env, expected.env);
    }

    if (actual.parserOptions && expected.parserOptions) {
        assert.deepEqual(actual.parserOptions, expected.parserOptions);
    }

    if (actual.globals && expected.globals) {
        assert.deepEqual(actual.globals, expected.globals);
    }

    if (actual.rules && expected.rules) {
        assert.deepEqual(actual.rules, expected.rules);
    }

    if (actual.plugins && expected.plugins) {
        assert.deepEqual(actual.plugins, expected.plugins);
    }
}

//------------------------------------------------------------------------------
// Tests
//------------------------------------------------------------------------------

describe("Config", () => {

    let fixtureDir,
        sandbox;

    /**
     * Returns the path inside of the fixture directory.
     * @returns {string} The path inside the fixture directory.
     * @private
     */
    function getFixturePath() {
        const args = Array.prototype.slice.call(arguments);

        args.unshift("config-hierarchy");
        args.unshift(fixtureDir);
        return path.join.apply(path, args);
    }

    /**
     * Mocks the current CWD path
     * @param {string} fakeCWDPath - fake CWD path
     * @returns {void}
     * @private
     */
    function mockCWDResponse(fakeCWDPath) {
        sandbox.stub(process, "cwd")
            .returns(fakeCWDPath);
    }

    /**
     * Mocks the current user's home path
     * @param {string} fakeUserHomePath - fake user's home path
     * @returns {void}
     * @private
     */
    function mockOsHomedir(fakeUserHomePath) {
        sandbox.stub(os, "homedir")
            .returns(fakeUserHomePath);
    }

    // copy into clean area so as not to get "infected" by this project's .eslintrc files
    before(() => {
        fixtureDir = `${os.tmpdir()}/eslint/fixtures`;
        mkdir("-p", fixtureDir);
        cp("-r", "./tests/fixtures/config-hierarchy", fixtureDir);
    });

    beforeEach(() => {
        sandbox = sinon.sandbox.create();
    });

    afterEach(() => {
        sandbox.verifyAndRestore();
    });

    after(() => {
        rm("-r", fixtureDir);
    });

    describe("new Config()", () => {

        // https://github.com/eslint/eslint/issues/2380
        it("should not modify baseConfig when format is specified", () => {
            const customBaseConfig = { foo: "bar" },
                configHelper = new Config({ baseConfig: customBaseConfig, format: "foo" }, linter);

            // at one point, customBaseConfig.format would end up equal to "foo"...that's bad
            assert.deepEqual(customBaseConfig, { foo: "bar" });
            assert.equal(configHelper.options.format, "foo");
        });

        it("should create config object when using baseConfig with extends", () => {
            const customBaseConfig = {
                extends: path.resolve(__dirname, "..", "fixtures", "config-extends", "array", ".eslintrc")
            };
            const configHelper = new Config({ baseConfig: customBaseConfig }, linter);

            assert.deepEqual(configHelper.baseConfig.env, {
                browser: false,
                es6: true,
                node: true
            });
            assert.deepEqual(configHelper.baseConfig.rules, {
                "no-empty": 1,
                "comma-dangle": 2,
                "no-console": 2
            });
        });
    });

    describe("findLocalConfigFiles()", () => {

        /**
         * Returns the path inside of the fixture directory.
         * @returns {string} The path inside the fixture directory.
         * @private
         */
        function getFakeFixturePath() {
            const args = Array.prototype.slice.call(arguments);

            args.unshift("config-hierarchy");
            args.unshift("fixtures");
            args.unshift("eslint");
            args.unshift(process.cwd());
            return path.join.apply(path, args);
        }

        before(() => {
            mockFs({
                eslint: {
                    fixtures: {
                        "config-hierarchy": DIRECTORY_CONFIG_HIERARCHY
                    }
                }
            });
        });

        after(() => {
            mockFs.restore();
        });

        it("should return the path when an .eslintrc file is found", () => {
            const configHelper = new Config({}, linter),
                expected = getFakeFixturePath("broken", ".eslintrc"),
                actual = Array.from(
                    configHelper.findLocalConfigFiles(getFakeFixturePath("broken"))
                );

            assert.equal(actual[0], expected);
        });

        it("should return an empty array when an .eslintrc file is not found", () => {
            const configHelper = new Config({}, linter),
                actual = Array.from(
                    configHelper.findLocalConfigFiles(getFakeFixturePath())
                );

            assert.isArray(actual);
            assert.lengthOf(actual, 0);
        });

        it("should return package.json only when no other config files are found", () => {
            const configHelper = new Config({}, linter),
                expected0 = getFakeFixturePath("packagejson", "subdir", "package.json"),
                expected1 = getFakeFixturePath("packagejson", ".eslintrc"),
                actual = Array.from(
                    configHelper.findLocalConfigFiles(getFakeFixturePath("packagejson", "subdir"))
                );

            assert.equal(actual[0], expected0);
            assert.equal(actual[1], expected1);
        });

        it("should return the only one config file even if there are multiple found", () => {
            const configHelper = new Config({}, linter),
                expected = getFakeFixturePath("broken", ".eslintrc"),

                // The first element of the array is the .eslintrc in the same directory.
                actual = Array.from(
                    configHelper.findLocalConfigFiles(getFakeFixturePath("broken"))
                );

            assert.equal(actual.length, 1);
            assert.equal(actual, expected);
        });

        it("should return all possible files when multiple are found", () => {
            const configHelper = new Config({}, linter),
                expected = [
                    getFakeFixturePath("fileexts/subdir/subsubdir/", ".eslintrc.json"),
                    getFakeFixturePath("fileexts/subdir/", ".eslintrc.yml"),
                    getFakeFixturePath("fileexts", ".eslintrc.js")
                ],

                actual = Array.from(
                    configHelper.findLocalConfigFiles(getFakeFixturePath("fileexts/subdir/subsubdir"))
                );

            assert.deepEqual(actual.length, expected.length);
        });

        it("should return an empty array when a package.json file is not found", () => {
            const configHelper = new Config({}, linter),
                actual = Array.from(configHelper.findLocalConfigFiles(getFakeFixturePath()));

            assert.isArray(actual);
            assert.lengthOf(actual, 0);
        });
    });

    describe("getConfig()", () => {

        it("should return the project config when called in current working directory", () => {
            const configHelper = new Config({ cwd: process.cwd() }, linter),
                actual = configHelper.getConfig();

            assert.equal(actual.rules.strict[1], "global");
        });

        it("should not retain configs from previous directories when called multiple times", () => {

            const firstpath = path.resolve(__dirname, "..", "fixtures", "configurations", "single-quotes", "subdir", ".eslintrc");
            const secondpath = path.resolve(__dirname, "..", "fixtures", "configurations", "single-quotes", ".eslintrc");

            const configHelper = new Config({ cwd: process.cwd() }, linter);
            let config;

            config = configHelper.getConfig(firstpath);
            assert.equal(config.rules["no-new"], 0);
            config = configHelper.getConfig(secondpath);
            assert.equal(config.rules["no-new"], 1);
        });

        it("should throw an error when an invalid path is given", () => {
            const configPath = path.resolve(__dirname, "..", "fixtures", "configurations", "foobaz", ".eslintrc");
            const homePath = "does-not-exist";

            mockOsHomedir(homePath);
            const StubbedConfig = proxyquire("../../lib/config", {});

            const configHelper = new StubbedConfig({ cwd: process.cwd() }, linter);

            sandbox.stub(fs, "readdirSync").throws(new Error());

            assert.throws(() => {
                configHelper.getConfig(configPath);
            }, "No ESLint configuration found.");
        });

        it("should throw error when a configuration file doesn't exist", () => {
            const configPath = path.resolve(__dirname, "..", "fixtures", "configurations", ".eslintrc");
            const configHelper = new Config({ cwd: process.cwd() }, linter);

            sandbox.stub(fs, "readFileSync").throws(new Error());

            assert.throws(() => {
                configHelper.getConfig(configPath);
            }, "Cannot read config file");

        });

        it("should throw error when a configuration file is not require-able", () => {
            const configPath = ".eslintrc";
            const configHelper = new Config({ cwd: process.cwd() }, linter);

            sandbox.stub(fs, "readFileSync").throws(new Error());

            assert.throws(() => {
                configHelper.getConfig(configPath);
            }, "Cannot read config file");

        });

        it("should cache config when the same directory is passed twice", () => {
            const configPath = path.resolve(__dirname, "..", "fixtures", "configurations", "single-quotes", ".eslintrc");
            const configHelper = new Config({ cwd: process.cwd() }, linter);

            sandbox.spy(configHelper, "findLocalConfigFiles");

            // If cached this should be called only once
            configHelper.getConfig(configPath);
            const callcount = configHelper.findLocalConfigFiles.callcount;

            configHelper.getConfig(configPath);

            assert.equal(configHelper.findLocalConfigFiles.callcount, callcount);
        });

        // make sure JS-style comments don't throw an error
        it("should load the config file when there are JS-style comments in the text", () => {
            const configPath = path.resolve(__dirname, "..", "fixtures", "configurations", "comments.json"),
                configHelper = new Config({ configFile: configPath }, linter),
                semi = configHelper.specificConfig.rules.semi,
                strict = configHelper.specificConfig.rules.strict;

            assert.equal(semi, 1);
            assert.equal(strict, 0);
        });

        // make sure YAML files work correctly
        it("should load the config file when a YAML file is used", () => {
            const configPath = path.resolve(__dirname, "..", "fixtures", "configurations", "env-browser.yaml"),
                configHelper = new Config({ configFile: configPath }, linter),
                noAlert = configHelper.specificConfig.rules["no-alert"],
                noUndef = configHelper.specificConfig.rules["no-undef"];

            assert.equal(noAlert, 0);
            assert.equal(noUndef, 2);
        });

        it("should contain the correct value for parser when a custom parser is specified", () => {
            const configPath = path.resolve(__dirname, "../fixtures/configurations/parser/.eslintrc.json"),
                configHelper = new Config({ cwd: process.cwd() }, linter),
                config = configHelper.getConfig(configPath);

            assert.equal(config.parser, path.resolve(path.dirname(configPath), "./custom.js"));
        });

        // Configuration hierarchy ---------------------------------------------

        // https://github.com/eslint/eslint/issues/3915
        it("should correctly merge environment settings", () => {
            const configHelper = new Config({ useEslintrc: true, cwd: process.cwd() }, linter),
                file = getFixturePath("envs", "sub", "foo.js"),
                expected = {
                    rules: {},
                    env: {
                        browser: true,
                        node: false
                    },
                    globals: environments.browser.globals
                },
                actual = configHelper.getConfig(file);

            assertConfigsEqual(actual, expected);
        });

        // Default configuration - blank
        it("should return a blank config when using no .eslintrc", () => {

            const configHelper = new Config({ useEslintrc: false }, linter),
                file = getFixturePath("broken", "console-wrong-quotes.js"),
                expected = {
                    rules: {},
                    globals: {},
                    env: {}
                },
                actual = configHelper.getConfig(file);

            assertConfigsEqual(actual, expected);
        });

        it("should return a blank config when baseConfig is set to false and no .eslintrc", () => {
            const configHelper = new Config({ baseConfig: false, useEslintrc: false }, linter),
                file = getFixturePath("broken", "console-wrong-quotes.js"),
                expected = {
                    rules: {},
                    globals: {},
                    env: {}
                },
                actual = configHelper.getConfig(file);

            assertConfigsEqual(actual, expected);
        });

        // No default configuration
        it("should return an empty config when not using .eslintrc", () => {

            const configHelper = new Config({ useEslintrc: false }, linter),
                file = getFixturePath("broken", "console-wrong-quotes.js"),
                actual = configHelper.getConfig(file);

            assertConfigsEqual(actual, {});
        });

        it("should return a modified config when baseConfig is set to an object and no .eslintrc", () => {

            const configHelper = new Config({
                    baseConfig: {
                        env: {
                            node: true
                        },
                        rules: {
                            quotes: [2, "single"]
                        }
                    },
                    useEslintrc: false
                }, linter),
                file = getFixturePath("broken", "console-wrong-quotes.js"),
                expected = {
                    env: {
                        node: true
                    },
                    rules: {
                        quotes: [2, "single"]
                    }
                },
                actual = configHelper.getConfig(file);

            assertConfigsEqual(actual, expected);
        });

        it("should return a modified config without plugin rules enabled when baseConfig is set to an object with plugin and no .eslintrc", () => {
            const customRule = require("../fixtures/rules/custom-rule");
            const examplePluginName = "eslint-plugin-example";
            const requireStubs = {};

            requireStubs[examplePluginName] = {
                rules: { "example-rule": customRule },

                // rulesConfig support removed in 2.0.0, so this should have no effect
                rulesConfig: { "example-rule": 1 }
            };

            const StubbedConfig = proxyquire("../../lib/config", requireStubs);
            const configHelper = new StubbedConfig({
                    baseConfig: {
                        env: {
                            node: true
                        },
                        rules: {
                            quotes: [2, "single"]
                        },
                        plugins: [examplePluginName]
                    },
                    useEslintrc: false
                }, linter),
                file = getFixturePath("broken", "plugins", "console-wrong-quotes.js"),
                expected = {
                    env: {
                        node: true
                    },
                    rules: {
                        quotes: [2, "single"]
                    }
                },
                actual = configHelper.getConfig(file);

            assertConfigsEqual(actual, expected);
        });

        // Project configuration - second level .eslintrc
        it("should merge configs when local .eslintrc overrides parent .eslintrc", () => {

            const configHelper = new Config({ cwd: process.cwd() }, linter),
                file = getFixturePath("broken", "subbroken", "console-wrong-quotes.js"),
                expected = {
                    env: {
                        node: true
                    },
                    rules: {
                        "no-console": 1,
                        quotes: [2, "single"]
                    }
                },
                actual = configHelper.getConfig(file);

            expected.env.node = true;

            assertConfigsEqual(actual, expected);
        });

        // Project configuration - third level .eslintrc
        it("should merge configs when local .eslintrc overrides parent and grandparent .eslintrc", () => {

            const configHelper = new Config({ cwd: process.cwd() }, linter),
                file = getFixturePath("broken", "subbroken", "subsubbroken", "console-wrong-quotes.js"),
                expected = {
                    env: {
                        node: true
                    },
                    rules: {
                        "no-console": 0,
                        quotes: [1, "double"]
                    }
                },
                actual = configHelper.getConfig(file);

            expected.env.node = true;

            assertConfigsEqual(actual, expected);
        });

        // Project configuration - root set in second level .eslintrc
        it("should not return or traverse configurations in parents of config with root:true", () => {
            const configHelper = new Config({ cwd: process.cwd() }, linter),
                file = getFixturePath("root-true", "parent", "root", "wrong-semi.js"),
                expected = {
                    rules: {
                        semi: [2, "never"]
                    }
                },
                actual = configHelper.getConfig(file);

            assertConfigsEqual(actual, expected);
        });

        // Project configuration - root set in second level .eslintrc
        it("should return project config when called with a relative path from a subdir", () => {
            const configHelper = new Config({ cwd: getFixturePath("root-true", "parent", "root", "subdir") }, linter),
                dir = ".",
                expected = {
                    rules: {
                        semi: [2, "never"]
                    }
                },
                actual = configHelper.getConfig(dir);

            assertConfigsEqual(actual, expected);
        });

        // Command line configuration - --config with first level .eslintrc
        it("should merge command line config when config file adds to local .eslintrc", () => {

            const configHelper = new Config({
                    configFile: getFixturePath("broken", "add-conf.yaml"),
                    cwd: process.cwd()
                }, linter),
                file = getFixturePath("broken", "console-wrong-quotes.js"),
                expected = {
                    env: {
                        node: true
                    },
                    rules: {
                        quotes: [2, "double"],
                        semi: [1, "never"]
                    }
                },
                actual = configHelper.getConfig(file);

            expected.env.node = true;

            assertConfigsEqual(actual, expected);
        });

        // Command line configuration - --config with first level .eslintrc
        it("should merge command line config when config file overrides local .eslintrc", () => {

            const configHelper = new Config({
                    configFile: getFixturePath("broken", "override-conf.yaml"),
                    cwd: process.cwd()
                }, linter),
                file = getFixturePath("broken", "console-wrong-quotes.js"),
                expected = {
                    env: {
                        node: true
                    },
                    rules: {
                        quotes: [0, "double"]
                    }
                },
                actual = configHelper.getConfig(file);

            expected.env.node = true;

            assertConfigsEqual(actual, expected);
        });

        // Command line configuration - --config with second level .eslintrc
        it("should merge command line config when config file adds to local and parent .eslintrc", () => {

            const configHelper = new Config({
                    configFile: getFixturePath("broken", "add-conf.yaml"),
                    cwd: process.cwd()
                }, linter),
                file = getFixturePath("broken", "subbroken", "console-wrong-quotes.js"),
                expected = {
                    env: {
                        node: true
                    },
                    rules: {
                        quotes: [2, "single"],
                        "no-console": 1,
                        semi: [1, "never"]
                    }
                },
                actual = configHelper.getConfig(file);

            expected.env.node = true;

            assertConfigsEqual(actual, expected);
        });

        // Command line configuration - --config with second level .eslintrc
        it("should merge command line config when config file overrides local and parent .eslintrc", () => {

            const configHelper = new Config({
                    configFile: getFixturePath("broken", "override-conf.yaml"),
                    cwd: process.cwd()
                }, linter),
                file = getFixturePath("broken", "subbroken", "console-wrong-quotes.js"),
                expected = {
                    env: {
                        node: true
                    },
                    rules: {
                        quotes: [0, "single"],
                        "no-console": 1
                    }
                },
                actual = configHelper.getConfig(file);

            expected.env.node = true;

            assertConfigsEqual(actual, expected);
        });

        // Command line configuration - --rule with --config and first level .eslintrc
        it("should merge command line config and rule when rule and config file overrides local .eslintrc", () => {

            const configHelper = new Config({
                    configFile: getFixturePath("broken", "override-conf.yaml"),
                    rules: {
                        quotes: [1, "double"]
                    },
                    cwd: process.cwd()
                }, linter),
                file = getFixturePath("broken", "console-wrong-quotes.js"),
                expected = {
                    env: {
                        node: true
                    },
                    rules: {
                        quotes: [1, "double"]
                    }
                },
                actual = configHelper.getConfig(file);

            expected.env.node = true;

            assertConfigsEqual(actual, expected);
        });

        // Command line configuration - --plugin
        it("should merge command line plugin with local .eslintrc", () => {

            // stub out Config to use stub config file
            const StubbedConfig = createStubbedConfigWithPlugins({
                "eslint-plugin-example": {},
                "eslint-plugin-another-plugin": {}
            });

            const configHelper = new StubbedConfig({
                    plugins: ["another-plugin"],
                    cwd: process.cwd()
                }, linter),
                file = getFixturePath("broken", "plugins", "console-wrong-quotes.js"),
                expected = {
                    plugins: [
                        "example",
                        "another-plugin"
                    ]
                },
                actual = configHelper.getConfig(file);

            assertConfigsEqual(actual, expected);
        });

        it("should merge multiple different config file formats", () => {

            const configHelper = new Config({ cwd: process.cwd() }, linter),
                file = getFixturePath("fileexts/subdir/subsubdir/foo.js"),
                expected = {
                    env: {
                        browser: true
                    },
                    rules: {
                        semi: [2, "always"],
                        eqeqeq: 2
                    }
                },
                actual = configHelper.getConfig(file);

            assertConfigsEqual(actual, expected);
        });

        it("should load user config globals", () => {
            const configPath = path.resolve(__dirname, "..", "fixtures", "globals", "conf.yaml"),
                configHelper = new Config({ configFile: configPath, useEslintrc: false }, linter);

            const expected = {
                globals: {
                    foo: true
                }
            };

            const actual = configHelper.getConfig(configPath);

            assertConfigsEqual(actual, expected);
        });

        it("should not load disabled environments", () => {
            const configPath = path.resolve(__dirname, "..", "fixtures", "environments", "disable.yaml");

            const configHelper = new Config({ configFile: configPath, useEslintrc: false }, linter);

            const config = configHelper.getConfig(configPath);

            assert.isUndefined(config.globals.window);
        });

        it("should error on fake environments", () => {
            const configPath = path.resolve(__dirname, "..", "fixtures", "environments", "fake.yaml");

            assert.throw(() => {
                new Config({ configFile: configPath, useEslintrc: false, cwd: process.cwd() }, linter); // eslint-disable-line no-new
            });
        });

        it("should gracefully handle empty files", () => {
            const configPath = path.resolve(__dirname, "..", "fixtures", "configurations", "env-node.json"),
                configHelper = new Config({ configFile: configPath, cwd: process.cwd() }, linter);

            configHelper.getConfig(path.resolve(__dirname, "..", "fixtures", "configurations", "empty", "empty.json"));
        });

        // Meaningful stack-traces
        it("should include references to where an `extends` configuration was loaded from", () => {
            const configPath = path.resolve(__dirname, "..", "fixtures", "config-extends", "error.json");

            assert.throws(() => {
                const configHelper = new Config({ useEslintrc: false, configFile: configPath }, linter);

                configHelper.getConfig(configPath);
            }, /Referenced from:.*?error\.json/);
        });

        // Keep order with the last array element taking highest precedence
        it("should make the last element in an array take the highest precedence", () => {
            const configPath = path.resolve(__dirname, "..", "fixtures", "config-extends", "array", ".eslintrc"),
                configHelper = new Config({ useEslintrc: false, configFile: configPath }, linter),
                expected = {
                    rules: { "no-empty": 1, "comma-dangle": 2, "no-console": 2 },
                    env: { browser: false, node: true, es6: true }
                },
                actual = configHelper.getConfig(configPath);

            assertConfigsEqual(actual, expected);
        });

        describe("with env in a child configuration file", () => {
            it("should not overwrite parserOptions of the parent with env of the child", () => {
                const config = new Config({ cwd: process.cwd() }, linter);
                const targetPath = getFixturePath("overwrite-ecmaFeatures", "child", "foo.js");
                const expected = {
                    rules: {},
                    env: { commonjs: true },
                    parserOptions: { ecmaFeatures: { globalReturn: false } }
                };
                const actual = config.getConfig(targetPath);

                assertConfigsEqual(actual, expected);
            });
        });

        describe("personal config file within home directory", () => {

            /**
             * Returns the path inside of the fixture directory.
             * @returns {string} The path inside the fixture directory.
             * @private
             */
            function getFakeFixturePath() {
                const args = Array.prototype.slice.call(arguments);

                args.unshift("config-hierarchy");
                args.unshift("fixtures");
                args.unshift("eslint");
                args.unshift(process.cwd());
                return path.join.apply(path, args);
            }

            /**
             * Mocks the file system for personal-config files
             * @returns {undefined}
             * @private
             */
            function mockPersonalConfigFileSystem() {
                mockFs({
                    eslint: {
                        fixtures: {
                            "config-hierarchy": DIRECTORY_CONFIG_HIERARCHY
                        }
                    }
                });
            }

            afterEach(() => {
                mockFs.restore();
            });

            it("should load the personal config if no local config was found", () => {
                const projectPath = getFakeFixturePath("personal-config", "project-without-config"),
                    homePath = getFakeFixturePath("personal-config", "home-folder"),
                    filePath = getFakeFixturePath("personal-config", "project-without-config", "foo.js");

                mockOsHomedir(homePath);
                const StubbedConfig = proxyquire("../../lib/config", {});

                mockPersonalConfigFileSystem();
                mockCWDResponse(projectPath);

                const config = new StubbedConfig({ cwd: process.cwd() }, linter),
                    actual = config.getConfig(filePath),
                    expected = {
                        parserOptions: {},
                        env: {},
                        globals: {},
                        parser: void 0,
                        rules: {
                            "home-folder-rule": 2
                        }
                    };

                assert.deepEqual(actual, expected);

                // Ensure that the personal config is cached and isn't reloaded on every call
                assert.strictEqual(config.getPersonalConfig(), config.getPersonalConfig());
            });

            it("should ignore the personal config if a local config was found", () => {
                const projectPath = getFakeFixturePath("personal-config", "home-folder", "project"),
                    homePath = getFakeFixturePath("personal-config", "home-folder"),
                    filePath = getFakeFixturePath("personal-config", "home-folder", "project", "foo.js");

                mockOsHomedir(homePath);
                const StubbedConfig = proxyquire("../../lib/config", {});

                mockPersonalConfigFileSystem();
                mockCWDResponse(projectPath);

                const config = new StubbedConfig({ cwd: process.cwd() }, linter),
                    actual = config.getConfig(filePath),
                    expected = {
                        parserOptions: {},
                        env: {},
                        globals: {},
                        parser: void 0,
                        rules: {
                            "project-level-rule": 2
                        }
                    };

                assert.deepEqual(actual, expected);
            });

            it("should ignore the personal config if config is passed through cli", () => {
                const configPath = getFakeFixturePath("quotes-error.json");
                const projectPath = getFakeFixturePath("personal-config", "project-without-config"),
                    homePath = getFakeFixturePath("personal-config", "home-folder"),
                    filePath = getFakeFixturePath("personal-config", "project-without-config", "foo.js");

                mockOsHomedir(homePath);
                const StubbedConfig = proxyquire("../../lib/config", {});

                mockPersonalConfigFileSystem();
                mockCWDResponse(projectPath);

                const config = new StubbedConfig({ configFile: configPath, cwd: process.cwd() }, linter),
                    actual = config.getConfig(filePath),
                    expected = {
                        parserOptions: {},
                        env: {},
                        globals: {},
                        parser: void 0,
                        rules: {
                            quotes: [2, "double"]
                        }
                    };

                assert.deepEqual(actual, expected);
            });

            it("should still load the project config if the current working directory is the same as the home folder", () => {
                const projectPath = getFakeFixturePath("personal-config", "project-with-config"),
                    filePath = getFakeFixturePath("personal-config", "project-with-config", "subfolder", "foo.js");

                mockOsHomedir(projectPath);
                const StubbedConfig = proxyquire("../../lib/config", {});

                mockPersonalConfigFileSystem();
                mockCWDResponse(projectPath);

                const config = new StubbedConfig({ cwd: process.cwd() }, linter),
                    actual = config.getConfig(filePath),
                    expected = {
                        parserOptions: {},
                        env: {},
                        globals: {},
                        parser: void 0,
                        rules: {
                            "project-level-rule": 2,
                            "subfolder-level-rule": 2
                        }
                    };

                assert.deepEqual(actual, expected);
            });
        });

        describe("when no local or personal config is found", () => {

            /**
             * Returns the path inside of the fixture directory.
             * @returns {string} The path inside the fixture directory.
             * @private
             */
            function getFakeFixturePath() {
                const args = Array.prototype.slice.call(arguments);

                args.unshift("config-hierarchy");
                args.unshift("fixtures");
                args.unshift("eslint");
                args.unshift(process.cwd());
                return path.join.apply(path, args);
            }

            /**
             * Mocks the file system for personal-config files
             * @returns {undefined}
             * @private
             */
            function mockPersonalConfigFileSystem() {
                mockFs({
                    eslint: {
                        fixtures: {
                            "config-hierarchy": DIRECTORY_CONFIG_HIERARCHY
                        }
                    }
                });
            }

            afterEach(() => {
                mockFs.restore();
            });

            it("should throw an error if no local config and no personal config was found", () => {
                const projectPath = getFakeFixturePath("personal-config", "project-without-config"),
                    homePath = getFakeFixturePath("personal-config", "folder-does-not-exist"),
                    filePath = getFakeFixturePath("personal-config", "project-without-config", "foo.js");

                mockOsHomedir(homePath);
                const StubbedConfig = proxyquire("../../lib/config", {});

                mockPersonalConfigFileSystem();
                mockCWDResponse(projectPath);

                const config = new StubbedConfig({ cwd: process.cwd() }, linter);

                assert.throws(() => {
                    config.getConfig(filePath);
                }, "No ESLint configuration found");
            });

            it("should throw an error if no local config was found and ~/package.json contains no eslintConfig section", () => {
                const projectPath = getFakeFixturePath("personal-config", "project-without-config"),
                    homePath = getFakeFixturePath("personal-config", "home-folder-with-packagejson"),
                    filePath = getFakeFixturePath("personal-config", "project-without-config", "foo.js");

                mockOsHomedir(homePath);
                const StubbedConfig = proxyquire("../../lib/config", {});

                mockPersonalConfigFileSystem();
                mockCWDResponse(projectPath);

                const configHelper = new StubbedConfig({ cwd: process.cwd() }, linter);

                assert.throws(() => {
                    configHelper.getConfig(filePath);
                }, "No ESLint configuration found");
            });

            it("should not throw an error if no local config and no personal config was found but useEslintrc is false", () => {
                const projectPath = getFakeFixturePath("personal-config", "project-without-config"),
                    homePath = getFakeFixturePath("personal-config", "folder-does-not-exist"),
                    filePath = getFakeFixturePath("personal-config", "project-without-config", "foo.js");

                mockOsHomedir(homePath);
                const StubbedConfig = proxyquire("../../lib/config", {});

                mockPersonalConfigFileSystem();
                mockCWDResponse(projectPath);

                const config = new StubbedConfig({
                    cwd: process.cwd(),
                    useEslintrc: false
                }, linter);

                assert.doesNotThrow(() => {
                    config.getConfig(filePath);
                }, "No ESLint configuration found");
            });

            it("should not throw an error if no local config and no personal config was found but rules are specified", () => {
                const projectPath = getFakeFixturePath("personal-config", "project-without-config"),
                    homePath = getFakeFixturePath("personal-config", "folder-does-not-exist"),
                    filePath = getFakeFixturePath("personal-config", "project-without-config", "foo.js");

                mockOsHomedir(homePath);
                const StubbedConfig = proxyquire("../../lib/config", {});

                mockPersonalConfigFileSystem();
                mockCWDResponse(projectPath);

                const config = new StubbedConfig({
                    cwd: process.cwd(),
                    rules: { quotes: [2, "single"] }
                }, linter);

                assert.doesNotThrow(() => {
                    config.getConfig(filePath);
                }, "No ESLint configuration found");
            });

            it("should not throw an error if no local config and no personal config was found but baseConfig is specified", () => {
                const projectPath = getFakeFixturePath("personal-config", "project-without-config"),
                    homePath = getFakeFixturePath("personal-config", "folder-does-not-exist"),
                    filePath = getFakeFixturePath("personal-config", "project-without-config", "foo.js");

                mockOsHomedir(homePath);
                const StubbedConfig = proxyquire("../../lib/config", {});

                mockPersonalConfigFileSystem();
                mockCWDResponse(projectPath);

                const config = new StubbedConfig({
                    cwd: process.cwd(),
                    baseConfig: {}
                }, linter);

                assert.doesNotThrow(() => {
                    config.getConfig(filePath);
                }, "No ESLint configuration found");
            });
        });

        describe("with overrides", () => {

            /**
             * Returns the path inside of the fixture directory.
             * @param {...string} pathSegments One or more path segments, in order of depth, shallowest first
             * @returns {string} The path inside the fixture directory.
             * @private
             */
            function getFakeFixturePath() {
                const pathSegments = Array.from(arguments);

                pathSegments.unshift("config-hierarchy");
                pathSegments.unshift("fixtures");
                pathSegments.unshift("eslint");
                pathSegments.unshift(process.cwd());

                return path.join.apply(path, pathSegments);
            }

            before(() => {
                mockFs({
                    eslint: {
                        fixtures: {
                            "config-hierarchy": DIRECTORY_CONFIG_HIERARCHY
                        }
                    }
                });
            });

            after(() => {
                mockFs.restore();
            });

            it("should merge override config when the pattern matches the file name", () => {
                const config = new Config({ cwd: process.cwd() }, linter);
                const targetPath = getFakeFixturePath("overrides", "foo.js");
                const expected = {
                    rules: {
                        quotes: [2, "single"],
                        "no-else-return": 0,
                        "no-unused-vars": 1,
                        semi: [1, "never"]
                    }
                };
                const actual = config.getConfig(targetPath);

                assertConfigsEqual(actual, expected);
            });

            it("should merge override config when the pattern matches the file path relative to the config file", () => {
                const config = new Config({ cwd: process.cwd() }, linter);
                const targetPath = getFakeFixturePath("overrides", "child", "child-one.js");
                const expected = {
                    rules: {
                        curly: ["error", "multi", "consistent"],
                        "no-else-return": 0,
                        "no-unused-vars": 1,
                        quotes: [2, "double"],
                        semi: [1, "never"]
                    }
                };
                const actual = config.getConfig(targetPath);

                assertConfigsEqual(actual, expected);
            });

            it("should not merge override config when the pattern matches the absolute file path", () => {
                const targetPath = getFakeFixturePath("overrides", "bar.js");
                const resolvedPath = path.resolve(__dirname, "..", "fixtures", "config-hierarchy", "overrides", "bar.js");
                const config = new Config({
                    cwd: process.cwd(),
                    baseConfig: {
                        overrides: [{
                            files: resolvedPath,
                            rules: {
                                quotes: [1, "double"]
                            }
                        }],
                        useEslintrc: false
                    }
                }, linter);

                assert.throws(() => config.getConfig(targetPath), /Invalid override pattern/);
            });

            it("should not merge override config when the pattern traverses up the directory tree", () => {
                const targetPath = getFakeFixturePath("overrides", "bar.js");
                const parentPath = "overrides/../**/*.js";

                const config = new Config({
                    cwd: process.cwd(),
                    baseConfig: {
                        overrides: [{
                            files: parentPath,
                            rules: {
                                quotes: [1, "single"]
                            }
                        }],
                        useEslintrc: false
                    }
                }, linter);

                assert.throws(() => config.getConfig(targetPath), /Invalid override pattern/);
            });

            it("should merge all local configs (override and non-override) before non-local configs", () => {
                const config = new Config({ cwd: process.cwd() }, linter);
                const targetPath = getFakeFixturePath("overrides", "two", "child-two.js");
                const expected = {
                    rules: {
                        "no-console": 0,
                        "no-else-return": 0,
                        "no-unused-vars": 2,
                        quotes: [2, "double"],
                        semi: [2, "never"]
                    }
                };
                const actual = config.getConfig(targetPath);

                assertConfigsEqual(actual, expected);
            });

            it("should apply overrides in parent .eslintrc over non-override rules in child .eslintrc", () => {
                const targetPath = getFakeFixturePath("overrides", "three", "foo.js");
                const config = new Config({
                    cwd: getFakeFixturePath("overrides"),
                    baseConfig: {
                        overrides: [
                            {
                                files: "three/**/*.js",
                                rules: {
                                    "semi-style": [2, "last"]
                                }
                            }
                        ]
                    },
                    useEslintrc: false
                }, linter);
                const expected = {
                    rules: {
                        "semi-style": [2, "last"]
                    }
                };
                const actual = config.getConfig(targetPath);

                assertConfigsEqual(actual, expected);
            });

            it("should apply overrides if all glob patterns match", () => {
                const targetPath = getFakeFixturePath("overrides", "one", "child-one.js");
                const config = new Config({
                    cwd: getFakeFixturePath("overrides"),
                    baseConfig: {
                        overrides: [{
                            files: ["one/**/*", "*.js"],
                            rules: {
                                quotes: [2, "single"]
                            }
                        }]
                    },
                    useEslintrc: false
                }, linter);
                const expected = {
                    rules: {
                        quotes: [2, "single"]
                    }
                };
                const actual = config.getConfig(targetPath);

                assertConfigsEqual(actual, expected);
            });

            it("should apply overrides even if some glob patterns do not match", () => {
                const targetPath = getFakeFixturePath("overrides", "one", "child-one.js");
                const config = new Config({
                    cwd: getFakeFixturePath("overrides"),
                    baseConfig: {
                        overrides: [{
                            files: ["one/**/*", "*two.js"],
                            rules: {
                                quotes: [2, "single"]
                            }
                        }]
                    },
                    useEslintrc: false
                }, linter);
                const expected = {
                    rules: {
                        quotes: [2, "single"]
                    }
                };
                const actual = config.getConfig(targetPath);

                assertConfigsEqual(actual, expected);
            });

            it("should not apply overrides if any excluded glob patterns match", () => {
                const targetPath = getFakeFixturePath("overrides", "one", "child-one.js");
                const config = new Config({
                    cwd: getFakeFixturePath("overrides"),
                    baseConfig: {
                        overrides: [{
                            files: "one/**/*",
                            excludedFiles: ["two/**/*", "*one.js"],
                            rules: {
                                quotes: [2, "single"]
                            }
                        }]
                    },
                    useEslintrc: false
                }, linter);
                const expected = {
                    rules: {}
                };
                const actual = config.getConfig(targetPath);

                assertConfigsEqual(actual, expected);
            });

            it("should apply overrides if all excluded glob patterns fail to match", () => {
                const targetPath = getFakeFixturePath("overrides", "one", "child-one.js");
                const config = new Config({
                    cwd: getFakeFixturePath("overrides"),
                    baseConfig: {
                        overrides: [{
                            files: "one/**/*",
                            excludedFiles: ["two/**/*", "*two.js"],
                            rules: {
                                quotes: [2, "single"]
                            }
                        }]
                    },
                    useEslintrc: false
                }, linter);
                const expected = {
                    rules: {
                        quotes: [2, "single"]
                    }
                };
                const actual = config.getConfig(targetPath);

                assertConfigsEqual(actual, expected);
            });

            it("should cascade", () => {
                const targetPath = getFakeFixturePath("overrides", "foo.js");
                const config = new Config({
                    cwd: getFakeFixturePath("overrides"),
                    baseConfig: {
                        overrides: [
                            {
                                files: "foo.js",
                                rules: {
                                    semi: [2, "never"],
                                    quotes: [2, "single"]
                                }
                            },
                            {
                                files: "foo.js",
                                rules: {
                                    semi: [2, "never"],
                                    quotes: [2, "double"]
                                }
                            }
                        ]
                    },
                    useEslintrc: false
                }, linter);
                const expected = {
                    rules: {
                        semi: [2, "never"],
                        quotes: [2, "double"]
                    }
                };
                const actual = config.getConfig(targetPath);

                assertConfigsEqual(actual, expected);
            });
        });
    });

    describe("Plugin Environments", () => {
        it("should load environments from plugin", () => {

            const StubbedConfig = createStubbedConfigWithPlugins({
                "eslint-plugin-test": {
                    environments: { example: { globals: { test: false } } }
                }
            });

            const configPath = path.resolve(__dirname, "..", "fixtures", "environments", "plugin.yaml"),
                configHelper = new StubbedConfig({
                    reset: true, configFile: configPath, useEslintrc: false
                }, linter),
                expected = {
                    env: {
                        "test/example": true
                    },
                    plugins: ["test"]
                },
                actual = configHelper.getConfig(configPath);

            assertConfigsEqual(actual, expected);
        });
    });
});


text:
USE [WEBTRACKING]
GO

/****** Object:  View [dbo].[VW_SUBSET]    Script Date: 11/26/2016 13:22:00 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

ALTER VIEW [dbo].[VW_SUBSET]
AS
SELECT     sequence_number, event, user_ipaddress, user_id, domain_userid, domain_sessionid, dvce_tstamp, page_title, page_urlhost, refr_urlhost, refr_urlpath,
                      page_urlpath, page_url, page_referrer, refr_source, refr_medium, sunburst_page
FROM         dbo.DATA_SET (NOLOCK)
WHERE	event = 'PV'
AND     sunburst_page is not null

GO


text:
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Tests
{
    [TestClass]
    public class PropertyEx_Tests
    {
        [TestMethod]
        public void Name_WhenSelectorExpressionArgumentIsNull_ThrowArgumentNullException()
        {
            // arrange
            // act
            try
            {
                Expression<Func<string>> selectorExpression = null;
                Shiva.PropertyEx.Name(selectorExpression);
                Assert.Fail();
            }
            catch (ArgumentNullException e)
            {
                // assert
                Assert.AreEqual(e.ParamName, "selectorExpression");
            }
        }

        int dummy() { return 0; }

        [TestMethod]
        public void Name_WhenSelectorExpressionArgumentIsNotMemberExpression_ThrowArgumentException()
        {
            // arrange
            // act
            try
            {
                Shiva.PropertyEx.Name<int>(() => dummy());
                Assert.Fail();
            }
            catch (ArgumentException e)
            {
                // assert
                Assert.AreEqual(e.ParamName, "selectorExpression");
            }
        }

        public int MyProperty { get; set; }

        [TestMethod]
        public void Name_WhenArgumentsAreOk_ShouldReturnCorrectly()
        {
            // arrange
            // act
            // assert
            Assert.AreEqual(Shiva.PropertyEx.Name(() => MyProperty), "MyProperty");
        }
    }
}