import { getWeeksInMonth } from './get-weeks-in-month';

describe('getWeeksInMonth', () => {
  it('should work for february 2019', () => {
    const result = getWeeksInMonth(1, 2019);

    expect(result[0]).toEqual({start: 1, end: 3});
    expect(result[4]).toEqual({start: 25, end: 28});
    expect(result.length).toBe(5);
  });

  it('should work for march 2019', () => {
    const result = getWeeksInMonth(2, 2019);
    expect(result[0]).toEqual({start: 1, end: 3});
    expect(result[4]).toEqual({start: 25, end: 31});
    expect(result.length).toBe(5);
  });

  it('should work for april 2019', () => {
    const result = getWeeksInMonth(3, 2019);
    expect(result[0]).toEqual({start: 1, end: 7});
    expect(result[4]).toEqual({start: 29, end: 30});
    expect(result.length).toBe(5);
  });

  it('should work for february 2021', () => {
    const result = getWeeksInMonth(1, 2021);
    expect(result[0]).toEqual({start: 1, end: 7});
    expect(result[3]).toEqual({start: 22, end: 28});
    expect(result.length).toBe(4);
  });
});

{'repo_name': 'johannesjo/super-productivity', 'stars': '2017', 'repo_language': 'TypeScript', 'file_name': 'goToDefaultProject.ts', 'mime_type': 'text/x-java', 'hash': 1791301559127356475, 'source_dataset': 'data'}


<!DOCTYPE html>

  <meta charset="utf-8">
  <title>Linter tests</title>

  <link rel="stylesheet" href="scripts/lib/qunit/qunit-1.10.0.css" />

{'repo_name': 'scripted-editor/scripted', 'stars': '1583', 'repo_language': 'JavaScript', 'file_name': 'github-fs.js', 'mime_type': 'text/plain', 'hash': -5466661065406221090, 'source_dataset': 'data'}


/************************************************************************/
/*									*/
/*	dc395x.h							*/
/*									*/
/*	Device Driver for Tekram DC395(U/UW/F), DC315(U)		*/
/*	PCI SCSI Bus Master Host Adapter				*/
/*	(SCSI chip set used Tekram ASIC TRM-S1040)			*/
/*									*/
/************************************************************************/
#ifndef DC395x_H
#define DC395x_H

/************************************************************************/
/*									*/
/*	Initial values							*/
/*									*/
/************************************************************************/
#define DC395x_MAX_CMD_QUEUE		32
/* #define DC395x_MAX_QTAGS		32 */
#define DC395x_MAX_QTAGS		16
#define DC395x_MAX_SCSI_ID		16
#define DC395x_MAX_CMD_PER_LUN		DC395x_MAX_QTAGS
#define DC395x_MAX_SG_TABLESIZE		64	/* HW limitation			*/
#define DC395x_MAX_SG_LISTENTRY		64	/* Must be equal or lower to previous	*/
						/* item					*/
#define DC395x_MAX_SRB_CNT		63
/* #define DC395x_MAX_CAN_QUEUE		7 * DC395x_MAX_QTAGS */
#define DC395x_MAX_CAN_QUEUE		DC395x_MAX_SRB_CNT
#define DC395x_END_SCAN			2
#define DC395x_SEL_TIMEOUT		153	/* 250 ms selection timeout (@ 40 MHz)	*/
#define DC395x_MAX_RETRIES		3

#if 0
#define SYNC_FIRST
#endif

#define NORM_REC_LVL			0

/************************************************************************/
/*									*/
/*	Various definitions						*/
/*									*/
/************************************************************************/
#define BIT31				0x80000000
#define BIT30				0x40000000
#define BIT29				0x20000000
#define BIT28				0x10000000
#define BIT27				0x08000000
#define BIT26				0x04000000
#define BIT25				0x02000000
#define BIT24				0x01000000
#define BIT23				0x00800000
#define BIT22				0x00400000
#define BIT21				0x00200000
#define BIT20				0x00100000
#define BIT19				0x00080000
#define BIT18				0x00040000
#define BIT17				0x00020000
#define BIT16				0x00010000
#define BIT15				0x00008000
#define BIT14				0x00004000
#define BIT13				0x00002000
#define BIT12				0x00001000
#define BIT11				0x00000800
#define BIT10				0x00000400
#define BIT9				0x00000200
#define BIT8				0x00000100
#define BIT7				0x00000080
#define BIT6				0x00000040
#define BIT5				0x00000020
#define BIT4				0x00000010
#define BIT3				0x00000008
#define BIT2				0x00000004
#define BIT1				0x00000002
#define BIT0				0x00000001

/* UnitCtrlFlag */
#define UNIT_ALLOCATED			BIT0
#define UNIT_INFO_CHANGED		BIT1
#define FORMATING_MEDIA			BIT2
#define UNIT_RETRY			BIT3

/* UnitFlags */
#define DASD_SUPPORT			BIT0
#define SCSI_SUPPORT			BIT1
#define ASPI_SUPPORT			BIT2

/* SRBState machine definition */
#define SRB_FREE			0x0000
#define SRB_WAIT			0x0001
#define SRB_READY			0x0002
#define SRB_MSGOUT			0x0004	/* arbitration+msg_out 1st byte		*/
#define SRB_MSGIN			0x0008
#define SRB_EXTEND_MSGIN		0x0010
#define SRB_COMMAND			0x0020
#define SRB_START_			0x0040	/* arbitration+msg_out+command_out	*/
#define SRB_DISCONNECT			0x0080
#define SRB_DATA_XFER			0x0100
#define SRB_XFERPAD			0x0200
#define SRB_STATUS			0x0400
#define SRB_COMPLETED			0x0800
#define SRB_ABORT_SENT			0x1000
#define SRB_DO_SYNC_NEGO		0x2000
#define SRB_DO_WIDE_NEGO		0x4000
#define SRB_UNEXPECT_RESEL		0x8000

/************************************************************************/
/*									*/
/*	ACB Config							*/
/*									*/
/************************************************************************/
#define HCC_WIDE_CARD			0x20
#define HCC_SCSI_RESET			0x10
#define HCC_PARITY			0x08
#define HCC_AUTOTERM			0x04
#define HCC_LOW8TERM			0x02
#define HCC_UP8TERM			0x01

/* ACBFlag */
#define RESET_DEV			BIT0
#define RESET_DETECT			BIT1
#define RESET_DONE			BIT2

/* DCBFlag */
#define ABORT_DEV_			BIT0

/* SRBstatus */
#define SRB_OK				BIT0
#define ABORTION			BIT1
#define OVER_RUN			BIT2
#define UNDER_RUN			BIT3
#define PARITY_ERROR			BIT4
#define SRB_ERROR			BIT5

/* SRBFlag */
#define DATAOUT				BIT7
#define DATAIN				BIT6
#define RESIDUAL_VALID			BIT5
#define ENABLE_TIMER			BIT4
#define RESET_DEV0			BIT2
#define ABORT_DEV			BIT1
#define AUTO_REQSENSE			BIT0

/* Adapter status */
#define H_STATUS_GOOD			0
#define H_SEL_TIMEOUT			0x11
#define H_OVER_UNDER_RUN		0x12
#define H_UNEXP_BUS_FREE		0x13
#define H_TARGET_PHASE_F		0x14
#define H_INVALID_CCB_OP		0x16
#define H_LINK_CCB_BAD			0x17
#define H_BAD_TARGET_DIR		0x18
#define H_DUPLICATE_CCB			0x19
#define H_BAD_CCB_OR_SG			0x1A
#define H_ABORT				0x0FF

/* SCSI BUS Status byte codes */
#define SCSI_STAT_GOOD			0x0	/* Good status				*/
#define SCSI_STAT_CHECKCOND		0x02	/* SCSI Check Condition			*/
#define SCSI_STAT_CONDMET		0x04	/* Condition Met			*/
#define SCSI_STAT_BUSY			0x08	/* Target busy status			*/
#define SCSI_STAT_INTER			0x10	/* Intermediate status			*/
#define SCSI_STAT_INTERCONDMET		0x14	/* Intermediate condition met		*/
#define SCSI_STAT_RESCONFLICT		0x18	/* Reservation conflict			*/
#define SCSI_STAT_CMDTERM		0x22	/* Command Terminated			*/
#define SCSI_STAT_QUEUEFULL		0x28	/* Queue Full				*/
#define SCSI_STAT_UNEXP_BUS_F		0xFD	/* Unexpect Bus Free			*/
#define SCSI_STAT_BUS_RST_DETECT	0xFE	/* Scsi Bus Reset detected		*/
#define SCSI_STAT_SEL_TIMEOUT		0xFF	/* Selection Time out			*/

/* Sync_Mode */
#define SYNC_WIDE_TAG_ATNT_DISABLE	0
#define SYNC_NEGO_ENABLE		BIT0
#define SYNC_NEGO_DONE			BIT1
#define WIDE_NEGO_ENABLE		BIT2
#define WIDE_NEGO_DONE			BIT3
#define WIDE_NEGO_STATE			BIT4
#define EN_TAG_QUEUEING			BIT5
#define EN_ATN_STOP			BIT6

#define SYNC_NEGO_OFFSET		15

/* SCSI MSG BYTE */
#define MSG_COMPLETE			0x00
#define MSG_EXTENDED			0x01
#define MSG_SAVE_PTR			0x02
#define MSG_RESTORE_PTR			0x03
#define MSG_DISCONNECT			0x04
#define MSG_INITIATOR_ERROR		0x05
#define MSG_ABORT			0x06
#define MSG_REJECT_			0x07
#define MSG_NOP				0x08
#define MSG_PARITY_ERROR		0x09
#define MSG_LINK_CMD_COMPL		0x0A
#define MSG_LINK_CMD_COMPL_FLG		0x0B
#define MSG_BUS_RESET			0x0C
#define MSG_ABORT_TAG			0x0D
#define MSG_SIMPLE_QTAG			0x20
#define MSG_HEAD_QTAG			0x21
#define MSG_ORDER_QTAG			0x22
#define MSG_IGNOREWIDE			0x23
#define MSG_IDENTIFY			0x80
#define MSG_HOST_ID			0xC0

/* SCSI STATUS BYTE */
#define STATUS_GOOD			0x00
#define CHECK_CONDITION_		0x02
#define STATUS_BUSY			0x08
#define STATUS_INTERMEDIATE		0x10
#define RESERVE_CONFLICT		0x18

/* cmd->result */
#define STATUS_MASK_			0xFF
#define MSG_MASK			0xFF00
#define RETURN_MASK			0xFF0000

/************************************************************************/
/*									*/
/*	Inquiry Data format						*/
/*									*/
/************************************************************************/
struct ScsiInqData
{						/* INQ					*/
	u8 DevType;				/* Periph Qualifier & Periph Dev Type	*/
	u8 RMB_TypeMod;				/* rem media bit & Dev Type Modifier	*/
	u8 Vers;				/* ISO, ECMA, & ANSI versions		*/
	u8 RDF;					/* AEN, TRMIOP, & response data format	*/
	u8 AddLen;				/* length of additional data		*/
	u8 Res1;				/* reserved				*/
	u8 Res2;				/* reserved				*/
	u8 Flags;				/* RelADr, Wbus32, Wbus16, Sync, etc.	*/
	u8 VendorID[8];				/* Vendor Identification		*/
	u8 ProductID[16];			/* Product Identification		*/
	u8 ProductRev[4];			/* Product Revision			*/
};

						/* Inquiry byte 0 masks			*/
#define SCSI_DEVTYPE			0x1F	/* Peripheral Device Type		*/
#define SCSI_PERIPHQUAL			0xE0	/* Peripheral Qualifier			*/
						/* Inquiry byte 1 mask			*/
#define SCSI_REMOVABLE_MEDIA		0x80	/* Removable Media bit (1=removable)	*/
						/* Peripheral Device Type definitions	*/
						/* See include/scsi/scsi.h		*/
#define TYPE_NODEV		SCSI_DEVTYPE	/* Unknown or no device type		*/
#ifndef TYPE_PRINTER				/*					*/
# define TYPE_PRINTER			0x02	/* Printer device			*/
#endif						/*					*/
#ifndef TYPE_COMM				/*					*/
# define TYPE_COMM			0x09	/* Communications device		*/
#endif

/************************************************************************/
/*									*/
/*	Inquiry flag definitions (Inq data byte 7)			*/
/*									*/
/************************************************************************/
#define SCSI_INQ_RELADR			0x80	/* device supports relative addressing	*/
#define SCSI_INQ_WBUS32			0x40	/* device supports 32 bit data xfers	*/
#define SCSI_INQ_WBUS16			0x20	/* device supports 16 bit data xfers	*/
#define SCSI_INQ_SYNC			0x10	/* device supports synchronous xfer	*/
#define SCSI_INQ_LINKED			0x08	/* device supports linked commands	*/
#define SCSI_INQ_CMDQUEUE		0x02	/* device supports command queueing	*/
#define SCSI_INQ_SFTRE			0x01	/* device supports soft resets		*/

#define ENABLE_CE			1
#define DISABLE_CE			0
#define EEPROM_READ			0x80

/************************************************************************/
/*									*/
/*	The PCI configuration register offset for TRM_S1040		*/
/*									*/
/************************************************************************/
#define TRM_S1040_ID			0x00	/* Vendor and Device ID			*/
#define TRM_S1040_COMMAND		0x04	/* PCI command register			*/
#define TRM_S1040_IOBASE		0x10	/* I/O Space base address		*/
#define TRM_S1040_ROMBASE		0x30	/* Expansion ROM Base Address		*/
#define TRM_S1040_INTLINE		0x3C	/* Interrupt line			*/

/************************************************************************/
/*									*/
/*	The SCSI register offset for TRM_S1040				*/
/*									*/
/************************************************************************/
#define TRM_S1040_SCSI_STATUS		0x80	/* SCSI Status (R)			*/
#define COMMANDPHASEDONE		0x2000	/* SCSI command phase done		*/
#define SCSIXFERDONE			0x0800	/* SCSI SCSI transfer done		*/
#define SCSIXFERCNT_2_ZERO		0x0100	/* SCSI SCSI transfer count to zero	*/
#define SCSIINTERRUPT			0x0080	/* SCSI interrupt pending		*/
#define COMMANDABORT			0x0040	/* SCSI command abort			*/
#define SEQUENCERACTIVE			0x0020	/* SCSI sequencer active		*/
#define PHASEMISMATCH			0x0010	/* SCSI phase mismatch			*/
#define PARITYERROR			0x0008	/* SCSI parity error			*/

#define PHASEMASK			0x0007	/* Phase MSG/CD/IO			*/
#define PH_DATA_OUT			0x00	/* Data out phase			*/
#define PH_DATA_IN			0x01	/* Data in phase			*/
#define PH_COMMAND			0x02	/* Command phase			*/
#define PH_STATUS			0x03	/* Status phase				*/
#define PH_BUS_FREE			0x05	/* Invalid phase used as bus free	*/
#define PH_MSG_OUT			0x06	/* Message out phase			*/
#define PH_MSG_IN			0x07	/* Message in phase			*/

#define TRM_S1040_SCSI_CONTROL		0x80	/* SCSI Control (W)			*/
#define DO_CLRATN			0x0400	/* Clear ATN				*/
#define DO_SETATN			0x0200	/* Set ATN				*/
#define DO_CMDABORT			0x0100	/* Abort SCSI command			*/
#define DO_RSTMODULE			0x0010	/* Reset SCSI chip			*/
#define DO_RSTSCSI			0x0008	/* Reset SCSI bus			*/
#define DO_CLRFIFO			0x0004	/* Clear SCSI transfer FIFO		*/
#define DO_DATALATCH			0x0002	/* Enable SCSI bus data input (latched)	*/
/* #define DO_DATALATCH			0x0000 */	/* KG: DISable SCSI bus data latch	*/
#define DO_HWRESELECT			0x0001	/* Enable hardware reselection		*/

#define TRM_S1040_SCSI_FIFOCNT		0x82	/* SCSI FIFO Counter 5bits(R)		*/
#define TRM_S1040_SCSI_SIGNAL		0x83	/* SCSI low level signal (R/W)		*/

#define TRM_S1040_SCSI_INTSTATUS	0x84	/* SCSI Interrupt Status (R)		*/
#define INT_SCAM			0x80	/* SCAM selection interrupt		*/
#define INT_SELECT			0x40	/* Selection interrupt			*/
#define INT_SELTIMEOUT			0x20	/* Selection timeout interrupt		*/
#define INT_DISCONNECT			0x10	/* Bus disconnected interrupt		*/
#define INT_RESELECTED			0x08	/* Reselected interrupt			*/
#define INT_SCSIRESET			0x04	/* SCSI reset detected interrupt	*/
#define INT_BUSSERVICE			0x02	/* Bus service interrupt		*/
#define INT_CMDDONE			0x01	/* SCSI command done interrupt		*/

#define TRM_S1040_SCSI_OFFSET		0x84	/* SCSI Offset Count (W)		*/

/************************************************************************/
/*									*/
/*	Bit		Name		Definition			*/
/*	---------	-------------	----------------------------	*/
/*	07-05	0	RSVD		Reversed. Always 0.		*/
/*	04	0	OFFSET4		Reversed for LVDS. Always 0.	*/
/*	03-00	0	OFFSET[03:00]	Offset number from 0 to 15	*/
/*									*/
/************************************************************************/

#define TRM_S1040_SCSI_SYNC		0x85	/* SCSI Synchronous Control (R/W)	*/
#define LVDS_SYNC			0x20	/* Enable LVDS synchronous		*/
#define WIDE_SYNC			0x10	/* Enable WIDE synchronous		*/
#define ALT_SYNC			0x08	/* Enable Fast-20 alternate synchronous	*/

/************************************************************************/
/*									*/
/*	SYNCM	7    6    5    4    3       2       1       0		*/
/*	Name	RSVD RSVD LVDS WIDE ALTPERD PERIOD2 PERIOD1 PERIOD0	*/
/*	Default	0    0    0    0    0       0       0       0		*/
/*									*/
/*	Bit		Name		Definition			*/
/*	---------	-------------	---------------------------	*/
/*	07-06	0	RSVD		Reversed. Always read 0		*/
/*	05	0	LVDS		Reversed. Always read 0		*/
/*	04	0	WIDE/WSCSI	Enable wide (16-bits) SCSI	*/
/*					transfer.			*/
/*	03	0	ALTPERD/ALTPD	Alternate (Sync./Period) mode.	*/
/*									*/
/*			@@ When this bit is set,			*/
/*			   the synchronous period bits 2:0		*/
/*			   in the Synchronous Mode register		*/
/*			   are used to transfer data			*/
/*			   at the Fast-20 rate.				*/
/*			@@ When this bit is unset,			*/
/*			   the synchronous period bits 2:0		*/
/*			   in the Synchronous Mode Register		*/
/*			   are used to transfer data			*/
/*			   at the Fast-10 rate (or Fast-40 w/ LVDS).	*/
/*									*/
/*	02-00	0	PERIOD[2:0]/	Synchronous SCSI Transfer Rate.	*/
/*			SXPD[02:00]	These 3 bits specify		*/
/*					the Synchronous SCSI Transfer	*/
/*					Rate for Fast-20 and Fast-10.	*/
/*					These bits are also reset	*/
/*					by a SCSI Bus reset.		*/
/*									*/
/*	For Fast-10 bit ALTPD = 0 and LVDS = 0				*/
/*	and bit2,bit1,bit0 is defined as follows :			*/
/*									*/
/*	000	100ns, 10.0 MHz						*/
/*	001	150ns,  6.6 MHz						*/
/*	010	200ns,  5.0 MHz						*/
/*	011	250ns,  4.0 MHz						*/
/*	100	300ns,  3.3 MHz						*/
/*	101	350ns,  2.8 MHz						*/
/*	110	400ns,  2.5 MHz						*/
/*	111	450ns,  2.2 MHz						*/
/*									*/
/*	For Fast-20 bit ALTPD = 1 and LVDS = 0				*/
/*	and bit2,bit1,bit0 is defined as follows :			*/
/*									*/
/*	000	 50ns, 20.0 MHz						*/
/*	001	 75ns, 13.3 MHz						*/
/*	010	100ns, 10.0 MHz						*/
/*	011	125ns,  8.0 MHz						*/
/*	100	150ns,  6.6 MHz						*/
/*	101	175ns,  5.7 MHz						*/
/*	110	200ns,  5.0 MHz						*/
/*	111	250ns,  4.0 MHz   KG: Maybe 225ns, 4.4 MHz		*/
/*									*/
/*	For Fast-40 bit ALTPD = 0 and LVDS = 1				*/
/*	and bit2,bit1,bit0 is defined as follows :			*/
/*									*/
/*	000	 25ns, 40.0 MHz						*/
/*	001	 50ns, 20.0 MHz						*/
/*	010	 75ns, 13.3 MHz						*/
/*	011	100ns, 10.0 MHz						*/
/*	100	125ns,  8.0 MHz						*/
/*	101	150ns,  6.6 MHz						*/
/*	110	175ns,  5.7 MHz						*/
/*	111	200ns,  5.0 MHz						*/
/*									*/
/************************************************************************/

#define TRM_S1040_SCSI_TARGETID		0x86	/* SCSI Target ID (R/W)			*/
#define TRM_S1040_SCSI_IDMSG		0x87	/* SCSI Identify Message (R)		*/
#define TRM_S1040_SCSI_HOSTID		0x87	/* SCSI Host ID (W)			*/
#define TRM_S1040_SCSI_COUNTER		0x88	/* SCSI Transfer Counter 24bits(R/W)	*/

#define TRM_S1040_SCSI_INTEN		0x8C	/* SCSI Interrupt Enable (R/W)		*/
#define EN_SCAM				0x80	/* Enable SCAM selection interrupt	*/
#define EN_SELECT			0x40	/* Enable selection interrupt		*/
#define EN_SELTIMEOUT			0x20	/* Enable selection timeout interrupt	*/
#define EN_DISCONNECT			0x10	/* Enable bus disconnected interrupt	*/
#define EN_RESELECTED			0x08	/* Enable reselected interrupt		*/
#define EN_SCSIRESET			0x04	/* Enable SCSI reset detected interrupt	*/
#define EN_BUSSERVICE			0x02	/* Enable bus service interrupt		*/
#define EN_CMDDONE			0x01	/* Enable SCSI command done interrupt	*/

#define TRM_S1040_SCSI_CONFIG0		0x8D	/* SCSI Configuration 0 (R/W)		*/
#define PHASELATCH			0x40	/* Enable phase latch			*/
#define INITIATOR			0x20	/* Enable initiator mode		*/
#define PARITYCHECK			0x10	/* Enable parity check			*/
#define BLOCKRST			0x01	/* Disable SCSI reset1			*/

#define TRM_S1040_SCSI_CONFIG1		0x8E	/* SCSI Configuration 1 (R/W)		*/
#define ACTIVE_NEGPLUS			0x10	/* Enhance active negation		*/
#define FILTER_DISABLE			0x08	/* Disable SCSI data filter		*/
#define FAST_FILTER			0x04	/* ?					*/
#define ACTIVE_NEG			0x02	/* Enable active negation		*/

#define TRM_S1040_SCSI_CONFIG2		0x8F	/* SCSI Configuration 2 (R/W)		*/
#define CFG2_WIDEFIFO			0x02	/*					*/

#define TRM_S1040_SCSI_COMMAND		0x90	/* SCSI Command (R/W)			*/
#define SCMD_COMP			0x12	/* Command complete			*/
#define SCMD_SEL_ATN			0x60	/* Selection with ATN			*/
#define SCMD_SEL_ATN3			0x64	/* Selection with ATN3			*/
#define SCMD_SEL_ATNSTOP		0xB8	/* Selection with ATN and Stop		*/
#define SCMD_FIFO_OUT			0xC0	/* SCSI FIFO transfer out		*/
#define SCMD_DMA_OUT			0xC1	/* SCSI DMA transfer out		*/
#define SCMD_FIFO_IN			0xC2	/* SCSI FIFO transfer in		*/
#define SCMD_DMA_IN			0xC3	/* SCSI DMA transfer in			*/
#define SCMD_MSGACCEPT			0xD8	/* Message accept			*/

/************************************************************************/
/*									*/
/*	Code	Command Description					*/
/*	----	----------------------------------------		*/
/*	02	Enable reselection with FIFO				*/
/*	40	Select without ATN with FIFO				*/
/*	60	Select with ATN with FIFO				*/
/*	64	Select with ATN3 with FIFO				*/
/*	A0	Select with ATN and stop with FIFO			*/
/*	C0	Transfer information out with FIFO			*/
/*	C1	Transfer information out with DMA			*/
/*	C2	Transfer information in with FIFO			*/
/*	C3	Transfer information in with DMA			*/
/*	12	Initiator command complete with FIFO			*/
/*	50	Initiator transfer information out sequence without ATN	*/
/*		with FIFO						*/
/*	70	Initiator transfer information out sequence with ATN	*/
/*		with FIFO						*/
/*	74	Initiator transfer information out sequence with ATN3	*/
/*		with FIFO						*/
/*	52	Initiator transfer information in sequence without ATN	*/
/*		with FIFO						*/
/*	72	Initiator transfer information in sequence with ATN	*/
/*		with FIFO						*/
/*	76	Initiator transfer information in sequence with ATN3	*/
/*		with FIFO						*/
/*	90	Initiator transfer information out command complete	*/
/*		with FIFO						*/
/*	92	Initiator transfer information in command complete	*/
/*		with FIFO						*/
/*	D2	Enable selection					*/
/*	08	Reselection						*/
/*	48	Disconnect command with FIFO				*/
/*	88	Terminate command with FIFO				*/
/*	C8	Target command complete with FIFO			*/
/*	18	SCAM Arbitration/ Selection				*/
/*	5A	Enable reselection					*/
/*	98	Select without ATN with FIFO				*/
/*	B8	Select with ATN with FIFO				*/
/*	D8	Message Accepted					*/
/*	58	NOP							*/
/*									*/
/************************************************************************/

#define TRM_S1040_SCSI_TIMEOUT		0x91	/* SCSI Time Out Value (R/W)		*/
#define TRM_S1040_SCSI_FIFO		0x98	/* SCSI FIFO (R/W)			*/

#define TRM_S1040_SCSI_TCR0		0x9C	/* SCSI Target Control 0 (R/W)		*/
#define TCR0_WIDE_NEGO_DONE		0x8000	/* Wide nego done			*/
#define TCR0_SYNC_NEGO_DONE		0x4000	/* Synchronous nego done		*/
#define TCR0_ENABLE_LVDS		0x2000	/* Enable LVDS synchronous		*/
#define TCR0_ENABLE_WIDE		0x1000	/* Enable WIDE synchronous		*/
#define TCR0_ENABLE_ALT			0x0800	/* Enable alternate synchronous		*/
#define TCR0_PERIOD_MASK		0x0700	/* Transfer rate			*/

#define TCR0_DO_WIDE_NEGO		0x0080	/* Do wide NEGO				*/
#define TCR0_DO_SYNC_NEGO		0x0040	/* Do sync NEGO				*/
#define TCR0_DISCONNECT_EN		0x0020	/* Disconnection enable			*/
#define TCR0_OFFSET_MASK		0x001F	/* Offset number			*/

#define TRM_S1040_SCSI_TCR1		0x9E	/* SCSI Target Control 1 (R/W)		*/
#define MAXTAG_MASK			0x7F00	/* Maximum tags (127)			*/
#define NON_TAG_BUSY			0x0080	/* Non tag command active		*/
#define ACTTAG_MASK			0x007F	/* Active tags				*/

/************************************************************************/
/*									*/
/*	The DMA register offset for TRM_S1040				*/
/*									*/
/************************************************************************/
#define TRM_S1040_DMA_COMMAND		0xA0	/* DMA Command (R/W)			*/
#define DMACMD_SG			0x02	/* Enable HW S/G support		*/
#define DMACMD_DIR			0x01	/* 1 = read from SCSI write to Host	*/
#define XFERDATAIN_SG			0x0103	/* Transfer data in  w/  SG		*/
#define XFERDATAOUT_SG			0x0102	/* Transfer data out w/  SG		*/
#define XFERDATAIN			0x0101	/* Transfer data in  w/o SG		*/
#define XFERDATAOUT			0x0100	/* Transfer data out w/o SG		*/

#define TRM_S1040_DMA_FIFOCNT		0xA1	/* DMA FIFO Counter (R)			*/

#define TRM_S1040_DMA_CONTROL		0xA1	/* DMA Control (W)			*/
#define DMARESETMODULE			0x10	/* Reset PCI/DMA module			*/
#define STOPDMAXFER			0x08	/* Stop  DMA transfer			*/
#define ABORTXFER			0x04	/* Abort DMA transfer			*/
#define CLRXFIFO			0x02	/* Clear DMA transfer FIFO		*/
#define STARTDMAXFER			0x01	/* Start DMA transfer			*/

#define TRM_S1040_DMA_FIFOSTAT		0xA2	/* DMA FIFO Status (R)			*/

#define TRM_S1040_DMA_STATUS		0xA3	/* DMA Interrupt Status (R/W)		*/
#define XFERPENDING			0x80	/* Transfer pending			*/
#define SCSIBUSY			0x40	/* SCSI busy				*/
#define GLOBALINT			0x20	/* DMA_INTEN bit 0-4 set		*/
#define FORCEDMACOMP			0x10	/* Force DMA transfer complete		*/
#define DMAXFERERROR			0x08	/* DMA transfer error			*/
#define DMAXFERABORT			0x04	/* DMA transfer abort			*/
#define DMAXFERCOMP			0x02	/* Bus Master XFER Complete status	*/
#define SCSICOMP			0x01	/* SCSI complete interrupt		*/

#define TRM_S1040_DMA_INTEN		0xA4	/* DMA Interrupt Enable (R/W)		*/
#define EN_FORCEDMACOMP			0x10	/* Force DMA transfer complete		*/
#define EN_DMAXFERERROR			0x08	/* DMA transfer error			*/
#define EN_DMAXFERABORT			0x04	/* DMA transfer abort			*/
#define EN_DMAXFERCOMP			0x02	/* Bus Master XFER Complete status	*/
#define EN_SCSIINTR			0x01	/* Enable SCSI complete interrupt	*/

#define TRM_S1040_DMA_CONFIG		0xA6	/* DMA Configuration (R/W)		*/
#define DMA_ENHANCE			0x8000	/* Enable DMA enhance feature (SG?)	*/
#define DMA_PCI_DUAL_ADDR		0x4000	/*					*/
#define DMA_CFG_RES			0x2000	/* Always 1				*/
#define DMA_AUTO_CLR_FIFO		0x1000	/* DISable DMA auto clear FIFO		*/
#define DMA_MEM_MULTI_READ		0x0800	/*					*/
#define DMA_MEM_WRITE_INVAL		0x0400	/* Memory write and invalidate		*/
#define DMA_FIFO_CTRL			0x0300	/* Control FIFO operation with DMA	*/
#define DMA_FIFO_HALF_HALF		0x0200	/* Keep half filled on both read/write	*/

#define TRM_S1040_DMA_XCNT		0xA8	/* DMA Transfer Counter (R/W), 24bits	*/
#define TRM_S1040_DMA_CXCNT		0xAC	/* DMA Current Transfer Counter (R)	*/
#define TRM_S1040_DMA_XLOWADDR		0xB0	/* DMA Transfer Physical Low Address	*/
#define TRM_S1040_DMA_XHIGHADDR		0xB4	/* DMA Transfer Physical High Address	*/

/************************************************************************/
/*									*/
/*	The general register offset for TRM_S1040			*/
/*									*/
/************************************************************************/
#define TRM_S1040_GEN_CONTROL		0xD4	/* Global Control			*/
#define CTRL_LED			0x80	/* Control onboard LED			*/
#define EN_EEPROM			0x10	/* Enable EEPROM programming		*/
#define DIS_TERM			0x08	/* Disable onboard termination		*/
#define AUTOTERM			0x04	/* Enable Auto SCSI terminator		*/
#define LOW8TERM			0x02	/* Enable Lower 8 bit SCSI terminator	*/
#define UP8TERM				0x01	/* Enable Upper 8 bit SCSI terminator	*/

#define TRM_S1040_GEN_STATUS		0xD5	/* Global Status			*/
#define GTIMEOUT			0x80	/* Global timer reach 0			*/
#define EXT68HIGH			0x40	/* Higher 8 bit connected externally	*/
#define INT68HIGH			0x20	/* Higher 8 bit connected internally	*/
#define CON5068				0x10	/* External 50/68 pin connected (low)	*/
#define CON68				0x08	/* Internal 68 pin connected (low)	*/
#define CON50				0x04	/* Internal 50 pin connected (low!)	*/
#define WIDESCSI			0x02	/* Wide SCSI card			*/
#define STATUS_LOAD_DEFAULT		0x01	/*					*/

#define TRM_S1040_GEN_NVRAM		0xD6	/* Serial NON-VOLATILE RAM port		*/
#define NVR_BITOUT			0x08	/* Serial data out			*/
#define NVR_BITIN			0x04	/* Serial data in			*/
#define NVR_CLOCK			0x02	/* Serial clock				*/
#define NVR_SELECT			0x01	/* Serial select			*/

#define TRM_S1040_GEN_EDATA		0xD7	/* Parallel EEPROM data port		*/
#define TRM_S1040_GEN_EADDRESS		0xD8	/* Parallel EEPROM address		*/
#define TRM_S1040_GEN_TIMER		0xDB	/* Global timer				*/

/************************************************************************/
/*									*/
/*	NvmTarCfg0: Target configuration byte 0 :..pDCB->DevMode	*/
/*									*/
/************************************************************************/
#define NTC_DO_WIDE_NEGO		0x20	/* Wide negotiate			*/
#define NTC_DO_TAG_QUEUEING		0x10	/* Enable SCSI tag queuing		*/
#define NTC_DO_SEND_START		0x08	/* Send start command SPINUP		*/
#define NTC_DO_DISCONNECT		0x04	/* Enable SCSI disconnect		*/
#define NTC_DO_SYNC_NEGO		0x02	/* Sync negotiation			*/
#define NTC_DO_PARITY_CHK		0x01	/* (it should define at NAC)		*/
						/* Parity check enable			*/

/************************************************************************/
/*									*/
/*	Nvram Initiater bits definition					*/
/*									*/
/************************************************************************/
#if 0
#define MORE2_DRV			BIT0
#define GREATER_1G			BIT1
#define RST_SCSI_BUS			BIT2
#define ACTIVE_NEGATION			BIT3
#define NO_SEEK				BIT4
#define LUN_CHECK			BIT5
#endif

/************************************************************************/
/*									*/
/*	Nvram Adapter Cfg bits definition				*/
/*									*/
/************************************************************************/
#define NAC_SCANLUN			0x20	/* Include LUN as BIOS device		*/
#define NAC_POWERON_SCSI_RESET		0x04	/* Power on reset enable		*/
#define NAC_GREATER_1G			0x02	/* > 1G support enable			*/
#define NAC_GT2DRIVES			0x01	/* Support more than 2 drives		*/
/* #define NAC_DO_PARITY_CHK		0x08 */	/* Parity check enable			*/

#endif

{'repo_name': 'seemoo-lab/bcm-rpi3', 'stars': '140', 'repo_language': 'C', 'file_name': 'spi.c', 'mime_type': 'text/x-c', 'hash': -7869920745034085119, 'source_dataset': 'data'}


source ../testsupport.sh

run

grep -q 'WARNING: 1 check.*failed' test.out || err "Did not observe 1 check fail as expected"

bpipe checks -l | grep -q '[0-9]. hello.*Passed' || err "One check did not pass"

bpipe checks -l | grep -q '[0-9]. hello.*Failed' || err "One check did not fail"

true

{'repo_name': 'ssadedin/bpipe', 'stars': '176', 'repo_language': 'Groovy', 'file_name': 'run.sh', 'mime_type': 'text/plain', 'hash': 8480959102975625469, 'source_dataset': 'data'}


import assert from 'assert';
import 'mocha';
import { StateNavigator } from 'navigation';
import { NavigationContext, NavigationHandler } from 'navigation-react';
import { NavigationMotion, useUnloaded } from 'navigation-react-mobile';
import React, { useState, useContext } from 'react';
import ReactDOM from 'react-dom';
import { act } from 'react-dom/test-utils';
import { JSDOM } from 'jsdom';

declare var global: any;
var { window } = new JSDOM('<!doctype html>', { pretendToBeVisual: true });
window.addEventListener = () => {};
global.window = window;
global.document = window.document;

describe('UnloadedHook', function () {
    describe('A', function () {
        it('should not call unloaded hook', function(){
            var stateNavigator = new StateNavigator([
                { key: 'sceneA' }
            ]);
            stateNavigator.navigate('sceneA');
            var {sceneA} = stateNavigator.states;
            var unloadedA;
            var SceneA = () => {
                useUnloaded(() => {
                    unloadedA = true;
                })
                return
;
            };
            sceneA.renderScene = () => <SceneA />;
            var container = document.createElement('div');
            act(() => {
                unloadedA = false;
                ReactDOM.render(
                    <NavigationHandler stateNavigator={stateNavigator}>
                        <NavigationMotion>
                            {(_style, scene, key) =>
{scene}
}
                        </NavigationMotion>
                    </NavigationHandler>,
                    container
                );
            });
            try {
                assert.equal(unloadedA, false);
            } finally {
                ReactDOM.unmountComponentAtNode(container);
            }
        })
    });

    describe('A -> B', function () {
        it('should not call unloaded hook on on A or B', function(){
            var stateNavigator = new StateNavigator([
                { key: 'sceneA' },
                { key: 'sceneB', trackCrumbTrail: true }
            ]);
            stateNavigator.navigate('sceneA');
            stateNavigator.navigate('sceneB');
            var {sceneA, sceneB} = stateNavigator.states;
            var unloadedA, unloadedB;
            var SceneA = () => {
                useUnloaded(() => {
                    unloadedA = true;
                })
                return
;
            };
            var SceneB = () => {
                useUnloaded(() => {
                    unloadedB = true;
                })
                return
;
            };
            sceneA.renderScene = () => <SceneA />;
            sceneB.renderScene = () => <SceneB />;
            var container = document.createElement('div');
            act(() => {
                unloadedA = unloadedB = false;
                ReactDOM.render(
                    <NavigationHandler stateNavigator={stateNavigator}>
                        <NavigationMotion>
                            {(_style, scene, key) =>
{scene}
}
                        </NavigationMotion>
                    </NavigationHandler>,
                    container
                );
            });
            try {
                assert.equal(unloadedA, false);
                assert.equal(unloadedB, false);
            } finally {
                ReactDOM.unmountComponentAtNode(container);
            }
        })
    });

    describe('A to A -> B', function () {
        it('should call unloaded hook on A and not B', function(){
            var stateNavigator = new StateNavigator([
                { key: 'sceneA' },
                { key: 'sceneB', trackCrumbTrail: true }
            ]);
            stateNavigator.navigate('sceneA');
            var {sceneA, sceneB} = stateNavigator.states;
            var unloadedA, unloadedB;
            var SceneA = () => {
                useUnloaded(() => {
                    unloadedA = true;
                })
                return
;
            };
            var SceneB = () => {
                useUnloaded(() => {
                    unloadedB = true;
                })
                return
;
            };
            sceneA.renderScene = () => <SceneA />;
            sceneB.renderScene = () => <SceneB />;
            var container = document.createElement('div');
            act(() => {
                ReactDOM.render(
                    <NavigationHandler stateNavigator={stateNavigator}>
                        <NavigationMotion>
                            {(_style, scene, key) =>
{scene}
}
                        </NavigationMotion>
                    </NavigationHandler>,
                    container
                );
            });
            act(() => {
                unloadedA = unloadedB = false;
                stateNavigator.navigate('sceneB');
            });
            try {
                assert.equal(unloadedA, true);
                assert.equal(unloadedB, false);
            } finally {
                ReactDOM.unmountComponentAtNode(container);
            }
        })
    });

    describe('A -> B to A', function () {
        it('should call unloaded hook on B and not on A', function(){
            var stateNavigator = new StateNavigator([
                { key: 'sceneA' },
                { key: 'sceneB', trackCrumbTrail: true }
            ]);
            stateNavigator.navigate('sceneA');
            var {sceneA, sceneB} = stateNavigator.states;
            var unloadedA, unloadedB;
            var SceneA = () => {
                useUnloaded(() => {
                    unloadedA = true;
                })
                return
;
            };
            var SceneB = () => {
                useUnloaded(() => {
                    unloadedB = true;
                })
                return
;
            };
            sceneA.renderScene = () => <SceneA />;
            sceneB.renderScene = () => <SceneB />;
            var container = document.createElement('div');
            act(() => {
                ReactDOM.render(
                    <NavigationHandler stateNavigator={stateNavigator}>
                        <NavigationMotion>
                            {(_style, scene, key) =>
{scene}
}
                        </NavigationMotion>
                    </NavigationHandler>,
                    container
                );
                stateNavigator.navigate('sceneB');
            });
            act(() => {
                unloadedA = unloadedB = false;
                stateNavigator.navigateBack(1);
            });
            try {
                assert.equal(unloadedA, false);
                assert.equal(unloadedB, true);
            } finally {
                ReactDOM.unmountComponentAtNode(container);
            }
        })
    });

    describe('A to A', function () {
        it('should not call unloaded hook', function(){
            var stateNavigator = new StateNavigator([
                { key: 'sceneA' }
            ]);
            stateNavigator.navigate('sceneA');
            var {sceneA} = stateNavigator.states;
            var unloadedA;
            var SceneA = () => {
                useUnloaded(() => {
                    unloadedA = true;
                })
                return
;
            };
            sceneA.renderScene = () => <SceneA />;
            var container = document.createElement('div');
            act(() => {
                ReactDOM.render(
                    <NavigationHandler stateNavigator={stateNavigator}>
                        <NavigationMotion>
                            {(_style, scene, key) =>
{scene}
}
                        </NavigationMotion>
                    </NavigationHandler>,
                    container
                );
            });
            act(() => {
                unloadedA = false;
                stateNavigator.navigate('sceneA');
            });
            try {
                assert.equal(unloadedA, false);
            } finally {
                ReactDOM.unmountComponentAtNode(container);
            }
        })
    });

    describe('A to B', function () {
        it('should call unloaded hook on A and not on B', function(){
            var stateNavigator = new StateNavigator([
                { key: 'sceneA' },
                { key: 'sceneB' }
            ]);
            stateNavigator.navigate('sceneA');
            var {sceneA, sceneB} = stateNavigator.states;
            var unloadedA, unloadedB;
            var SceneA = () => {
                useUnloaded(() => {
                    unloadedA = true;
                })
                return
;
            };
            var SceneB = () => {
                useUnloaded(() => {
                    unloadedB = true;
                })
                return
;
            };
            sceneA.renderScene = () => <SceneA />;
            sceneB.renderScene = () => <SceneB />;
            var container = document.createElement('div');
            act(() => {
                ReactDOM.render(
                    <NavigationHandler stateNavigator={stateNavigator}>
                        <NavigationMotion>
                            {(_style, scene, key) =>
{scene}
}
                        </NavigationMotion>
                    </NavigationHandler>,
                    container
                );
            });
            act(() => {
                unloadedA = unloadedB = false;
                stateNavigator.navigate('sceneB');
            });
            try {
                assert.equal(unloadedA, true);
                assert.equal(unloadedB, false);
            } finally {
                ReactDOM.unmountComponentAtNode(container);
            }
        })
    });

    describe('A -> B to C -> B', function () {
        it('should not call unloaded hook on A, B or C', function(){
            var stateNavigator = new StateNavigator([
                { key: 'sceneA' },
                { key: 'sceneB', trackCrumbTrail: true },
                { key: 'sceneC' }
            ]);
            stateNavigator.navigate('sceneA');
            var {sceneA, sceneB, sceneC} = stateNavigator.states;
            var unloadedA, unloadedB, unloadedC;
            var SceneA = () => {
                useUnloaded(() => {
                    unloadedA = true;
                })
                return
;
            };
            var SceneB = () => {
                useUnloaded(() => {
                    unloadedB = true;
                })
                return
;
            };
            var SceneC = () => {
                useUnloaded(() => {
                    unloadedC = true;
                })
                return
;
            };
            sceneA.renderScene = () => <SceneA />;
            sceneB.renderScene = () => <SceneB />;
            sceneC.renderScene = () => <SceneC />;
            var container = document.createElement('div');
            act(() => {
                ReactDOM.render(
                    <NavigationHandler stateNavigator={stateNavigator}>
                        <NavigationMotion>
                            {(_style, scene, key) =>
{scene}
}
                        </NavigationMotion>
                    </NavigationHandler>,
                    container
                );
                stateNavigator.navigate('sceneB');
            });
            act(() => {
                unloadedA = unloadedB = unloadedC = false;
                var url = stateNavigator.fluent()
                    .navigate('sceneC')
                    .navigate('sceneB').url;
                stateNavigator.navigateLink(url);
            });
            try {
                assert.equal(unloadedA, false);
                assert.equal(unloadedB, false);
                assert.equal(unloadedC, false);
            } finally {
                ReactDOM.unmountComponentAtNode(container);
            }
        })
    });

    describe('A -> B to C -> D', function () {
        it('should call unloaded hook on B and not on A, C, or D', function(){
            var stateNavigator = new StateNavigator([
                { key: 'sceneA' },
                { key: 'sceneB', trackCrumbTrail: true },
                { key: 'sceneC' },
                { key: 'sceneD', trackCrumbTrail: true }
            ]);
            stateNavigator.navigate('sceneA');
            var {sceneA, sceneB, sceneC, sceneD} = stateNavigator.states;
            var unloadedA, unloadedB, unloadedC, unloadedD;
            var SceneA = () => {
                useUnloaded(() => {
                    unloadedA = true;
                })
                return
;
            };
            var SceneB = () => {
                useUnloaded(() => {
                    unloadedB = true;
                })
                return
;
            };
            var SceneC = () => {
                useUnloaded(() => {
                    unloadedC = true;
                })
                return
;
            };
            var SceneD = () => {
                useUnloaded(() => {
                    unloadedD = true;
                })
                return
;
            };
            sceneA.renderScene = () => <SceneA />;
            sceneB.renderScene = () => <SceneB />;
            sceneC.renderScene = () => <SceneC />;
            sceneD.renderScene = () => <SceneD />;
            var container = document.createElement('div');
            act(() => {
                ReactDOM.render(
                    <NavigationHandler stateNavigator={stateNavigator}>
                        <NavigationMotion>
                            {(_style, scene, key) =>
{scene}
}
                        </NavigationMotion>
                    </NavigationHandler>,
                    container
                );
                stateNavigator.navigate('sceneB');
            });
            act(() => {
                unloadedA = unloadedB = unloadedC = unloadedD = false;
                var url = stateNavigator.fluent()
                    .navigate('sceneC')
                    .navigate('sceneD').url;
                stateNavigator.navigateLink(url);
            });
            try {
                assert.equal(unloadedA, false);
                assert.equal(unloadedB, true);
                assert.equal(unloadedC, false);
                assert.equal(unloadedD, false);
            } finally {
                ReactDOM.unmountComponentAtNode(container);
            }
        })
    });

    describe('A to A --> B -> C', function () {
        it('should call unloaded hook on A and not on B or C', function(){
            var stateNavigator = new StateNavigator([
                { key: 'sceneA' },
                { key: 'sceneB', trackCrumbTrail: true },
                { key: 'sceneC', trackCrumbTrail: true }
            ]);
            stateNavigator.navigate('sceneA');
            var {sceneA, sceneB, sceneC} = stateNavigator.states;
            var unloadedA, unloadedB, unloadedC;
            var SceneA = () => {
                useUnloaded(() => {
                    unloadedA = true;
                })
                return
;
            };
            var SceneB = () => {
                useUnloaded(() => {
                    unloadedB = true;
                })
                return
;
            };
            var SceneC = () => {
                useUnloaded(() => {
                    unloadedC = true;
                })
                return
;
            };
            sceneA.renderScene = () => <SceneA />;
            sceneB.renderScene = () => <SceneB />;
            sceneC.renderScene = () => <SceneC />;
            var container = document.createElement('div');
            act(() => {
                ReactDOM.render(
                    <NavigationHandler stateNavigator={stateNavigator}>
                        <NavigationMotion>
                            {(_style, scene, key) =>
{scene}
}
                        </NavigationMotion>
                    </NavigationHandler>,
                    container
                );
            });
            act(() => {
                unloadedA = unloadedB = unloadedC = false;
                var url = stateNavigator.fluent(true)
                    .navigate('sceneB')
                    .navigate('sceneC').url;
                stateNavigator.navigateLink(url);
            });
            try {
                assert.equal(unloadedA, true);
                assert.equal(unloadedB, false);
                assert.equal(unloadedC, false);
            } finally {
                ReactDOM.unmountComponentAtNode(container);
            }
        })
    });

    describe('A to A -> B -> C to A -> B', function () {
        it('should call unloaded hook on C and not A or B', function(){
            var stateNavigator = new StateNavigator([
                { key: 'sceneA' },
                { key: 'sceneB', trackCrumbTrail: true },
                { key: 'sceneC', trackCrumbTrail: true }
            ]);
            stateNavigator.navigate('sceneA');
            var {sceneA, sceneB, sceneC} = stateNavigator.states;
            var unloadedA, unloadedB, unloadedC;
            var SceneA = () => {
                useUnloaded(() => {
                    unloadedA = true;
                })
                return
;
            };
            var SceneB = () => {
                useUnloaded(() => {
                    unloadedB = true;
                })
                return
;
            };
            var SceneC = () => {
                useUnloaded(() => {
                    unloadedC = true;
                })
                return
;
            };
            sceneA.renderScene = () => <SceneA />;
            sceneB.renderScene = () => <SceneB />;
            sceneC.renderScene = () => <SceneC />;
            var container = document.createElement('div');
            act(() => {
                ReactDOM.render(
                    <NavigationHandler stateNavigator={stateNavigator}>
                        <NavigationMotion>
                            {(_style, scene, key) =>
{scene}
}
                        </NavigationMotion>
                    </NavigationHandler>,
                    container
                );
                var url = stateNavigator.fluent(true)
                    .navigate('sceneB')
                    .navigate('sceneC').url;
                stateNavigator.navigateLink(url);
            });
            act(() => {
                unloadedA = unloadedB = unloadedC = false;
                stateNavigator.navigateBack(1);
            });
            try {
                assert.equal(unloadedA, false);
                assert.equal(unloadedB, false);
                assert.equal(unloadedC, true);
            } finally {
                ReactDOM.unmountComponentAtNode(container);
            }
        })
    });

    describe('A to A -> B to A to A -> B to A', function () {
        it('should call unloaded hook on B and not A', function(){
            var stateNavigator = new StateNavigator([
                { key: 'sceneA' },
                { key: 'sceneB', trackCrumbTrail: true }
            ]);
            stateNavigator.navigate('sceneA');
            var {sceneA, sceneB} = stateNavigator.states;
            var unloadedA, unloadedB;
            var SceneA = () => {
                useUnloaded(() => {
                    unloadedA = true;
                })
                return
;
            };
            var SceneB = () => {
                useUnloaded(() => {
                    unloadedB = true;
                })
                return
;
            };
            sceneA.renderScene = () => <SceneA />;
            sceneB.renderScene = () => <SceneB />;
            var container = document.createElement('div');
            act(() => {
                ReactDOM.render(
                    <NavigationHandler stateNavigator={stateNavigator}>
                        <NavigationMotion>
                            {(_style, scene, key) =>
{scene}
}
                        </NavigationMotion>
                    </NavigationHandler>,
                    container
                );
                stateNavigator.navigate('sceneB');
                stateNavigator.navigate('sceneA');
                stateNavigator.navigate('sceneB');
            });
            act(() => {
                unloadedA = unloadedB = false;
                stateNavigator.navigate('sceneA');
            });
            try {
                assert.equal(unloadedA, false);
                assert.equal(unloadedB, true);
            } finally {
                ReactDOM.unmountComponentAtNode(container);
            }
        })
    });

    describe('A -> B -> C to A', function () {
        it('should call unloaded hook on C and not on A or B', function(){
            var stateNavigator = new StateNavigator([
                { key: 'sceneA' },
                { key: 'sceneB', trackCrumbTrail: true },
                { key: 'sceneC', trackCrumbTrail: true }
            ]);
            stateNavigator.navigate('sceneA');
            var {sceneA, sceneB, sceneC} = stateNavigator.states;
            var unloadedA, unloadedB, unloadedC;
            var SceneA = () => {
                useUnloaded(() => {
                    unloadedA = true;
                })
                return
;
            };
            var SceneB = () => {
                useUnloaded(() => {
                    unloadedB = true;
                })
                return
;
            };
            var SceneC = () => {
                useUnloaded(() => {
                    unloadedC = true;
                })
                return
;
            };
            sceneA.renderScene = () => <SceneA />;
            sceneB.renderScene = () => <SceneB />;
            sceneC.renderScene = () => <SceneC />;
            var container = document.createElement('div');
            act(() => {
                ReactDOM.render(
                    <NavigationHandler stateNavigator={stateNavigator}>
                        <NavigationMotion>
                            {(_style, scene, key) =>
{scene}
}
                        </NavigationMotion>
                    </NavigationHandler>,
                    container
                );
                stateNavigator.navigate('sceneB');
                stateNavigator.navigate('sceneC');
            });
            act(() => {
                unloadedA = unloadedB = unloadedC = false;
                stateNavigator.navigateBack(2);
            });
            try {
                assert.equal(unloadedA, false);
                assert.equal(unloadedB, false);
                assert.equal(unloadedC, true);
            } finally {
                ReactDOM.unmountComponentAtNode(container);
            }
        })
    });

    describe('A -> B -> C to B', function () {
        it('should call unloaded hook on C and not on A or B', function(){
            var stateNavigator = new StateNavigator([
                { key: 'sceneA' },
                { key: 'sceneB', trackCrumbTrail: true },
                { key: 'sceneC', trackCrumbTrail: true }
            ]);
            stateNavigator.navigate('sceneA');
            var {sceneA, sceneB, sceneC} = stateNavigator.states;
            var unloadedA, unloadedB, unloadedC;
            var SceneA = () => {
                useUnloaded(() => {
                    unloadedA = true;
                })
                return
;
            };
            var SceneB = () => {
                useUnloaded(() => {
                    unloadedB = true;
                })
                return
;
            };
            var SceneC = () => {
                useUnloaded(() => {
                    unloadedC = true;
                })
                return
;
            };
            sceneA.renderScene = () => <SceneA />;
            sceneB.renderScene = () => <SceneB />;
            sceneC.renderScene = () => <SceneC />;
            var container = document.createElement('div');
            act(() => {
                ReactDOM.render(
                    <NavigationHandler stateNavigator={stateNavigator}>
                        <NavigationMotion>
                            {(_style, scene, key) =>
{scene}
}
                        </NavigationMotion>
                    </NavigationHandler>,
                    container
                );
                stateNavigator.navigate('sceneB');
                stateNavigator.navigate('sceneC');
            });
            act(() => {
                unloadedA = unloadedB = unloadedC = false;
                var url = stateNavigator.fluent()
                    .navigate('sceneB').url;
                stateNavigator.navigateLink(url);
            });
            try {
                assert.equal(unloadedA, false);
                assert.equal(unloadedB, false);
                assert.equal(unloadedC, true);
            } finally {
                ReactDOM.unmountComponentAtNode(container);
            }
        })
    });

    describe('Suspend navigation', function () {
        it('should not call unloaded hook', function(){
            var stateNavigator = new StateNavigator([
                { key: 'sceneA' },
                { key: 'sceneB', trackCrumbTrail: true }
            ]);
            stateNavigator.navigate('sceneA');
            var {sceneA, sceneB} = stateNavigator.states;
            var unloadedA, unloadedB;
            var SceneA = () => {
                useUnloaded(() => {
                    unloadedA = true;
                })
                return
;
            };
            var SceneB = () => {
                useUnloaded(() => {
                    unloadedB = true;
                })
                return
;
            };
            sceneA.renderScene = () => <SceneA />;
            sceneB.renderScene = () => <SceneB />;
            var container = document.createElement('div');
            act(() => {
                ReactDOM.render(
                    <NavigationHandler stateNavigator={stateNavigator}>
                        <NavigationMotion>
                            {(_style, scene, key) =>
{scene}
}
                        </NavigationMotion>
                    </NavigationHandler>,
                    container
                );
            });
            act(() => {
                unloadedA = unloadedB = false;
                var url = stateNavigator.getNavigationLink('sceneB');
                stateNavigator.navigateLink(url, undefined, false, () => {});
            });
            try {
                assert.equal(unloadedA, false);
                assert.equal(unloadedB, false);
            } finally {
                ReactDOM.unmountComponentAtNode(container);
            }
        })
    });

    describe('Set state', function () {
        it('should not call unloaded hook', function(){
            var stateNavigator = new StateNavigator([
                { key: 'sceneA' }
            ]);
            stateNavigator.navigate('sceneA');
            var {sceneA} = stateNavigator.states;
            var unloadedA;
            var setCountA;
            var SceneA = () => {
                var [count, setCount]  = useState(0);
                setCountA = setCount;
                useUnloaded(() => {
                    unloadedA = true;
                })
                return
;
            };
            sceneA.renderScene = () => <SceneA />;
            var container = document.createElement('div');
            act(() => {
                ReactDOM.render(
                    <NavigationHandler stateNavigator={stateNavigator}>
                        <NavigationMotion>
                            {(_style, scene, key) =>
{scene}
}
                        </NavigationMotion>
                    </NavigationHandler>,
                    container
                );
            });
            act(() => {
                unloadedA = false;
                setCountA(1);
            });
            try {
                assert.equal(unloadedA, false);
            } finally {
                ReactDOM.unmountComponentAtNode(container);
            }
        })
    });

    describe('Unloaded handler state', function () {
        it('should access latest state', function(){
            var stateNavigator = new StateNavigator([
                { key: 'sceneA' },
                { key: 'sceneB', trackCrumbTrail: true }
            ]);
            stateNavigator.navigate('sceneA');
            var {sceneA, sceneB} = stateNavigator.states;
            var countA, setCountA;
            var SceneA = () => {
                var [count, setCount]  = useState(0);
                setCountA = setCount;
                useUnloaded(() => {
                    countA = count;
                })
                return
;
            };
            var SceneB = () =>
;
            sceneA.renderScene = () => <SceneA />;
            sceneB.renderScene = () => <SceneB />;
            var container = document.createElement('div');
            act(() => {
                ReactDOM.render(
                    <NavigationHandler stateNavigator={stateNavigator}>
                        <NavigationMotion>
                            {(_style, scene, key) =>
{scene}
}
                        </NavigationMotion>
                    </NavigationHandler>,
                    container
                );
                setCountA(1);
            });
            act(() => {
                countA = 0;
                stateNavigator.navigate('sceneB');
            });
            try {
                assert.equal(countA, 1);
            } finally {
                ReactDOM.unmountComponentAtNode(container);
            }
        })
    });

    describe('Unloaded handler context', function () {
        it('should access current context', function(){
            var stateNavigator = new StateNavigator([
                { key: 'sceneA' },
                { key: 'sceneB', trackCrumbTrail: true }
            ]);
            stateNavigator.navigate('sceneA');
            var {sceneA, sceneB} = stateNavigator.states;
            var stateContextA;
            var SceneA = () => {
                var navigationEvent = useContext(NavigationContext);
                useUnloaded(() => {
                    var {stateContext} = navigationEvent.stateNavigator;
                    stateContextA = stateContext;
                })
                return
;
            };
            var SceneB = () =>
;
            sceneA.renderScene = () => <SceneA />;
            sceneB.renderScene = () => <SceneB />;
            var container = document.createElement('div');
            act(() => {
                ReactDOM.render(
                    <NavigationHandler stateNavigator={stateNavigator}>
                        <NavigationMotion>
                            {(_style, scene, key) =>
{scene}
}
                        </NavigationMotion>
                    </NavigationHandler>,
                    container
                );
            });
            act(() => {
                stateContextA = null;
                stateNavigator.navigate('sceneB');
            });
            try {
                assert.equal(stateContextA.oldState, null);
                assert.equal(stateContextA.state, sceneA);
            } finally {
                ReactDOM.unmountComponentAtNode(container);
            }
        })
    });

    describe('Unloaded handler data', function () {
        it('should access data', function(){
            var stateNavigator = new StateNavigator([
                { key: 'sceneA', defaultTypes: {x: 'number'} },
                { key: 'sceneB', defaultTypes: {y: 'number'}, trackCrumbTrail: true },
                { key: 'sceneC', trackCrumbTrail: true }
            ]);
            stateNavigator.navigate('sceneA', {x: 0});
            var {sceneA, sceneB, sceneC} = stateNavigator.states;
            var stateC, dataC, stateContextC;
            var SceneA = () =>
;
            var SceneB = () =>
;
            var SceneC = () => {
                useUnloaded((state, data, stateContext) => {
                    stateC = state;
                    dataC = data;
                    stateContextC = stateContext;
                })
                return
;
            };
            sceneA.renderScene = () => <SceneA />;
            sceneB.renderScene = () => <SceneB />;
            sceneC.renderScene = () => <SceneC />;
            var container = document.createElement('div');
            act(() => {
                ReactDOM.render(
                    <NavigationHandler stateNavigator={stateNavigator}>
                        <NavigationMotion>
                            {(_style, scene, key) =>
{scene}
}
                        </NavigationMotion>
                    </NavigationHandler>,
                    container
                );
                stateNavigator.navigate('sceneB', {y: 1});
                stateNavigator.navigate('sceneC');
            });
            act(() => {
                stateC = dataC = stateContextC = null;
                stateNavigator.navigateBack(1);
            });
            try {
                assert.equal(stateC, sceneB);
                assert.equal(dataC.y, 1);
                assert.equal(stateContextC.url, '/sceneB?y=1&crumb=%2FsceneA%3Fx%3D0');
                assert.equal(stateContextC.crumbs.length, 1);
                assert.equal(stateContextC.crumbs[0].state, sceneA);
                assert.equal(stateContextC.crumbs[0].data.x, 0);
                assert.equal(stateContextC.history, false);
            } finally {
                ReactDOM.unmountComponentAtNode(container);
            }
        })
    });
});

{'repo_name': 'grahammendick/navigation', 'stars': '303', 'repo_language': 'TypeScript', 'file_name': 'App-test.js', 'mime_type': 'text/x-java', 'hash': 6992210484146016331, 'source_dataset': 'data'}


// CodeContracts
//
// Copyright (c) Microsoft Corporation
//
// All rights reserved.
//
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

// File System.Runtime.Serialization.ISurrogateSelector.cs
// Automatically generated contract file.
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Diagnostics.Contracts;
using System;

// Disable the "this variable is not used" warning as every field would imply it.
#pragma warning disable 0414
// Disable the "this variable is never assigned to".
#pragma warning disable 0067
// Disable the "this event is never assigned to".
#pragma warning disable 0649
// Disable the "this variable is never used".
#pragma warning disable 0169
// Disable the "new keyword not required" warning.
#pragma warning disable 0109
// Disable the "extern without DllImport" warning.
#pragma warning disable 0626
// Disable the "could hide other member" warning, can happen on certain properties.
#pragma warning disable 0108

namespace System.Runtime.Serialization
{
  public partial interface ISurrogateSelector
  {
    #region Methods and constructors
    void ChainSelector(ISurrogateSelector selector);

    ISurrogateSelector GetNextSelector();

    ISerializationSurrogate GetSurrogate(Type type, StreamingContext context, out ISurrogateSelector selector);
    #endregion
  }
}

{'repo_name': 'microsoft/CodeContracts', 'stars': '833', 'repo_language': 'C#', 'file_name': 'AssemblyInfo.cs', 'mime_type': 'text/plain', 'hash': 922816743229215702, 'source_dataset': 'data'}


/*
 * Copyright (C) 2018 Tran Le Duy
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

package com.duy.ide.javaide.menu;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.MenuItem;
import android.view.SubMenu;

import com.duy.ide.R;
import com.jecelyin.editor.v2.manager.MenuManager;

import java.util.ArrayList;

public class JavaMenuManager {
    private final Context mContext;

    public JavaMenuManager(Context context) {
        mContext = context;
    }

    public void createFileMenu(SubMenu menu) {
        //hide create new file menu
        menu.removeItem(R.id.action_new_file);
        menu.removeItem(R.id.action_open);

        ArrayList<MenuItem> oldMenuItems = new ArrayList<>();
        for (int i = 0; i < menu.size(); i++) {
            MenuItem item = menu.getItem(i);
            oldMenuItems.add(item);
        }
        menu.clear();

        int[] newMenuIds = new int[]{
                R.id.action_new_java_project, R.string.new_java_project, R.drawable.ic_create_new_folder_white_24dp,
                R.id.action_new_android_project, R.string.new_android_project, R.drawable.ic_create_new_folder_white_24dp,
                R.id.action_new_class, R.string.new_class, R.drawable.ic_create_new_folder_white_24dp,
                R.id.action_new_file, R.string.new_file, R.drawable.ic_fiber_new_white_24dp,
        };
        int[] openMenuIds = new int[]{
                R.id.action_open_java_project, R.string.open_java_project, R.drawable.ic_folder_open_white_24dp,
                R.id.action_open_android_project, R.string.open_android_project, R.drawable.ic_folder_open_white_24dp,
        };
        addToMenu(menu, R.drawable.ic_create_new_folder_white_24dp, R.string.title_menu_new, newMenuIds);
        addToMenu(menu, R.drawable.baseline_folder_open_24, R.string.title_menu_open, openMenuIds);

        //restore, make it bottom
        for (MenuItem item : oldMenuItems) {
            menu.add(item.getGroupId(), item.getItemId(), item.getOrder(), item.getTitle())
                    .setIcon(item.getIcon());
        }
    }

    private void addToMenu(SubMenu menu, int iconId, int title, int[] child) {

        SubMenu subMenu = menu.addSubMenu(0, 0, 0, title);
        subMenu.getItem().setIcon(MenuManager.makeMenuNormalIcon(mContext, iconId))
                .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
        for (int i = 0; i < child.length / 3; i++) {
            Drawable icon = MenuManager.makeMenuNormalIcon(mContext, child[3 * i + 2]);
            subMenu.add(0, child[3 * i], 0, child[3 * i + 1])
                    .setIcon(icon);
        }
    }
}

{'repo_name': 'tranleduy2000/javaide', 'stars': '316', 'repo_language': 'Java', 'file_name': 'ExampleInstrumentedTest.java', 'mime_type': 'text/html', 'hash': -3348286459052432380, 'source_dataset': 'data'}


/*global bean:true, buster:true, Syn:true, assert:true, defer:true, features:true, globalSetUp:true, globalTearDown:true*/

buster.testCase('custom', {
    'setUp': globalSetUp
  , 'tearDown': globalTearDown

  , 'should be able to add single custom events': function (done) {
      var el      = this.byId('input')
        , trigger = this.trigger()
        , spy     = this.spy()

      trigger.after(function () {
        assert(spy.calledOnce, 'add single custom events')
        done()
      })

      bean.add(el, 'partytime', trigger.wrap(spy))
      bean.fire(el, 'partytime')
    }

  , 'should bubble up dom like traditional events': function (done) {
      if (features.w3c) {
        //dean edwards' onpropertychange hack doesn't bubble unfortunately :(
        var el1     = this.byId('foo')
          , el2     = this.byId('bar')
          , trigger = this.trigger()
          , spy     = this.spy()

        trigger.after(function () {
          assert(spy.calledOnce, 'bubbles up dom like traditional events')
          done()
        })

        bean.add(el1, 'partytime', trigger.wrap(spy))
        bean.fire(el2, 'partytime')
      } else {
        assert(true, 'onpropertychange bubbling not supported by this browser, test bypassed')
        done()
      }
    }

  , 'should be able to add, fire and remove custom events to document': function (done) {
      var calls   = 0
        , trigger = this.trigger()

      this.removables.push(document)

      trigger.after(function () {
        assert.equals(calls, 1, 'add custom events to document')
        done()
      })

      bean.add(document, 'justlookatthat', trigger.wrap(function () {
        calls++
        bean.remove(document, 'justlookatthat')
      }))

      bean.fire(document, 'justlookatthat')
      bean.fire(document, 'justlookatthat')
    }

  , 'should be able to add, fire and remove custom events to window': function (done) {
      var calls   = 0
        , trigger = this.trigger()

      trigger.after(function () {
        assert.equals(calls, 1, 'add custom events to window')
        done()
      })

      this.removables.push(window)

      bean.add(window, 'spiffy', trigger.wrap(function () {
        calls++
        bean.remove(window, 'spiffy')
      }))

      bean.fire(window, 'spiffy')
      bean.fire(window, 'spiffy')
    }
})

{'repo_name': 'ceph/calamari-clients', 'stars': '103', 'repo_language': 'JavaScript', 'file_name': 'README.rst', 'mime_type': 'text/plain', 'hash': -3904884735615003084, 'source_dataset': 'data'}


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

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>AttributeOverride (Java(TM) EE 8 Specification APIs)</title>
<meta name="date" content="2017-09-06">
<link rel="stylesheet" type="text/css" href="../../stylesheet.css" title="Style">

JavaScript is disabled on your browser.

Skip navigation links

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev Class

Next Class

Frames

No Frames

All Classes

Summary:

Field |

Required |

Optional

Detail:

Field |

Element

javax.persistence

Annotation Type AttributeOverride

@Repeatable(value=AttributeOverrides.class)
 @Target(value={TYPE,METHOD,FIELD})
 @Retention(value=RUNTIME)
public @interface AttributeOverride

Used to override the mapping of a Basic (whether
 explicit or default) property or field or Id property or
 field.

 May be applied to an entity that extends a mapped superclass or
 to an embedded field or property to override a basic mapping or id
 mapping defined by the mapped superclass or embeddable class (or
 embeddable class of one of its attributes).

 May be applied to an element collection containing instances of
 an embeddable class or to a map collection whose key and/or value
 is an embeddable class. When AttributeOverride is
 applied to a map, "key." or "value." must
 be used to prefix the name of the attribute that is being
 overridden in order to specify it as part of the map key or map
 value.

 To override mappings at multiple levels of embedding, a dot (".")
 notation form must be used in the name element to indicate an
 attribute within an embedded attribute.  The value of each identifier
 used with the dot notation is the name of the respective embedded
 field or property.

 If AttributeOverride is not specified, the column
 is mapped the same as in the original mapping.

    Example 1:

    @MappedSuperclass
    public class Employee {
        @Id protected Integer id;
        @Version protected Integer version;
        protected String address;
        public Integer getId() { ... }
        public void setId(Integer id) { ... }
        public String getAddress() { ... }
        public void setAddress(String address) { ... }
    }

    @Entity
    @AttributeOverride(name="address", column=@Column(name="ADDR"))
    public class PartTimeEmployee extends Employee {
        // address field mapping overridden to ADDR
        protected Float wage();
        public Float getHourlyWage() { ... }
        public void setHourlyWage(Float wage) { ... }
    }

    Example 2:

    @Embeddable public class Address {
        protected String street;
        protected String city;
        protected String state;
        @Embedded protected Zipcode zipcode;
    }

    @Embeddable public class Zipcode {
        protected String zip;
        protected String plusFour;
    }

    @Entity public class Customer {
        @Id protected Integer id;
        protected String name;
        @AttributeOverrides({
            @AttributeOverride(name="state",
                               column=@Column(name="ADDR_STATE")),
            @AttributeOverride(name="zipcode.zip",
                               column=@Column(name="ADDR_ZIP"))
        })
        @Embedded protected Address address;
        ...
    }

    Example 3:

    @Entity public class PropertyRecord {
        @EmbeddedId PropertyOwner owner;
        @AttributeOverrides({
            @AttributeOverride(name="key.street",
                               column=@Column(name="STREET_NAME")),
            @AttributeOverride(name="value.size",
                               column=@Column(name="SQUARE_FEET")),
            @AttributeOverride(name="value.tax",
                               column=@Column(name="ASSESSMENT"))
        })
       @ElementCollection
       Map<Address, PropertyInfo> parcels;
    }

    @Embeddable public class PropertyInfo {
        Integer parcelNumber;
        Integer size;
        BigDecimal tax;
    }

Since:

Java Persistence 1.0

See Also:

Embedded,
Embeddable,
MappedSuperclass,
AssociationOverride

Required Element Summary

Required Elements

Modifier and Type
Required Element and Description

Column
column

(Required) The column that is being mapped to the persistent
 attribute.

String
name

(Required) The name of the property whose mapping is being
 overridden if property-based access is being used, or the
 name of the field if field-based access is used.

Element Detail

name

public abstract String name

(Required) The name of the property whose mapping is being
 overridden if property-based access is being used, or the
 name of the field if field-based access is used.

column

public abstract Column column

(Required) The column that is being mapped to the persistent
 attribute. The mapping type will remain the same as is
 defined in the embeddable class or mapped superclass.

Skip navigation links

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev Class

Next Class

Frames

No Frames

All Classes

Summary:

Field |

Required |

Optional

Detail:

Field |

Element

Copyright © 1996-2017,     Oracle     and/or its affiliates. All Rights Reserved.     Use is subject to     license terms.

{'repo_name': 'javaee/javaee-spec', 'stars': '388', 'repo_language': 'HTML', 'file_name': 'default.html', 'mime_type': 'text/html', 'hash': 4878677570094450196, 'source_dataset': 'data'}


<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textSize="10dp"/>

{'repo_name': 'airbnb/AirMapView', 'stars': '1781', 'repo_language': 'Java', 'file_name': 'google_maps_api.xml', 'mime_type': 'text/plain', 'hash': 868966541058070155, 'source_dataset': 'data'}


<?php defined('SYSPATH') or die('No direct script access.');
/**
 * Routes are used to determine the controller and action for a requested URI.
 * Every route generates a regular expression which is used to match a URI
 * and a route. Routes may also contain keys which can be used to set the
 * controller, action, and parameters.
 *
 * Each <key> will be translated to a regular expression using a default
 * regular expression pattern. You can override the default pattern by providing
 * a pattern for the key:
 *
 *     // This route will only match when <id> is a digit
 *     Route::set('user', 'user/<action>/<id>', array('id' => '\d+'));
 *
 *     // This route will match when <path> is anything
 *     Route::set('file', '<path>', array('path' => '.*'));
 *
 * It is also possible to create optional segments by using parentheses in
 * the URI definition:
 *
 *     // This is the standard default route, and no keys are required
 *     Route::set('default', '(<controller>(/<action>(/<id>)))');
 *
 *     // This route only requires the <file> key
 *     Route::set('file', '(<path>/)<file>(.<format>)', array('path' => '.*', 'format' => '\w+'));
 *
 * Routes also provide a way to generate URIs (called "reverse routing"), which
 * makes them an extremely powerful and flexible way to generate internal links.
 *
 * @package    Kohana
 * @category   Base
 * @author     Kohana Team
 * @copyright  (c) 2008-2011 Kohana Team
 * @license    http://kohanaframework.org/license
 */
class Kohana_Route {

	// Defines the pattern of a <segment>
	const REGEX_KEY     = '<([a-zA-Z0-9_]++)>';

	// What can be part of a <segment> value
	const REGEX_SEGMENT = '[^/.,;?\n]++';

	// What must be escaped in the route regex
	const REGEX_ESCAPE  = '[.\\+*?[^\\]${}=!|]';

	/**
	 * @var  string  default protocol for all routes
	 *
	 * @example  'http://'
	 */
	public static $default_protocol = 'http://';

	/**
	 * @var  array   list of valid localhost entries
	 */
	public static $localhosts = array(FALSE, '', 'local', 'localhost');

	/**
	 * @var  string  default action for all routes
	 */
	public static $default_action = 'index';

	/**
	 * @var  bool Indicates whether routes are cached
	 */
	public static $cache = FALSE;

	/**
	 * @var  array
	 */
	protected static $_routes = array();

	/**
	 * Stores a named route and returns it. The "action" will always be set to
	 * "index" if it is not defined.
	 *
	 *     Route::set('default', '(<controller>(/<action>(/<id>)))')
	 *         ->defaults(array(
	 *             'controller' => 'welcome',
	 *         ));
	 *
	 * @param   string   route name
	 * @param   string   URI pattern
	 * @param   array    regex patterns for route keys
	 * @return  Route
	 */
	public static function set($name, $uri_callback = NULL, $regex = NULL)
	{
		return Route::$_routes[$name] = new Route($uri_callback, $regex);
	}

	/**
	 * Retrieves a named route.
	 *
	 *     $route = Route::get('default');
	 *
	 * @param   string  route name
	 * @return  Route
	 * @throws  Kohana_Exception
	 */
	public static function get($name)
	{
		if ( ! isset(Route::$_routes[$name]))
		{
			throw new Kohana_Exception('The requested route does not exist: :route',
				array(':route' => $name));
		}

		return Route::$_routes[$name];
	}

	/**
	 * Retrieves all named routes.
	 *
	 *     $routes = Route::all();
	 *
	 * @return  array  routes by name
	 */
	public static function all()
	{
		return Route::$_routes;
	}

	/**
	 * Get the name of a route.
	 *
	 *     $name = Route::name($route)
	 *
	 * @param   object  Route instance
	 * @return  string
	 */
	public static function name(Route $route)
	{
		return array_search($route, Route::$_routes);
	}

	/**
	 * Saves or loads the route cache. If your routes will remain the same for
	 * a long period of time, use this to reload the routes from the cache
	 * rather than redefining them on every page load.
	 *
	 *     if ( ! Route::cache())
	 *     {
	 *         // Set routes here
	 *         Route::cache(TRUE);
	 *     }
	 *
	 * @param   boolean   cache the current routes
	 * @return  void      when saving routes
	 * @return  boolean   when loading routes
	 * @uses    Kohana::cache
	 */
	public static function cache($save = FALSE)
	{
		if ($save === TRUE)
		{
			// Cache all defined routes
			Kohana::cache('Route::cache()', Route::$_routes);
		}
		else
		{
			if ($routes = Kohana::cache('Route::cache()'))
			{
				Route::$_routes = $routes;

				// Routes were cached
				return Route::$cache = TRUE;
			}
			else
			{
				// Routes were not cached
				return Route::$cache = FALSE;
			}
		}
	}

	/**
	 * Create a URL from a route name. This is a shortcut for:
	 *
	 *     echo URL::site(Route::get($name)->uri($params), $protocol);
	 *
	 * @param   string   route name
	 * @param   array    URI parameters
	 * @param   mixed   protocol string or boolean, adds protocol and domain
	 * @return  string
	 * @since   3.0.7
	 * @uses    URL::site
	 */
	public static function url($name, array $params = NULL, $protocol = NULL)
	{
		$route = Route::get($name);

		// Create a URI with the route and convert it to a URL
		if ($route->is_external())
			return Route::get($name)->uri($params);
		else
			return URL::site(Route::get($name)->uri($params), $protocol);
	}

	/**
	 * Returns the compiled regular expression for the route. This translates
	 * keys and optional groups to a proper PCRE regular expression.
	 *
	 *     $compiled = Route::compile(
	 *        '<controller>(/<action>(/<id>))',
	 *         array(
	 *           'controller' => '[a-z]+',
	 *           'id' => '\d+',
	 *         )
	 *     );
	 *
	 * @return  string
	 * @uses    Route::REGEX_ESCAPE
	 * @uses    Route::REGEX_SEGMENT
	 */
	public static function compile($uri, array $regex = NULL)
	{
		if ( ! is_string($uri))
			return;

		// The URI should be considered literal except for keys and optional parts
		// Escape everything preg_quote would escape except for : ( ) < >
		$expression = preg_replace('#'.Route::REGEX_ESCAPE.'#', '\\\\$0', $uri);

		if (strpos($expression, '(') !== FALSE)
		{
			// Make optional parts of the URI non-capturing and optional
			$expression = str_replace(array('(', ')'), array('(?:', ')?'), $expression);
		}

		// Insert default regex for keys
		$expression = str_replace(array('<', '>'), array('(?P<', '>'.Route::REGEX_SEGMENT.')'), $expression);

		if ($regex)
		{
			$search = $replace = array();
			foreach ($regex as $key => $value)
			{
				$search[]  = "<$key>".Route::REGEX_SEGMENT;
				$replace[] = "<$key>$value";
			}

			// Replace the default regex with the user-specified regex
			$expression = str_replace($search, $replace, $expression);
		}

		return '#^'.$expression.'$#uD';
	}

	/**
	 * @var  callback     The callback method for routes
	 */
	protected $_callback;

	/**
	 * @var  string  route URI
	 */
	protected $_uri = '';

	/**
	 * @var  array
	 */
	protected $_regex = array();

	/**
	 * @var  array
	 */
	protected $_defaults = array('action' => 'index', 'host' => FALSE);

	/**
	 * @var  string
	 */
	protected $_route_regex;

	/**
	 * Creates a new route. Sets the URI and regular expressions for keys.
	 * Routes should always be created with [Route::set] or they will not
	 * be properly stored.
	 *
	 *     $route = new Route($uri, $regex);
	 *
	 * The $uri parameter can either be a string for basic regex matching or it
	 * can be a valid callback or anonymous function (php 5.3+). If you use a
	 * callback or anonymous function, your method should return an array
	 * containing the proper keys for the route. If you want the route to be
	 * "reversable", you need pass the route string as the third parameter.
	 *
	 *     $route = new Route(function($uri)
	 *     {
	 *     	if (list($controller, $action, $param) = explode('/', $uri) AND $controller == 'foo' AND $action == 'bar')
	 *     	{
	 *     		return array(
	 *     			'controller' => 'foobar',
	 *     			'action' => $action,
	 *     			'id' => $param,
	 *     		);
	 *     	},
	 *     	'foo/bar/<id>'
	 *     });
	 *
	 * @param   mixed    route URI pattern or lambda/callback function
	 * @param   array    key patterns
	 * @return  void
	 * @uses    Route::_compile
	 */
	public function __construct($uri = NULL, $regex = NULL)
	{
		if ($uri === NULL)
		{
			// Assume the route is from cache
			return;
		}

		if ( ! is_string($uri) AND is_callable($uri))
		{
			$this->_callback = $uri;
			$this->_uri = $regex;
			$regex = NULL;
		}
		elseif ( ! empty($uri))
		{
			$this->_uri = $uri;
		}

		if ( ! empty($regex))
		{
			$this->_regex = $regex;
		}

		// Store the compiled regex locally
		$this->_route_regex = Route::compile($uri, $regex);
	}

	/**
	 * Provides default values for keys when they are not present. The default
	 * action will always be "index" unless it is overloaded here.
	 *
	 *     $route->defaults(array(
	 *         'controller' => 'welcome',
	 *         'action'     => 'index'
	 *     ));
	 *
	 * If no parameter is passed, this method will act as a getter.
	 *
	 * @param   array  key values
	 * @return  $this or array
	 */
	public function defaults(array $defaults = NULL)
	{
		if ($defaults === NULL)
		{
			return $this->_defaults;
		}

		$this->_defaults = $defaults;

		return $this;
	}

	/**
	 * Tests if the route matches a given URI. A successful match will return
	 * all of the routed parameters as an array. A failed match will return
	 * boolean FALSE.
	 *
	 *     // Params: controller = users, action = edit, id = 10
	 *     $params = $route->matches('users/edit/10');
	 *
	 * This method should almost always be used within an if/else block:
	 *
	 *     if ($params = $route->matches($uri))
	 *     {
	 *         // Parse the parameters
	 *     }
	 *
	 * @param   string  URI to match
	 * @return  array   on success
	 * @return  FALSE   on failure
	 */
	public function matches($uri)
	{
		if ($this->_callback)
		{
			$closure = $this->_callback;
			$params = call_user_func($closure, $uri);

			if ( ! is_array($params))
				return FALSE;
		}
		else
		{
			if ( ! preg_match($this->_route_regex, $uri, $matches))
				return FALSE;

			$params = array();
			foreach ($matches as $key => $value)
			{
				if (is_int($key))
				{
					// Skip all unnamed keys
					continue;
				}

				// Set the value for all matched keys
				$params[$key] = $value;
			}
		}

		foreach ($this->_defaults as $key => $value)
		{
			if ( ! isset($params[$key]) OR $params[$key] === '')
			{
				// Set default values for any key that was not matched
				$params[$key] = $value;
			}
		}

		return $params;
	}

	/**
	 * Returns whether this route is an external route
	 * to a remote controller.
	 *
	 * @return  boolean
	 */
	public function is_external()
	{
		return ! in_array(Arr::get($this->_defaults, 'host', FALSE), Route::$localhosts);
	}

	/**
	 * Generates a URI for the current route based on the parameters given.
	 *
	 *     // Using the "default" route: "users/profile/10"
	 *     $route->uri(array(
	 *         'controller' => 'users',
	 *         'action'     => 'profile',
	 *         'id'         => '10'
	 *     ));
	 *
	 * @param   array   URI parameters
	 * @return  string
	 * @throws  Kohana_Exception
	 * @uses    Route::REGEX_Key
	 */
	public function uri(array $params = NULL)
	{
		// Start with the routed URI
		$uri = $this->_uri;

		if (strpos($uri, '<') === FALSE AND strpos($uri, '(') === FALSE)
		{
			// This is a static route, no need to replace anything

			if ( ! $this->is_external())
				return $uri;

			// If the localhost setting does not have a protocol
			if (strpos($this->_defaults['host'], '://') === FALSE)
			{
				// Use the default defined protocol
				$params['host'] = Route::$default_protocol.$this->_defaults['host'];
			}
			else
			{
				// Use the supplied host with protocol
				$params['host'] = $this->_defaults['host'];
			}

			// Compile the final uri and return it
			return rtrim($params['host'], '/').'/'.$uri;
		}

		while (preg_match('#\([^()]++\)#', $uri, $match))
		{
			// Search for the matched value
			$search = $match[0];

			// Remove the parenthesis from the match as the replace
			$replace = substr($match[0], 1, -1);

			while (preg_match('#'.Route::REGEX_KEY.'#', $replace, $match))
			{
				list($key, $param) = $match;

				if (isset($params[$param]))
				{
					// Replace the key with the parameter value
					$replace = str_replace($key, $params[$param], $replace);
				}
				else
				{
					// This group has missing parameters
					$replace = '';
					break;
				}
			}

			// Replace the group in the URI
			$uri = str_replace($search, $replace, $uri);
		}

		while (preg_match('#'.Route::REGEX_KEY.'#', $uri, $match))
		{
			list($key, $param) = $match;

			if ( ! isset($params[$param]))
			{
				// Look for a default
				if (isset($this->_defaults[$param]))
				{
					$params[$param] = $this->_defaults[$param];
				}
				else
				{
					// Ungrouped parameters are required
					throw new Kohana_Exception('Required route parameter not passed: :param', array(
						':param' => $param,
					));
			}
			}

			$uri = str_replace($key, $params[$param], $uri);
		}

		// Trim all extra slashes from the URI
		$uri = preg_replace('#//+#', '/', rtrim($uri, '/'));

		if ($this->is_external())
		{
			// Need to add the host to the URI
			$host = $this->_defaults['host'];

			if (strpos($host, '://') === FALSE)
			{
				// Use the default defined protocol
				$host = Route::$default_protocol.$host;
			}

			// Clean up the host and prepend it to the URI
			$uri = rtrim($host, '/').'/'.$uri;
		}

		return $uri;
	}

} // End Route

{'repo_name': 'eryx/php-framework-benchmark', 'stars': '131', 'repo_language': 'PHP', 'file_name': 'base.html.twig', 'mime_type': 'text/html', 'hash': 9150473843316915458, 'source_dataset': 'data'}


using System;
using ClosedXML.Excel;

namespace ClosedXML_Examples
{
    public class HelloWorld
    {
        public void Create(String filePath)
        {
            var workbook = new XLWorkbook();
            var worksheet = workbook.Worksheets.Add("Sample Sheet");
            worksheet.Cell("A1").Value = "Hello World!";
            workbook.SaveAs(filePath);
        }
    }
}

{'repo_name': 'ClosedXML/ClosedXML', 'stars': '1820', 'repo_language': 'C#', 'file_name': 'TablesTests.cs', 'mime_type': 'text/plain', 'hash': -2121080474002641448, 'source_dataset': 'data'}


/// Copyright (c) 2012 Ecma International.  All rights reserved.
/// Ecma International makes this code available under the terms and conditions set
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
/// "Use Terms").   Any redistribution of this code must retain the above
/// copyright and this notice and otherwise comply with the Use Terms.
/**
 * @path ch15/15.2/15.2.3/15.2.3.12/15.2.3.12-2-a-5.js
 * @description Object.isFrozen - 'P' is own accessor property that overrides an inherited data property
 */

function testcase() {

        var proto = {};

        Object.defineProperty(proto, "foo", {
            value: 12,
            configurable: false
        });

        var Con = function () { };
        Con.prototype = proto;
        var child = new Con();

        Object.defineProperty(child, "foo", {
            get: function () {
                return 9;
            },
            configurable: true
        });

        Object.preventExtensions(child);
        return !Object.isFrozen(child);
    }
runTestCase(testcase);

{'repo_name': 'wizzard0/js2lua', 'stars': '181', 'repo_language': 'JavaScript', 'file_name': 'shortcuts.js', 'mime_type': 'text/plain', 'hash': 3244337707537922192, 'source_dataset': 'data'}


using System.IO;
using System.Text;
using ScreenToGif.Util;

namespace ScreenToGif.ImageUtil.Psd.AditionalLayers
{
    internal class MetadataContent : IAditionalLayerInfo
    {
        internal string Signature { get; }

        public string Key { get; }

        internal bool CopyOnSheetDuplication { get; } = true;

        internal string Data { get; }

        public long Length => Content?.Length ?? 0;

        public byte[] Content
        {
            get
            {
                using (var stream = new MemoryStream())
                {
                    stream.WriteBytes(Encoding.ASCII.GetBytes(Signature)); //Signature, 4 bytes.
                    stream.WriteBytes(Encoding.ASCII.GetBytes(Key)); //Key, 4 bytes.
                    stream.WriteByte((byte)(CopyOnSheetDuplication ? 1: 0)); //Copy on sheet duplication, 1 byte.
                    stream.Position += 3; //Padding 3 bytes.

                    var bytes = Encoding.UTF8.GetBytes(Data);

                    stream.WriteUInt32((uint)BitHelper.ConvertEndian(bytes.Length)); //Data length, 4 bytes.
                    stream.WriteBytes(bytes);

                    return stream.ToArray();
                }
            }
        }
    }
}

{'repo_name': 'NickeManarin/ScreenToGif', 'stars': '11762', 'repo_language': 'C#', 'file_name': 'AssemblyInfo.cs', 'mime_type': 'text/plain', 'hash': -2419542980247147238, 'source_dataset': 'data'}


// Copyright (c) Lawrence Livermore National Security, LLC and other VisIt
// Project developers.  See the top-level LICENSE file for dates and other
// details.  No copyright assignment is required to contribute to VisIt.

// ************************************************************************* //
//                          avtMatErrorExpression.C                          //
// ************************************************************************* //

#include <avtMatErrorExpression.h>

#include <stdio.h>

// ****************************************************************************
//  Method: avtMatErrorExpression constructor
//
//  Programmer: Hank Childs
//  Creation:   January 1, 2005
//
// ****************************************************************************

avtMatErrorExpression::avtMatErrorExpression()
{
    ;
}

// ****************************************************************************
//  Method: avtMatErrorExpression destructor
//
//  Programmer: Hank Childs
//  Creation:   January 1, 2005
//
// ****************************************************************************

avtMatErrorExpression::~avtMatErrorExpression()
{
    ;
}

// ****************************************************************************
//  Method: avtMatErrorExpression::GetMacro
//
//  Purpose:
//      Applies the macro to create a new expression corresponding to
//      material error.
//
//  Programmer: Hank Childs
//  Creation:   January 1, 2005
//
// ****************************************************************************

void
avtMatErrorExpression::GetMacro(std::vector<std::string> &args, std::string &ne,
                            Expression::ExprType &type)
{
    const char *matname  = args[0].c_str();
    const char *mats     = args[1].c_str();

    //
    // So this is a bit unfortunate.  GetMacro can be called before the input
    // is set and we can determine what the topological dimension is.  No
    // matter -- we really just want to get it right when we do the actual
    // execute (when we will have a valid input).  So, if the input is NULL,
    // claim we want "volume".  If the input is not NULL, choose between
    // "volume" and "area".
    //
    // A similar problem happens with the meshname.
    //
    const char *volume = "volume";
    const char *meshname = "";
    if (*(GetInput()) != NULL)
    {
        avtDataAttributes &atts = GetInput()->GetInfo().GetAttributes();
        volume   = (atts.GetTopologicalDimension() == 3 ? "volume" : "area");
        meshname = atts.GetMeshname().c_str();
    }
    char new_expr[1024];
    sprintf(new_expr, "relative_difference(matvf(%s, %s), "
                                      "mirvf(%s, zoneid(%s), %s(%s), %s))",
                           matname, mats, matname, meshname, volume,
                           meshname, mats);
    ne = new_expr;
    type = Expression::ScalarMeshVar;
}

{'repo_name': 'visit-dav/visit', 'stars': '109', 'repo_language': 'C', 'file_name': 'Velodyne_test_data.7z', 'mime_type': 'text/plain', 'hash': -6089548180107036108, 'source_dataset': 'data'}


var convert = require('./convert'),
    func = convert('isRegExp', require('../isRegExp'), require('./_falseOptions'));

func.placeholder = require('./placeholder');
module.exports = func;

{'repo_name': 'rampatra/wedding-website', 'stars': '1016', 'repo_language': 'HTML', 'file_name': 'is-implemented.js', 'mime_type': 'text/plain', 'hash': -1064356147278708450, 'source_dataset': 'data'}


# nonexistent_server.rb
# this example shows what happens when you try connect to a nonexistent server
#
# start it with ruby nonexistent_server.rb

require "rubygems"
require File.expand_path("../lib/beetle", File.dirname(__FILE__))

# set Beetle log level to info, less noisy than debug
Beetle.config.logger.level = Logger::INFO

Beetle.config.servers = "unknown.railsexpress.de:5672"

# setup client
client = Beetle::Client.new
client.register_queue(:test)
client.register_message(:test)

# register our handler to the message, check out the message.rb for more stuff you can get from the message object
client.register_handler(:test) {|message| puts "got message: #{message.data}"}

# start listening
# this starts the event machine event loop using EM.run
# the block passed to listen will be yielded as the last step of the setup process
client.listen do
  EM.add_timer(10) { client.stop_listening }
end

{'repo_name': 'xing/beetle', 'stars': '158', 'repo_language': 'Ruby', 'file_name': 'redundant_queues.graffle', 'mime_type': 'text/xml', 'hash': -229219184301965861, 'source_dataset': 'data'}


var baseDelay = require('../internal/baseDelay'),
    restParam = require('./restParam');

/**
 * Invokes `func` after `wait` milliseconds. Any additional arguments are
 * provided to `func` when it is invoked.
 *
 * @static
 * @memberOf _
 * @category Function
 * @param {Function} func The function to delay.
 * @param {number} wait The number of milliseconds to delay invocation.
 * @param {...*} [args] The arguments to invoke the function with.
 * @returns {number} Returns the timer id.
 * @example
 *
 * _.delay(function(text) {
 *   console.log(text);
 * }, 1000, 'later');
 * // => logs 'later' after one second
 */
var delay = restParam(function(func, wait, args) {
  return baseDelay(func, wait, args);
});

module.exports = delay;

{'repo_name': 'houdunwang/video', 'stars': '323', 'repo_language': 'PHP', 'file_name': 'phpcms.sql', 'mime_type': 'text/plain', 'hash': -7544905946262850787, 'source_dataset': 'data'}


#
# (C) Copyright 2000-2006
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
#
# SPDX-License-Identifier:	GPL-2.0+
#

extra-y	= start.o

obj-y	= cpu.o

{'repo_name': 'compsec-snu/razzer', 'stars': '265', 'repo_language': 'C', 'file_name': 'install.sh', 'mime_type': 'text/x-shellscript', 'hash': -4658525699313666589, 'source_dataset': 'data'}